PDA

View Full Version : Vertex Array



takercena
07-16-2012, 12:03 AM
I have problem in rendering multiple similar shape (circle).
This is my code


void initCircleVertices(float r)
{
float degree = 0;
unsigned int ctr = 0;

for(int xi = -320; xi < 320; xi+= 2*r)
{
for(int yi = 240; yi > -240; yi-= 2*r)
{
for(int i = 0; i < 360; ++i)
{
vertices.push_back(xi + r * cos(float(degree)));
vertices.push_back(yi + r * sin(float(degree)));
vertices.push_back(-8);

indices.push_back(i+ctr);
++degree;
}
ctr += 360;
degree = 0;
}
}
}


void drawCircles()
{
unsigned int i = 0;
for(i = 0; i < indices.size()/360; ++i)
{
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, &vertices[i*360]);
glDrawElements(GL_LINE_LOOP, 360, GL_UNSIGNED_INT, &indices[i*360]);
glDisableClientState(GL_VERTEX_ARRAY);
}
}




resulting in this imagehttp://tinypic.com/view.php?pic=kvpk0&s=6. How to render it normally?