Hi people.
As I mentioned here http://www.jmonkeyengine.com/jmeforum/index.php?topic=9876.0 I’m trying to load textures from ByteBuffer and not from images.
I have my textures on a file packaged with an special tool. Some textures are saved in internal format (COMPRESSED), like EXTTextureCompressionS3TC.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
I’m trying to create a texture with this method:
Image img;
img = new Image(formato,width,height,byteTexture);
TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
Texture tex = new Texture2D();
tex.setMinificationFilter(MinificationFilter.NearestNeighborNoMipMaps);
tex.setMagnificationFilter(MagnificationFilter.NearestNeighbor);
tex.setImage(img);
ts.setTexture(tex);
Note that byteTexture is a "ByteBuffer" filled with the RAW bits in format DX5
The problem occurs when LWJGLTextureState try to load the texture. It calls this procedure.
switch (texture.getType()) {
case TwoDimensional:
// ensure the buffer is ready for reading
image.getData(0).rewind();
// send top level to card
GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0,
TextureStateRecord.getGLDataFormat(image
.getFormat()), image.getWidth(), image
.getHeight(), hasBorder ? 1 : 0,
TextureStateRecord.getGLPixelFormat(image
.getFormat()), GL11.GL_UNSIGNED_BYTE,
image.getData(0));
This call causes an error:
java.lang.IllegalArgumentException: Number of remaining buffer elements is 4194304, must be at least 16777216
This is normal because this procedure needs widthxheightx4 bytes. (in my case is 2048x2048x4 = 16777216) but the ByteBuffer have only 4194304 because is in format compressed.
It needs to call this function.
ARBTextureCompression.glCompressedTexImage2DARB(GL11.GL_TEXTURE_2D,
0,
TextureStateRecord.getGLDataFormat(image.getFormat()),
image.getWidth(),
image.getHeight(),
0,
byteTexture);
Why should I do?
Make my own Path (look at the texture format, and if it is compressed call ARBTextureCompresion) or try to contact to some "official developer" to change this.