Opengl textures and juce internal image format

Hi, i’ve done some development in opengl (especially on the implementation of a glx low level renderer in juce), and i discovered i practically can’t use opengl textures straight away from juce Image cause the internal format isn’t properly understood by the opengl driver which expect a RGBA (at least RGB or APHA_LUMINANCE) but not BGRA framebuffer (and no way for ARGB which is a rather uncommon colour pixel format from what i see around in other graphics libraries).
The juce image framebuffer structure is platform dependant, and on x86 machine is actually BGRA (which there isn’t any format in openGL right away, unless you use obscure and undocumented opengl extension, namely GL_BGRA_EXT which is also not present in a lot of video drivers implementation).

At the moment it is not possible to do a proper creation of a texture image using glTexImage2D without involving a colour space conversion before it (which is quite cpu consuming when you have big textures, generally a useless waste of cpu cycles).

The problem is visible also in the JuceDemo:
the background image behind the rotating cube is practically wrong cause the orange should not be blue (you can see the png to verify).

What should be the right way to mix the power of juce Images (ease of loading/saving, manipulation through Graphic class) and opengl textures without involving too much conversions or memory allocations ? Should a proper PixelRGBA format be added to the library ? Or there are some obscure opengl formats or special keywords i don’t know ?

well, i must answer myself. it was some obscure opengl bits ( namely the BGRA_EXT, though i don’t know how much support in opengl driver there is for this).

here it is:

glx support with argb and in video memory textures, usable in linux with a composite manager like compiz or xcompmgr. this could lead to some interesting bits, like projected 3d interfaces.
i’m actually completing the support, cleaning up and providing fallbacks to the old X11 visualization mechanics.

good job Kraken !

GL_BGRA_EXT should be supported by any decent graphic card, even the crappy intel ones !
you may use glview to check extension support (they say it works on linux with wine)