internal formats. What are they good for?

Posts: 321
Joined: 2004.10
Post: #1
My title should say what are the GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, and GL_INTENSITY internal formats used for? I use GL_RGBA all the time so I think I know what that does Smile

The Red Book introduces them in the section on glTexImage2D() function
and even talks about issues of performance. But then they just seem to be
dropped and never addressed elsewhere.
Quote this message in a reply
Posts: 133
Joined: 2008.05
Post: #2
For the internal format parameter, you're specifying how the data is stored in the block of data you're sending to glTexImage2D. Most of the time you'll be using GL_RGBA or GL_RGB when using a color image, which is 32 or 24 bits per pixel, 4 or 3 components per pixel. The other ones specify how many bits per component and how many components in some different orders.

Using those parameters you mentioned for the type has an affect on the way the texture is blended into the scene. There is a table on this page to explain how they work.
Quote this message in a reply
Posts: 1,232
Joined: 2002.10
Post: #3
LongJumper Wrote:For the internal format parameter, you're specifying how the data is stored in the block of data you're sending to glTexImage2D.


The format and type specify what your data is.
The internal format specifies how you'd like GL to store your data, internally. It has no relation to the data you pass in, whatsoever.

You can think of this as a conversion process. You hand RGBA bits to GL, and tell it to keep and use them as LUMINANCE. Or vice versa. A more practical example might be you handing RGBA bits in, and asking GL to keep them as compressed DXT3 RGBA bits.

You can also specify sized internal formats, such as RGBA4, RGBA8, RGB5_A1 etc. This is handy if you've got pixels that you know don't need very many bits to accurately represent and you want to save some VRAM. Most image decompressors (jpeg, png etc) will only give you back 8 bpc data. But if your cartoon sprites only need 16 quantized colors, you can ask for RGBA4 internal format.

An important note here is that the internal format you specify is only a hint. The internal format that is ultimately used is up to the hardware, and might be different from device to device. You can query the internal format that was really chosen via glGetTexLevelParameter(...GL_TEXTURE_INTERNAL_FORMAT...)

Also, this is probably obvious but if there is a mismatch between your client format and the internal format, there is going to be a conversion. That costs some CPU cycles.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  File formats qwsed 10 8,608 Dec 18, 2010 10:49 AM
Last Post: AnotherJake
  Tex Internal Formats - Clarification Jones 2 3,035 Nov 17, 2006 10:25 PM
Last Post: Jones
  3D Model Formats Joseph Duchesne 3 3,325 Feb 27, 2006 01:30 PM
Last Post: akb825
  sound file formats in OpenAL unknown 7 7,672 Nov 6, 2005 12:50 AM
Last Post: Skorche
  OpenGL formats and endians Skorche 1 2,921 Jul 11, 2005 09:29 PM
Last Post: OneSadCookie