question about glDrawElements

Hello everybody,
I have a question about glDrawElements… I have an array of objects that I’m currently rendering using vertex arrays (one vertex array for each obj), but I want to set a different color for each object. glColor3f doesn’t seem to affect the current color and I think it has something to do with vertex arrays being on the client side… my question is, how can I change the color for each object?? do I need to enable GL_COLOR_ARRAY on the client side? and if so… do I need to specify a color (3 floats, ints…) for each vertex? or a color for each triangle in the indices list??

Hope my question makes sense :slight_smile:
Thanks in Advance!

Elefagente Secreto,
If you want to apply a single colour to an object, glColor*() should be enough, and you do not need colour array at all.

Colour in vertex array implementation is for vertex, not face(polygon). Please look at the following link about a simple usage of vertex array.
Vertex Array

Originally posted by songho:
[b]Elefagente Secreto,
If you want to apply a single colour to an object, glColor*() should be enough, and you do not need colour array at all.

Colour in vertex array implementation is for vertex, not face(polygon). Please look at the following link about a simple usage of vertex array.
Vertex Array [/b]
Songho,
Many thanks for your reply :slight_smile: . I’m looking at the code right now, however, there must be something wrong with the app because whenever I run the .exe in the vertexArray.zip I get a “the instruction at 0x00000000 referenced memory…” error.

Edit: or it just may be that I’m using a very old computer at work hehe

Elefagente Secreto,
The error may result from glDrawRangeElements(). It is available from OpenGL v1.2 or greater.

If you think your system is too old, please disable this function and try to re-compile yourself.

In order to make sure the capabilities of your video card, run glinfo . It will print out useful info into a file, glinfo.txt, such as version, supported extensions, available visual modes, etc.

Originally posted by songho:
[b]Elefagente Secreto,
The error may result from glDrawRangeElements(). It is available from OpenGL v1.2 or greater.

If you think your system is too old, please disable this function and try to re-compile yourself.

In order to make sure the capabilities of your video card, run glinfo . It will print out useful info into a file, glinfo.txt, such as version, supported extensions, available visual modes, etc.[/b]
Thanks songho, comparing your code to mine, I found out the call to glColorMaterial was missing, so even if I specified any color, it wouldn’t work :slight_smile: now it works, thx for the help.