Hello all,
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 :
- TYPE_INT_RGB
- TYPE_INT_ARGB
- TYPE_INT_ARGB_PRE
- TYPE_INT_BGR
- TYPE_3BYTE_BGR
- TYPE_4BYTE_ABGR
- TYPE_4BYTE_ABGR_PRE
- TYPE_BYTE_GRAY
- TYPE_USHORT_GRAY
- TYPE_BYTE_BINARY
- TYPE_BYTE_INDEXED
- TYPE_USHORT_565_RGB
- TYPE_USHORT_555_RGB
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.
Thanks in advance for all your advices.