GlColor4f () - alpha value effect

I am using glColor4f (). Surprisingly, the alpha change, i.e. The fourth argument does not lead to a change in transparency. Code Segment:

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 might be wrong?

+7
source share
1 answer

You need to enable blending if you want to use transparency:

glEnable(GL_BLEND) ;

See also glBlendFunc to customize the blend function.

+13
source

All Articles