I am using glColor4f(). Surprisingly, changing the alpha, i.e., the fourth argument doesn't cause any change in transparency. The code segment is:
const GLfloat squareVertices[] = {
0.5, 0.5, 0.0,
-0.5, 0.5, 0.0,
0.5, -0.5, 0.0,
-0.5, -0.5, 0.0};
glEnableClientState (GL_VERTEX_ARRAY);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor4f (1.0, 0.0, 0.0, 0.5);
glLoadIdentity ();
glTranslatef(0, 0, -5);
glVertexPointer(3, GL_FLOAT, 0, squareVertices);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
Any pointers to where I could be going wrong?
You need to enable blending if you want to use transparency:
glEnable(GL_BLEND)
;
See also glBlendFunc to setup the blending function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With