Color Material Mode

Changing material properties frequently is relatively expensive (i.e. time consuming).

Sometimes you will have a model that has varying colors - different colors per vertex - within a single series of polygons, and you want it to be lighted.

Rather than making calls to glMaterial for each vertex, you can use color-material mode, and call glColor to change the material's color. e.g.:

    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
    ...
    glColor3f(r,g,b);
    glVertex3f(x,y,z);
    ...


Example: topo-color.c



next