OpenGL Color Interpolation across vertices

Posted by gutsblow on Stack Overflow See other posts from Stack Overflow or by gutsblow
Published on 2010-04-16T20:20:50Z Indexed on 2010/04/16 20:23 UTC
Read the original article Hit count: 377

Right now, I have more than 25 vertices that form a model. I want to interpolate color linearly between the first and last vertex. The Problem is when I write the following code

glColor3f(1.0,0.0,0.0);
vertex3f(1.0,1.0,1.0);
vertex3f(0.9,1.0,1.0);
.
.`<more vertices>;
glColor3f(0.0,0.0,1.0);
vertex3f(0.0,0.0,0.0);

All the vertices except that last one are red. Now I am wondering if there is a way to interpolate color across these vertices without me having to manually interpolate color natively (like how opengl does it automatically) at each vertex since, I will be having a lot more number of colors at various vertices. Any help would be extremely appreciated.

Thank you!

© Stack Overflow or respective owner

Related posts about opengl

Related posts about color