Every time I try and load a texture using JOGL the VM explodes. Heres the code where its called:
public Texture getTexture(String name,
String resourceName,
int target,
int dstPixelFormat,
int minFilter,
int magFilter,
boolean wrap,
boolean mipmapped) throws IOException
{
int srcPixelFormat = 0;
// create the texture ID for this texture
int textureID = createTextureID();
System.out.println("Loading texture "+resourceName+" to ID: "+textureID);
Texture texture = new Texture(resourceName,target,textureID);
// bind this texture
gl.glBindTexture(target, textureID);
BufferedImage bufferedImage = loadImage(resourceName);
// Getting the real Width/Height of the Texture in the Memory
int realWidth = get2Fold(bufferedImage.getWidth());
int realHeight = get2Fold(bufferedImage.getHeight());
// don't need it?
texture.setBufferedImage(bufferedImage);
texture.setWidth(realWidth);
texture.setHeight(realHeight);
if (bufferedImage.getColorModel().hasAlpha()) {
srcPixelFormat = GL.GL_RGBA;
} else {
srcPixelFormat = GL.GL_RGB;
}
// convert that image into a byte buffer of texture data
ByteBuffer textureBuffer = convertImageData(bufferedImage,texture);
int wrapMode = wrap ? GL.GL_REPEAT : GL.GL_CLAMP;
if (target == GL.GL_TEXTURE_2D)
{
gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_S, wrapMode);
gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_T, wrapMode);
gl.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, minFilter);
gl.glTexParameteri(target, GL.GL_TEXTURE_MAG_FILTER, magFilter);
}
// create either a series of mipmaps of a single texture image based on what's loaded
if (mipmapped)
{
glu.gluBuild2DMipmaps(target,
dstPixelFormat,
realWidth,
realHeight,
srcPixelFormat,
GL.GL_UNSIGNED_BYTE,
textureBuffer);
}
else
{
gl.glTexImage2D(target, //<==Horrible horrible VM death
0,
dstPixelFormat,
realWidth,
realHeight,
0,
srcPixelFormat,
GL.GL_UNSIGNED_BYTE,
textureBuffer );
}
return texture;
}
Loading texture img/props/test.png to ID: 1