4. Now the story: All the above seems to be cool right? Well, I wish it was :) If I am loading a regular image (64x64, 128x128, 1024x1024 and etc.) everything works ok. If I am loading something like 1020x1020 or maybe 700x900 it MIGHT be ok, but not 100% (for instance, 1010x1010 doesnt load). Finally, if I try 129x129 or maybe 65x65 (or any other combination with numbers, which cannot be divided by 2), it fails 100%! Horrible...
5. Exception Here I provided you with the exception thrown by glTexImage2D, you can notice that here I was trying to load 1023x1023 image, because 1023 * 1023 * 3 = 3139587 bytes, which prooves that ByteBuffer was assembled right, but in some case JOGL wants me too pass him 3142653 bytes... uhm..? And again: if I am loading a regular image (64x64, 128x128, 1024x1024 and etc.) everything works ok.
Caused by: java.lang.IndexOutOfBoundsException: Required 3142653 remaining bytes in buffer, only had 3139587
The first two references are to guys who didnt rewind their ByteBuffers... My ByteBuffer is rewinded. My problem is that I am doing everything right, but somehow JOGL wants more bytes from me on irregular size images. Also I have noticed that when I was creating ByteBuffer with alpha channel and specifing GL_RGBA in glTexImage2D like that, the problem was gone: