Hello, everybody!
I’ve recently gotten back into programming with OpenGL. I’ve been working, actually, on a 2D game using OpenGL to enhance it with rotation, blending and so on.
Anyway, to the point. I use PNG images as textures for the sprites. No problems there. But now I want to be able to set an alpha value for the entire texture in addition to the per pixel alpha channel that’s available with the PNG image.
When I initialize OpenGL, I use the following lines:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
This works as I expect it to without any issues.
However, when I go to set an alpha value with glColor4f(), nothing happens.
So I thought that I needed to change the blend function. I used this function which seemed to work with a sample application that I poked around with:
glColor4f(1.0f,1.0f,1.0f,0.5f);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
Afterward I set the blend function back to the original method.
This doesn’t work. I get what appears to be some sort of alpha but it’s not what I expect. Additionally if I were to change any of the RGB values in glColor4f the texture is not adjusted as I would expect.
Obviously I don’t understand how to properly use glBlendFunc properly. I’ve looked at the documentation but I’m really not getting anywhere with it. I’ve also looked on google and, again, not really getting anywhere.
Long story short what I want to be able to do is apply a ‘per-texture’ alpha value to a texture that also has a ‘per-pixel’ alpha channel.
Thanks for taking the time to read over my post.