PDA

View Full Version : transparency



drummerboy_2002
07-25-2002, 11:30 AM
I've only messed with OpenGL a little. I use it with C++ and Glut. Forgive me if this seems too novice. How do I make a polygon transparent? Yes, it has to do with the alpha values, but how do I use it?

Lets say I have a simple triangle in front of a quad. I use float values for the color. What do I do to see the quad through the triangle? What do I need to enable? I'm trying to keep this case very simple so as to keep the answer simple.

nexusone
07-25-2002, 12:04 PM
Use this color function before the object.

glColor4f(r, g, b, a)

alpha channel set's transparency

t = 0.0 to 1.0.
1.0 = non-transparent
0.5 = 50% transparent
0.0 = transparent


Originally posted by drummerboy_2002:
I've only messed with OpenGL a little. I use it with C++ and Glut. Forgive me if this seems too novice. How do I make a polygon transparent? Yes, it has to do with the alpha values, but how do I use it?

Lets say I have a simple triangle in front of a quad. I use float values for the color. What do I do to see the quad through the triangle? What do I need to enable? I'm trying to keep this case very simple so as to keep the answer simple.

Rob The Bloke
07-25-2002, 02:30 PM
Originally posted by nexusone:
Use this color function before the object.

glColor4f(r, g, b, a)

alpha channel set's transparency

t = 0.0 to 1.0.
1.0 = non-transparent
0.5 = 50% transparent
0.0 = transparent



Although you might want to enable alpha blending for that to work.....

glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);

satan
07-25-2002, 11:56 PM
And you have to draw your promitives in back to front order.

drummerboy_2002
07-26-2002, 06:15 AM
Cool, thanks guys.

07-27-2002, 09:36 PM
how to draw a polygon??

satan
07-28-2002, 12:22 AM
Originally posted by sim3:
how to draw a polygon??

Choosing GL_POLYGON as primitive.
And then the standard: glBegin/glEnd, DL, VA, CVA, VAR, VAO (just what you want and what is supported by your hardware)