next up previous contents
Next: 6.1.2 Texture Coordinates Up: 6.1.1 The Texture Image Previous: 6.1.1 The Texture Image

6.1.1.1 Internal Texture Formats

If you care about the quality of your textures or want to conserve the amount of texture memory your application requires (and often conserving texture memory helps improve performance), you should definitely use appropriate internal formats. Internal texture formats were introduced in OpenGL 1.1. Table 1 lists the available internal texture formats. If your texture is known to be only gray-scale or luminance values, choosing the GL_LUMINANCE format instead of GL_RGB typically cuts your texture memory usage by one third. Requesting more efficient internal format sizes can also help. The GL_RGB8 internal texture format requests 8 bits of red, green, and blue precision for each texel. The more space efficient GL_RGB4 internal texture format uses only 4 bits per component making it require only half the texture memory of the GL_RGB8 format. Of course, the GL_RGB4 format only has 16 distinct values per component instead of 256 values for the GL_RGB8 format. However, if minimizing texture memory usage (and often improving texturing performance too) is more important than better texture quality, the GL_RGB4 format is a better choice. In the case where the source image for your texture only has 4 bits of color resolution per component, there is absolutely no reason to request a format with more than 4 bits of color resolution.


 
Table 1: OpenGL Internal Texture Formats. Each internal texture format has a corresponding base internal format and its desired component resolutions.
Sized Base R G B A L I
Internal Format Internal Format bits bits bits bits bits bits
ALPHA4 ALPHA       4    
ALPHA8 ALPHA       8    
ALPHA12 ALPHA       12    
ALPHA16 ALPHA       16    
LUMINANCE4 LUMINANCE         4  
LUMINANCE8 LUMINANCE         8  
LUMINANCE12 LUMINANCE         12  
LUMINANCE16 LUMINANCE         16  
LUMINANCE4_ALPHA4 LUMINANCE_ALPHA       4 4  
LUMINANCE6_ALPHA2 LUMINANCE_ALPHA       2 6  
LUMINANCE8_ALPHA8 LUMINANCE_ALPHA       8 8  
LUMINANCE12_ALPHA4 LUMINANCE_ALPHA       12 4  
LUMINANCE16_ALPHA16 LUMINANCE_ALPHA       16 16  
INTENSITY4 INTENSITY           4
INTENSITY8 INTENSITY           8
INTENSITY12 INTENSITY           12
INTENSITY16 INTENSITY           16
R3_G3_B2 RGB 3 3 2      
RGB4 RGB 4 4 4      
RGB5 RGB 5 5 5      
RGB8 RGB 8 8 8      
RGB10 RGB 10 10 10      
RGB12 RGB 12 12 12      
RGB16 RGB 16 16 16      
RGBA2 RGBA 2 2 2 2    
RGBA4 RGBA 4 4 4 4    
RGB5_A1 RGBA 5 5 5 1    
RGBA8 RGBA 8 8 8 8    
RGB10_A2 RGBA 10 10 10 2    
RGBA12 RGBA 12 12 12 12    
RGBA16 RGBA 16 16 16 16    
 

Some words of advice about internal texture formats: If you do not request a specific internal resolution for your texture image because you requested a GL_RGBA internal format instead of a size-specific internal format such as GL_RGBA8 or GL_RGBA4, your OpenGL implementation is free to pick the ``most appropriate'' format for the particular implementation. If a smaller texture format has better texturing performance, the implementation is free to choose the smaller format. This means if you care about maintaining a particular level of internal format resolution, selecting a size-specific texture format is strongly recommended.

Some words of warning about internal texture formats: Not all OpenGL implementations are expected to support all the available internal texture formats. This means just because you request a GL_LUMIANCE12_ALPHA4 format (to pick a format that is likely to be obscure) does not mean that your texture is guaranteed to be stored in this format. The size-specific internal texture formats are merely hints. If the best the OpenGL implementation can provide is GL_LUMINANCE8_ALPHA8, this will be the format you get, even though is provides less luminance precision and more alpha precision than you requested.


next up previous contents
Next: 6.1.2 Texture Coordinates Up: 6.1.1 The Texture Image Previous: 6.1.1 The Texture Image
David Blythe
1999-08-06