I am testing Vertex Arrays stuff, but for some reason the glDrawElements command does not draw anything for me. I can draw using glBegin / glEnd and glDrawElements between them, but glDrawElements does not work. Here's the code snippet:
These arrays are set in the constructor:
double points[100];
GLint indices[50];
for (int i=0; i < 50; i++){
points[2*i] = radius * cos(i*2*PI/50);
points[2*i + 1] = radius * sin(i*2*PI/50);
indices[i] = i;
}
Working code using only an array of points with glArrayElement:
void GLCircle::draw()
{
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_DOUBLE, 0, points);
glBegin(GL_POLYGON);
for (int i=0; i < 50; i++){
glArrayElement(i);
}
glEnd();
}
Also working code using an array of points, specific indices available through an array of indices:
void GLCircle::draw()
{
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_DOUBLE, 0, points);
glBegin(GL_POLYGON);
for (int i=0; i < 50; i++){
glArrayElement(indices[i]);
}
glEnd();
}
Broken code trying to use glDrawElements:
void GLCircle::draw()
{
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_DOUBLE, 0, points);
glDrawElements(GL_POLYGON, 4, GL_INT, indices);
}
Any tips? For me it is not necessary to use it at this moment, but it worries that it does not work ...