Login  Register

Texture Issue Again :(

Posted by Haroogan on Mar 07, 2011; 1:27pm
URL: https://forum.jogamp.org/Texture-Issue-Again-tp2646111.html

I'm quite stuck here, and can't continue any development until this mystery is explained.

I'm loading texture 2049 x 2049 (size does not matter! this one is given just as an example). And now I want to pass it with GL2.GL_RGB or GL2.GL_BGR (also does not matter), therefore I prepare my ByteBuffer as follows:

ByteBuffer.allocateDirect(2049 * 2049 * 3).order(ByteOrder.nativeOrder());

Later, I fill it with texture information and call "glTexImage2D" and here's what I get as a response:

Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException: Required 12597251 remaining bytes in buffer, only had 12595203

So now let's count: 2049 * 2049 * 3 = 12595203, so WTF? I mean why he asks me for 12597251 bytes?
Since I had one of last year JOGL releases installed - I have decided to install the newest one 2011-03-03, but the problem is still here. Right, maybe I don't understand something?

BTW, if I add alpha channel (change from GL2.GL_RGB to GL2.GL_RGBA) and extend buffer to 2049 * 2049 * 4 - everything works fine - this is a complete mystery to me...

Edit: I've just noticed that 12597251 - 12595203 = 2048 = 2049 - 1, there must be some dependency, eh?