I've got a question about the best image type to use with the glTexImage2D and glTexSubImage2D functions. I've read over the Khronos wiki that most graphic cards prefers the BGRA format but the BufferedImage class only provides the following image types in its constructor :
To me, the closest image type in this list seems to be the TYPE_4BYTE_ABGR but I'm not sure at all. Does OpenGL has to do some stuff to put the alpha component at the end for rendering ? If so, that would mean the ABGR is not the best suitable image type. Maybe OpenGL can reverse from ARGB to BGRA faster and then the TYPE_INT_ARGB image type would give better performance… ? (once again, I'm not sure at all).
Do you advice me to implement my own method to convert a ARGB BufferedImage into BGRA BufferedImage ? (and then call the glTexImage2D and glTexSubImage2D functions with the image type parameter set to GL_BGRA) Or let OpenGL do the stuff ? (because it may be fastest than my own stuff)
Another idea would be to create TYPE_3BYTE_BGR buffered images and then do the stuff in an extra method to add the alpha component at the beginning to keep the 4-alignment. Once again, I'm not sure if it's the best way to have something optimized.
Once again, perfect solution provided by Mr Gouesse
Just replaced all the stuff generating a BufferedImage with awtGlReadBufferUtil.readPixelsToBufferedImage by a simple awtGlReadBufferUtil.readPixels and it's running twice faster now ^^
All I have to try now is to see if it's possible to easily resize a TextureData to see if it makes me gain a bit more FPS (resizing my reflection texture was something I made to speed up a little my app)