Reputation: 6437
From what I've seen, the GL_ALPHA8
internal pixel format has been removed from the OpenGL core specification in OpenGL 3.1. It seems that there are no more pixel formats with an alpha channel but no RGB channels. Does that mean that the only alternative is to create an GL_RGBA8
texture and set the RGB components to 255, therefore wasting 75% of its memory?
Upvotes: 2
Views: 1442
Reputation: 473447
Simply use the GL_R8
format. If changing your textures to swizzle properly is a concern, you can set up a swizzle mask to do it at fetch time. For instance:
GLenum swizzleMask = {GL_ZERO, GL_ZERO, GL_ZERO, GL_RED};
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask);
Upvotes: 5
Reputation: 129764
You can use GL_RED
and treat it as alpha in the fragment shader (e.g. output_colour = vec4(1., 1., 1., texture2D(sampler, texcoords).r);
).
Upvotes: 2