I couldn't find an up to date tutorial about it and I'm not sure how this can be done.
I have an image with a text (the game title), it's a 200x100 BMP image.
Some pixels are have the (255, 0, 255) color and during the loading, I set the alpha value to 255 when I find these values.
In my initialization code:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
An my pixel shader:
void main()
{
color = texture2D(objectTexture, UV).rgba;
}
So it's displaying fine, but I want to add an effect of fade in/out on it, but just the title, nothing else.
The "regular" way I found is to create a polygon that covers the image and change it's alpha, but then the things behind it are also faded (and you can notice the polygon around it).
Another way is to create a pixel shader that receives an alpha value, and I send these values I calculate based on the time, so I have in the pixel shader:
in float alpha;
void main()
{
color = vec4(texture2D(objectTexture, UV).rgb, alpha);
}
But this would surely mess the already transparent pixels since I'm discarding the image's alpha values.
I found about the command glTexEnv() but I couldn't find it in the OpenGL4.0 reference pages, so I'm guessing it's outdated and I couldn't find the updated one.
How can I get this effect?