I am completely new to opengl and need some help in drawing a texture with gradient applied over it.
Now I am drawing a texture with the following code:
glPushMatrix();
glBindTexture(GL_TEXTURE_2D,fcr.texture);
glTranslatef(trans, 0, 0);
glScalef(sc,sc,1.0);
glColor4f(1.0,1.0,1.0,0.4);
glDrawArrays(GL_TRIANGLE_STRIP,0,4);
glColor4f(1,1,1,1);
In the above code glColor4f(1.0,1.0,1.0,0.4);
applies transparency to the drawn image. Now instead of a solid transparent color, I would like to apply a transparent gradient to the image so as to simulate the fading out effect.
Found this thread iPhone OpenGL - How to gradient fade out a texture?, which is the same as my question except I want the gradient to be applied to the main image itself instead of reflection. But I couldn't figure out the solution from answers given.
I guess I should use glTexEnvi
, but then how to draw another image with the gradient?