I am trying to use the glDrawElements() with glColorPointer() set to “color” elements/faces and not the individual vertices. Does anybody know if this is possible and if so, please help.
For example, I have an ASCII file that has a section with X, Y, Z coordinates and Elements/face section with point/nodal connectivity. such that:
I have been setting the GLfloat colors[] array using R, G, B but it looks like the colors are determined on the vertices/nodes and not for the element/face which is what I would like.
All data specified using the gl*Pointer calls are per vertex. On GeForce 8 and better hw the functionality you seek can be implemented using geometry shaders however on any older hw you have to create new vertex for each unique combination of Node and element color. So the vertices might look something like:
For each vertex, you need to have a color and that’s not going to change.
Use index rendering (glDrawElements or glDrawRangeElements)
and you will be able to reuse vertices that are identical (same vertex and color)
Do you know of a link or some quick and simple example(s) of face/element coloring using index rendering? I am using glDrawElements() but am new, so any help would be great.