glTexImage2D() - RGBA or BGRA ... does it matter?


When I create my textures, does it matter if they are RGBA or BGRA or whatever? Some people say the BGR order is “faster” … these vague arguments do not convince me.

I’m now creating my textures like this:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pImageData);

I did some searching in the forum but most informative threads were kinda oldish, so I thought I’d ask it here.


It was true that BGR most of the times resulted in faster performance.

Even if this would be true right now, there’s nothing to worry. The video card will put the texture in its own internal format so besides downloading speed to it (which will be unnoticeably faster/slower thosedays), there should be no problem in using one format or the other.

If you want to speed up everything, you may want to consider the idea to specify texture format so the texture does not get upsampled to higher bit depth if it does not need to.

Thanks for the swift and informative answer, Obli

Just as I thought, converting BGR<->RGB in hardware is merely flipping a few switches/gates/whateverTheyAre. I was just wondering if there was something quirky about it.

Who cares about the loading times anyway, we all just love waiting our games/textures to load for a few minutes …

I’m sticking with GL_RGBA then.



I know for a fact that certain kinds of popular hardware will convert from RGBA in memory to BGRA using the CPU, before the texture is uploaded. This increases texture load time, as you note.

Also, I believe even some very popular high-performance cards may still be doing this, at least the slightly older but still popular models.

Last, most image file formats on disk (TGA, BMP, most JPG loading libraries, etc) store/generate the texture data in BGRA format in memory, because that’s how the hardware and screen device wants it (on x86). Last, a BGRA pixel (again, on x86) will read as 0xAARRGGBB as a hex longword, so if you generate pixel values, this is typically what you expect.

All in all, if there’s no particular reason to use another format, you will usually be happiest with BGRA in memory.

Originally posted by jwatte:
…All in all, if there’s no particular reason to use another format, you will usually be happiest with BGRA in memory.

I agree, actually, I use RGBA because I’m too lazy to use another format. RGBA sounds better.