Hi!
Test case: create any texture of size (128x16) and try to load it with TextureLoader2 while specifying mipmap = true.
It will result in Exception:
java.lang.IndexOutOfBoundsException
at java.nio.Buffer.checkBounds(Unknown Source)
at java.nio.DirectByteBuffer.put(Unknown Source)
at com.xith3d.scenegraph.ImageComponent2D.setImage(ImageComponent2D.java:181)
at com.xith3d.scenegraph.ImageComponent2D.(ImageComponent2D.java:72)
at com.xith3d.loaders.texture.TextureLoader2.createTexture(TextureLoader2.java:571)
at com.xith3d.loaders.texture.TextureLoader2.createTexture(TextureLoader2.java:509)
at com.xith3d.loaders.texture.TextureLoader2.getTexture(TextureLoader2.java:408)
at com.xith3d.loaders.texture.TextureLoader2.getTexture(TextureLoader2.java:244)
…
I believe there are little “slip of pen” mistakes at the following lines (TextureLoader2):
in createTexture(BufferedImage img, int format, boolean mipmap, int width, int height):
581 int nextWidth = Math.max(1, width >> 1);
582 int nextHeight = Math.max(1, width >> 1); // should be height!!!
in createMipMaps(Texture2D tex, ImageComponent2D ic, boolean mipmap):
622 int nextWidth = Math.max(1, width >> 1);
623 int nextHeight = Math.max(1, width >> 1); // should be height!!!
I’m not sure really :), but at least no crash anymore
Bohdan.