Texture Alpha

As with materials and glColor, textures can include an alpha component.

This is done by using GL_RGBA, instead of GL_RGB, for the format (and internal format) of the texture.

GLubyte textureImage[IMAGE_HEIGHT][IMAGE_WIDTH][4];


glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, IMAGE_WIDTH, IMAGE_HEIGHT,
             0, GL_RGBA, GL_UNSIGNED_BYTE, textureImage);

Of course, a textured object can also be drawn transparently using a single alpha value in its glColor or glMaterial.
Adding an alpha component to the texture itself allows you to vary the transparency texel-by-texel.

Example code: textureAlpha.c



next