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 3 of 3

Thread: Triangle Strip - Per Triangle color

  1. #1
    Intern Newbie
    Join Date
    Oct 2011
    Posts
    47

    Triangle Strip - Per Triangle color

    In the old OpenGL(glBegin, glEnd), when you draw a triangle strip, there was no way to set the color per-triangle. Only per-vertex. Is this the same with shaders? I would need to draw the heightmap from trianle strips but I need different colors for each triangle, ....so the edges between them are visible. Thanks!

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,126
    Quote Originally Posted by Aliii View Post
    In the old OpenGL(glBegin, glEnd), when you draw a triangle strip, there was no way to set the color per-triangle. Only per-vertex. Is this the same with shaders?
    With old fixed-function OpenGL, you did have glShadeModel( GL_FLAT ), and there was a convention for which vertex's color was used for the whole triangle.

    What you're talking about is termed flat shading, and AFAIK the capability for it it's still there, but generalized for shaders. You can search for it in the latest OpenGL Spec:

    * http://www.opengl.org/registry/doc/g...patibility.pdf

    In particular, see section "13.4 Flat Shading". You can set which vertex in the primitive defines the color and other values for the whole primitive. In your GLSL shader, you mark the interpolator in your shader with the interpolation qualifier "flat" to signify that you don't want it smoothly blended across the surface of the primitive, but left fixed. See the GLSL spec for details (in particular, Section 4.5 Interpolation Qualifiers):

    * http://www.opengl.org/registry/doc/GLSLangSpec.4.40.pdf
    Last edited by Dark Photon; 09-27-2013 at 07:22 AM.

  3. #3
    Intern Newbie
    Join Date
    Oct 2011
    Posts
    47
    Thanks! Works fine. Thats what I wanted!

Posting Permissions

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