What is a fast way to darken the vertices I'm rendering?

Posted by Luis Cruz on Game Development See other posts from Game Development or by Luis Cruz
Published on 2012-11-03T22:25:11Z Indexed on 2012/11/03 23:19 UTC
Read the original article Hit count: 417

Filed under:
|
|

To make a lighting system for a voxel game, I need to specify a darkness value per vertex. I'm using GL_COLOR_MATERIAL and specifying a color per vertex, like this:

glEnable(GL_COLOR_MATERIAL);


glBegin(GL_QUADS);

glColor3f(0.6f, 0.6f, 0.6f);
glTexCoord2f(...);
glVertex3f(...);

glColor3f(0.3f, 0.3f, 0.3f);    
glTexCoord2f(...);
glVertex3f(...);

glColor3f(0.7f, 0.7f, 0.7f);        
glTexCoord2f(...);
glVertex3f(...);

glColor3f(0.9f, 0.9f, 0.9f);
glTexCoord2f(...);
glVertex3f(...);

glEnd();

This is working, but with many quads it is very slow.. I'm using display lists too. Any good ideas in how to make vertices darker?

© Game Development or respective owner

Related posts about opengl

Related posts about lighting