How to convert the QImage format to a format supported by OpenGL

I use QImage to load images, which are then used as textures in OpenGL. The problem is that the color components have a different order in QImage and OpenGL. I am currently using the GL_RGBA format in OpenGL and QImage::Format_ARGB32 in Qt. Because of this, I have to manually change the bytes for each pixel of the loaded image before creating the texture in OpenGL. Moreover, in order to correctly change the bytes, I need to know the finiteness of the machine.

Does anyone know a better solution for this? At least is there a way to make this conversion independent independent?

Thanks.

+4
source share
1 answer

The last three parameters of glTex(Sub)Image determine how pixel transfer occurs.

+5
source

All Articles