Newbie - applying textures

Here's the exception I get following the online tutorial.  The code is pretty simple, so what could be wrong?


java.lang.IndexOutOfBoundsException: 157311
   at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:209)
   at org.lwjgl.opengl.glu.MipMap.gluScaleImage(MipMap.java:237)
   at org.lwjgl.opengl.glu.MipMap.gluBuild2DMipmaps(MipMap.java:95)
   at org.lwjgl.opengl.glu.GLU.gluBuild2DMipmaps(GLU.java:381)
   at com.jme.scene.state.lwjgl.LWJGLTextureState.apply(LWJGLTextureState.java:247)
   at com.jme.util.TextureManager.loadTexture(TextureManager.java:252)
   at com.jme.util.TextureManager.loadTexture(TextureManager.java:158)
   at com.codecrate.shard.ui.TextureManager.loadTexture(TextureManager.java:14)
   at com.codecrate.shard.ShardHack.simpleInitGame(ShardHack.java:28)
   at com.jme.app.SimpleGame.initGame(SimpleGame.java:366)
   at com.jme.app.BaseGame.start(BaseGame.java:64)
   at com.codecrate.shard.ShardHack.main(ShardHack.java:22)




public class ShardHack extends SimpleGame {

    private final TextureManager textureManager;

    public ShardHack() {
        super();
        setDialogBehaviour(NEVER_SHOW_PROPS_DIALOG);
        this.textureManager = new TextureManager();
    }

    public static void main(String[] args) {
        new ShardHack().start();
    }

    protected void simpleInitGame() {
        display.setTitle("Shard Hack");

        Texture texture = textureManager.loadTexture("MetallicTile.jpg");

        TextureState ts = display.getRenderer().createTextureState();
        ts.setEnabled(true);
        ts.setTexture(texture);

        Sphere s = new Sphere("Sphere", 30, 30, 25);
        s.setLocalTranslation(new Vector3f(0,0,-40));
        s.setModelBound(new BoundingBox());
        s.updateModelBound();
        s.setRenderState(ts);

        rootNode.attachChild(s);
    }
}

Also, I extracted the texture loading to a seperate class:


    public Texture loadTexture(String name) {
        return com.jme.util.TextureManager.loadTexture(
                classLoader.getResource("MetallicTile.jpg"),
                Texture.MM_LINEAR,
                Texture.FM_LINEAR);
    }

pretty sure that it has something to do with the loadTexture call might try sending it a URL,filename,or awt.image not for the loaded .jpg but this is all a guess.  I too am having troubles with TextureManager hope this solves your problem

wireframe, are your textures power of two? If not, scale them to power of two and try again.

I'll check the image size and get back to you tonight.  THanks for the feedback. 



Is there someway for jme to check that the image size is correct to prevent this kind of user error?  should i file a RFE for this?

The trouble is, most modern cards can handle power of two textures just fine, but the glu mipmapping stuff can't seem to. I guess we could put in a check if mipmapping is enabled.

Yep, resizing the image worked for me.  I actually just grabbed the "Monkey.jpg" from the jme tests and it worked great. 



Thanks for your help, i hope it'll be smooth sailing from here on out (for a while at least).