How to get a flat, non-interpolated color when using vertex shaders.

Posted by Brett on Stack Overflow See other posts from Stack Overflow or by Brett
Published on 2010-04-21T17:21:51Z Indexed on 2010/04/21 17:23 UTC
Read the original article Hit count: 348

Filed under:
|
|
|

Hi,
Is there a way to achieve this? If I draw lines like this

glShadeModel(GL_FLAT);
glBegin(GL_LINES);
  glColor3f(1.0, 1.0, 0.0);
  glVertex3fv(bottomLeft);
  glVertex3fv(topRight);

  glColor3f(1.0, 0.0, 0.0);
  glVertex3fv(topRight);
  glVertex3fv(topLeft);
  .
  .
  (draw a square)
  .
  .
glEnd();

I get the desired result (a different colour for each edge) but I want to be able to calculate the fragment values in a shader. If I do the same after setting up my shader program I always get interpolated colors between vertices. Is there a way around this? (would be even better if I could get the same results using quads)

Thanks

© Stack Overflow or respective owner

Related posts about opengl

Related posts about c++