Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: How to display two different colors on two sides of a triangle?

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2003
    Posts
    1

    How to display two different colors on two sides of a triangle?

    I have tried to do as this:

    glColor3f(1.0f,0.0f,0.0f);
    glNormal3f(a,b,c);
    glVertex3f(...);
    glVertex3f(...);
    glVertex3f(...);

    glColor3f(0.0f,1.0f,0.0f);
    glNormal3f(-a,-b,-c);
    glVertex3f(...);
    glVertex3f(...);
    glVertex3f(...);

    but it doesn't work!who can help me!

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: How to display two different colors on two sides of a triangle?

    Enable backface culling and draw the triangle two times, one with vertices in clockwise order and one with vertices in counter clockwise order. OpenGL's backface culling is based on the order of the triangle's vertices in screen space, not the normal.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •