-
why not transparent?
I think the alpha channel controls the transparency of the colors, and I think the following code should generate a almost transparent sphere, through which we can see a triangle. But can anyone tell me why it doesn't work?
Thanks, it is in PyOpenGL
glTranslatef( 0.15, 0.15, 0 )
glColor4f(0.5, 0.9, 0.3, 0.0025 ) # almost transparent
glutSolidSphere( 0.5, 40, 40 )
glPushMatrix()
glTranslatef( 0.15, 0.15, -0.1)
glColor4f(1, 0, 0, 0.25)
glBegin(GL_TRIANGLES)
glVertex3f( 0.0, 1.0, 0.0)
glVertex3f(-1.0,-1.0, 0.0)
glVertex3f( 1.0,-1.0, 0.0)
glEnd()
glPopMatrix()
glFlush()
-
Advanced Member
Frequent Contributor
Re: why not transparent?
You'll need to enable blending and choose the right blend function. Something like:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules