Results 1 to 3 of 3

Thread: Triangle Strip - Per Triangle color

  1. #1
    Member Contributor
    Join Date
    Oct 2011
    Posts
    60

    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
    Join Date
    Oct 2004
    Posts
    4,649
    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

  3. #3
    Member Contributor
    Join Date
    Oct 2011
    Posts
    60
    Thanks! Works fine. Thats what I wanted!

Similar Threads

  1. triangle strip: which triangle am I in?
    By BenFoppa in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-08-2014, 07:35 PM
  2. Newbie: color blending on terrain grid as triangle strip
    By Ultimaswc3 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-06-2013, 05:53 PM
  3. Help with Triangle strip
    By Jeffg in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-30-2010, 09:52 AM
  4. triangle strip with a LINE triangle display error
    By Samme in forum OpenGL: Windows
    Replies: 22
    Last Post: 11-20-2008, 07:50 PM
  5. How To Triangle Strip?
    By imported_nomad in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 05-20-2002, 10:24 AM

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