-
different colors on either side of triangle
I am trying to draw some (rotatable) surfaces (say, a blanket) in 3D and I want either side of the surface to have a different color. One logical limit of this is to draw a single triangle with a different color on either side. I can't do this.
I can use culling and get no back surface, and I can use glPolygonMode(GL_BACK, GL_LINES) and get wire-frame, but I cannot get a different color there.
I have tried glColorMaterial(GL_BACK, GL_AMBIENT_AND_DIFFUSE) glColor3f(1.0,0.0,0.0), and a variety of other methods. The back always comes out the same color as the front.
There is something here I don't understand. Help,
wayne
-
Re: different colors on either side of triangle
use 2 different triangles, one offset very slightly from the other, so they appear to be different triangles. Then pick which color you want each triangle to be.
-
Re: different colors on either side of triangle
rhink,
Thanks for the reply. I can see that will work for the individual triangle, but when I draw a complex surface, composed of perhaps millions of such triangles, that solution seems impractical. Or at least it seems there ought to be a better way. Is there no way to use GL_BACK and GL_FRONT to solve this problem?
thanks again,
wayne
-
Re: different colors on either side of triangle
I figured it out. In order to make the GL_BACK stuff work I need to enable two
sided lighting via
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE)
I guess I need to spend more time reading the reference manual.
Thanks,
wayne
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