Problem with loading jpg texture

Unfortunately I am facing problems loading a jpg as a texture. Weirdly enough it works fine with a jpg of size 600x509 but I can not load a jpg of the size 746x346.



Both are not powers of 2 but one works while the other one makes the application crash with the following output:



Mar 10, 2005 4:12:04 PM com.jme.scene.TriMesh <init>
INFO: TriMesh created.
java.lang.IndexOutOfBoundsException: 1855481424
at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:208)
at org.lwjgl.opengl.glu.MipMap.gluScaleImage(MipMap.java:235)
at org.lwjgl.opengl.glu.MipMap.gluBuild2DMipmaps(MipMap.java:108)
at org.lwjgl.opengl.glu.GLU.gluBuild2DMipmaps(GLU.java:381)
at com.jme.scene.state.lwjgl.LWJGLTextureState.apply(Unknown Source)
at com.jme.util.TextureManager.loadTexture(Unknown Source)
at com.jme.util.TextureManager.loadTexture(Unknown Source)


Here is the responsible source code:


monkeyLoc=firstMonkeySketchbook.class.getClassLoader().getResource("72.jpg");
TextureState ts=firstMonkeySketchbook.getInstance().getTextureState();
Texture t=TextureManager.loadTexture(monkeyLoc, Texture.MM_LINEAR, Texture.FM_LINEAR);
t.setWrap(Texture.WM_WRAP_S_WRAP_T);
ts.setTexture(t);



I am working under Mac OSX, Version 10.3.8

Where is my mistake? 8-O

Thanks,
Ralph

jME doesn’t currently support texture the size of non-power of 2.



Having said that, i know that 256x128 works fine :slight_smile:



DP

I was afraid that you might say that.

:’(



But thank you very much for your quick reply anyway!



Ralph

while jME doesn’t support non-power of two textures it doesn’t restrict them. That is, you should be able to load the texture, depending on the card you’ll have different results. (Evident by your success in loading the first texture). Most commonly a black banding.



Your error seems to be generated from the mip map creation and

java.lang.IndexOutOfBoundsException: 1855481424

1,855,481,424 is quite a few bytes (I doubt you want to spend 2 Gig on 1 texture :wink: ). Perhaps gluBuild2DMipmaps is having problems with that particular size of texture.