About glArrayElement and glDrawElements

Hi,

In glDrawElements method, every vertex has a color which defined in glColorArray, but I would like draw each element in single color, what I should do? I must use glArrayElement?

Thanks in advance.

glColor3f(r, g, b);
glDrawElements(…);

Is that what you mean, that all vertices have the same colour? I hope I understood correctly.

Hope that helps.

Sorry for my poor english.

For example, I have two triangles, one is red, another is green, but I don’t know how to arrange color index, it seems glColorPointer is just for each vertex, so what can I do?

Thanks in advance.

Oh, OK. Unfortunately, you will have to duplicate vertices, like you would with vertices with more than 1 texcoord.

Hope that helps.

Nice to your reply, Thanks.

Here is another question.

I have a lot of trangles and quads, which is plot by using Gl_Begin and Gl_End, while the number is increasing, the performance is so bad, do you have any ideas to solve problem?

Thanks in advance.

[This message has been edited by zhangjunyue (edited 09-28-2001).]

Use glDrawElements to render them. It can render an entire list of independent quads or triangles with only one function call.

I’m kinda wondering why you asked, since you started this discussion talking about glDrawElements.