Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
4  
You need to switch to vertex buffers. –  bobobobo Nov 3 '12 at 22:51

1 Answer 1

up vote 3 down vote accepted

The problem here, almost certainly, is not that you're "darkening" your vertices by specifying the vertex colors. The problem is more likely to do with how you're rendering everything in general -- you appear to be using immediate mode in your code sample, and although you claim to be using display lists which are somewhat better, you're likely going to want to switch to VBOs as suggested by bobobobo.

However, your performance issue could be somewhere else entirely, for example, you may not be culling your voxels as aggressively as you could. You're not providing enough information to answer the question about your poor render performance, though.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.