Results 1 to 4 of 4

Thread: different colors on either side of triangle

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    Oklahoma
    Posts
    5

    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

  2. #2
    Junior Member Newbie
    Join Date
    Feb 2000
    Posts
    24

    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.

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    Oklahoma
    Posts
    5

    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

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    Oklahoma
    Posts
    5

    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

Similar Threads

  1. Triangle side is not straight line
    By MirzaSe in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 09-03-2014, 03:43 PM
  2. glColorPointer and colors for whole triangle
    By kraeste in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-23-2011, 03:51 AM
  3. TBN Matrix on back-side of triangle
    By Jan in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 06-28-2008, 09:11 AM
  4. How to display two different colors on two sides of a triangle?
    By loginlog in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 03-23-2003, 10:37 PM
  5. Fastest way to determin which side of a triangle
    By NicholasFrancis in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 01-02-2002, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean