我在使用这些代码在屏幕上渲染许多圆圈时遇到问题。
float degree = 0;
unsigned int ctr = 0;
for(int xi = -3200; xi < 3200; xi+= 2*r)
{
for(int yi = 4800; yi > -4800; 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;
}
}
unsigned int i = 0;
for(i = 0; i < indices.size()/360; ++i)
{
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, &vertices[i*360]);
glLineWidth(1);
glDrawElements(GL_LINE_LOOP, 360, GL_UNSIGNED_INT, &indices[i*360]);
glDisableClientState(GL_VERTEX_ARRAY);
}
这是结果
另外,当我将 xi 值更改为 [-6400, 6400] 时程序崩溃