Wednesday, December 6, 2006

What is the optimal 32 bit texture format?

The optimal texture format on all systems, regardless of endianness or operating system, is an internal format of GL_RGBA8, a type of GL_UNSIGNED_INT_8_8_8_8_REV, and a format of GL_BGRA. An optimal call to glTexImage2D would thus be this:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, border, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);

Remember that because this is a packed integer format, you are responsible for taking endianness into account when packing the pixels.

References:
GL_NV_pixel_data_range (look at NVIDIA Implementation Details).
Mac OpenGL mailing list

1 comment:

Brad Parker said...

I know this is a really old post, but I just wanted to leave this here in case anyone else saw it. On my Windows 7 machine with NVIDIA GT 240, GL_RGBA is actually significantly faster than GL_BGRA.