I want to render an indexed geometry. So, I have a bunch of vertices and associated sequenced indices. I am using glDrawElements()
to render 2 quads as given below. Now, I know I can use glColorPointer()
for specifying color per vertex.
My question is: Can I specify color per primitive? If yes, then how should I do it for this indexed geometry?
static GLint vertices[] ={0,0,0,
1,0,0,
1,1,0,
0,1,0,
0,0,1,
0,1,1};
static GLubyte indices[]={0,1,2,3,
0,3,5,4}
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEXARRAY);
//glColorPointer(3, GL_FLOAT,0,colors);
glVertexPointer(3,GL_INT,0,vertices);
glDrawElements( GL_QUADS, sizeof( indices ) / sizeof( GLubyte ), GL_UNSIGNED_BYTE, indices );