Choice between color and materials

Hello everybody:

I am puzzled with OpenGL GLSL recently on using color or material in OpenGL Programming. The problem is : which should be used vertex color or vertex materials, or both?

Previously, I use the color for each vertex. However, it seems that by using material properties we could get a more realistic rendering for viewing. And I realized some good reanding result by using material in my program. However, when I was reading the red book (Programming Guide), I noticed that the book is using both color and material property for rendering when consider multi-lights and multi-materials. I am wondering which is best/correct way to use? Since I have the material property why I need the color for each vertex? Or it is just an example to show that the current GLSL language is so powerful to realize whatever you want by programming ?

Best wishes!

Jacky

If GL_LIGHTING is disabled, each vertex has the colour specified via glColor() or glColorPointer(); materials and lights have no effect.

If GL_LIGHTING is enabled, each vertex’ colour is calculated based upon the material and lights. Vertex colours can still be specified by glColor() or glColorPointer(), in which case they affect some of the material colours according to the glColorMaterial() setting.

But all this is ancient history. Modern code tends to perform lighting calculations on a per-fragment basis using shaders, with material properties (at least the diffuse colour, sometimes others) stored in textures.

Even before shaders, fixed-function lighting was never particularly useful.