updateTextureSubImage & java.lang.IllegalArgumentException

Hi guys.



I create a texture and set an Image to it like that:


        final Texture2D ta = new Texture2D();
        ta.setAnisotropicFilterPercent(0);
        ta.setMinificationFilter(MinificationFilter.NearestNeighborNoMipMaps);
        ta.setMagnificationFilter(MagnificationFilter.NearestNeighbor);

        URL texURL = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_TEXTURE, texName);
        Image image = TextureManager.loadImage(texURL, false);
        ta.setImage(image);

        final TextureKey tkey = new TextureKey(texURL, false, image.getFormat());
        ta.setTextureKey(tkey);
        ta.setImageLocation(tkey.getLocation().toString());



The texture  and image are loaded fine and show up as intended.

Now when I load another image and want to copy it over the original image like that:


        texURL = ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_TEXTURE, texName2);
        image = TextureManager.loadImage(texURL, false);
        DisplaySystem.getDisplaySystem().getRenderer().updateTextureSubImage(ta, 0, 0, image, 0, 0, 256, 256);



I get the following exception:


java.lang.IllegalArgumentException: Number of remaining buffer elements is 32768, must be at least 196608
   at org.lwjgl.BufferChecks.throwBufferSizeException(BufferChecks.java:136)
   at org.lwjgl.BufferChecks.checkBufferSize(BufferChecks.java:151)
   at org.lwjgl.BufferChecks.checkBuffer(BufferChecks.java:156)
   at org.lwjgl.opengl.GL11.glTexSubImage2D(GL11.java:2752)
   at com.jme.renderer.lwjgl.LWJGLRenderer.updateTextureSubImage(LWJGLRenderer.java:1825)
   at com.jme.image.TextureAnimated.setTime(TextureAnimated.java:68)
   at com.jme.image.TextureAnimated.update(TextureAnimated.java:40)
   at jmetest.renderer.TestTextureAnimation.simpleUpdate(TestTextureAnimation.java:86)
   at com.jme.app.SimpleGame.update(SimpleGame.java:60)
   at com.jme.app.BaseGame.start(BaseGame.java:85)
   at jmetest.renderer.TestTextureAnimation.main(TestTextureAnimation.java:81)



Both images are the same size and everything, i just copied the same image and renamed it. The images are DXT1 .dds images. Debugging shows that both images have 32768 bytes of data right before the call.

Thanks for any help.
dhdd

Hi guys.



I just found out it has something to do with the .dds file format. The code works fine if I use .bmp images instead of .dds images. Anyone any idea why?

isn't dxt1 a compressed format? maybee there comes your exception from.

dhdd said:

Hi guys.

I just found out it has something to do with the .dds file format. The code works fine if I use .bmp images instead of .dds images. Anyone any idea why?


i could never get image blitting working on dds sourced textures...
it was something to do with DTX compression...
try turning off compression for textures maybe...

TextureManager.COMPRESS_BY_DEFAULT = false;