Iphone – Change texture opacity in OpenGL

iphoneopengl-es

This is hopefully a simple question: I have an OpenGL texture and would like to be able to change its opacity, how do I do that? The texture already has an alpha channel and blending works fine, but I want to be able to decrease the opacity of the whole texture, to fade it into the background. I have fiddled with glBlendFunc, but with no luck – it seems that I would need something like GL_SRC_ALPHA_MINUS_CONSTANT, which is not available. I am working on iPhone, with OpenGL ES.

Best Answer

I have no idea about OpenGL ES, but in standard OpenGL you would set the opacity by declaring a colour for the texture before you use it:

//          R,   G,   B,   A
glColor4f(1.0, 1.0, 1.0, 0.5);

The example would give you 50% alpha without affecting the colour of your texture. By adjusting the other values you can shift the texture colour too.

Related Topic