In the init function, use the following two lines:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
And in your rendering function, make sure that it is glColor4fused instead glColor3f, and set the 4th argument to the desired opacity level.
glColor4f(1.0, 1.0, 1.0, 0.5);
glBegin(GL_QUADS);
glVertex3f(-1.0, +1.0, 0.0);
glVertex3f(-1.0, -1.0, 0.0);
glVertex3f(+1.0, -1.0, 0.0);
glVertex3f(+1.0, +1.0, 0.0);
glEnd();
source
share