I'm loading a texture that consists just of the alpha channel.
No, you're not. You're loading a texture that consists of one color channel.
"Alpha" is merely an interpretation of your data. And you are free to interpret data however you wish. But to OpenGL, "one color channel" is spelled "red". Two color channels are spelled "red/green". And so forth.
If you want to make a one channel shader look like it is alpha-only to your shader, then you should use a texture swizzle:
GLint swizzleMask[] = {GL_ZERO, GL_ZERO, GL_ZERO, GL_RED};
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
why is there still GL_ALPHA
?
Are you asking why the enumerator exists? If so, then you may not understand the separation between the internal format of a texture (the third parameter) and the pixel transfer format (the third-to-last parameter). The former defines what data exists in the texture. GL_RED
means that the texture will have one color channel with unsigned, normalized values of an indeterminate size (stop using unsized image formats).
The latter defines how data from your application is read into the image. It is legal (though nobody would call it fast) to only upload data to specific color channels of an image. For example, if you have a 4-channel image, you could upload data to just the green channels in it using the GL_GREEN
transfer format.