java.lang.IndexOutOfBoundsException: 1098306

Hey all… Again… Does anybody have any idea why this bit of code:




   private void initDanceFloor() {
      floor = new Box("Large Dance Floor", new Vector3f(), 65 / 2, .1f, 65 / 2);
      floor.setLocalTranslation(new Vector3f(0, -0.11f, 0));
      Box floor2 = new Box("Actual Dance Floor", new Vector3f(), 50 / 2, .1f, 50 / 2);
      floor2.setLocalTranslation(new Vector3f(0, .1f, 0));
      
      TextureState ts = display.getRenderer().createTextureState(); // Use the TextureManager to load a texture
      try {
         File texture = new File("floor.jpg");
         Texture t = TextureManager.loadTexture(texture.toURL(), Texture.MM_LINEAR, Texture.FM_LINEAR);
         t.setWrap(Texture.WM_WRAP_S_WRAP_T);
         ts.setTexture(t);
         floor.setRenderState(ts);
         texture = new File("floor2.jpg");
         t = TextureManager.loadTexture(texture.toURL(), Texture.MM_LINEAR, Texture.FM_LINEAR);
         t.setWrap(Texture.WM_WRAP_S_WRAP_T);
         ts.setTexture(t);
         floor.setRenderState(ts);
      } catch (MalformedURLException e) {
         System.err.println("Unable To Apply Texture To The Floor");
      }

      rootNode.attachChild(floor);
      rootNode.attachChild(floor2);
   }




Would cause this failure?:



java.lang.IndexOutOfBoundsException: 1098306
   at java.nio.DirectByteBuffer.get(Unknown Source)
   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)
   at DanceSim.initDanceFloor(DanceSim.java:82)
   at DanceSim.simpleInitGame(DanceSim.java:42)
   at com.jme.app.SimpleGame.initGame(Unknown Source)
   at com.jme.app.BaseGame.start(Unknown Source)
   at DanceSim.main(DanceSim.java:103)
31-Mar-2005 22:01:09 com.jme.app.SimpleGame cleanup
INFO: Cleaning up resources.
31-Mar-2005 22:01:09 com.jme.app.BaseGame start
INFO: Application ending.



Cheers,

Roja

I noticed btw that you seem to be applying two different textures to the same floor (when you seem like you’d want to apply the second one to floor2). Also, the error might be caused because the image you’re loading doesn’t have dimensions that are powers of two?

Cheers mate… Think the power of 2 thing may be the bussom of the issues i was having (what comes with using free textures off the tinterweb!)



Will bear it in mind on future texture location missions :slight_smile:



Regards

Roja