绘制球体(顶点数组和索引数组)
GLint statcky = 60;
GLint stlicex = 60;
const float PI = 3.1415926;
std::vector<float> drawglobeVBO() {
std::vector<float> c;
GLfloat R = 0.5f;
GLfloat angleHy = (GLfloat)(2 * PI) / statcky;
GLfloat angleZx = (GLfloat)(2 * PI) / stlicex;
GLfloat NumAngleHy = 0;
GLfloat NumAngleZx = 0;
GLfloat x = 0;
GLfloat y = 0;
GLfloat z = 0;
for (float j = 0; j < statcky; j++)
{
for (float i = 0; i < stlicex; i++)
{
NumAngleHy = angleHy * i;
NumAngleZx = angleZx * j;
GLfloat x = R * cos(NumAngleHy) * cos(NumAngleZx);
GLfloat y = R * sin(NumAngleHy);
GLfloat z = R * cos(NumAngleHy) * sin(NumAngleZx);
c.push_back(x);
c.push_back(y);
c.push_back(z);
}
}
return c;
}
std::vector<int> drawglobeEBO() {
std::vector<int> ebo;
std::vector<float> vbo = drawglobeVBO();
int only = vbo.size();
int num = (int)((only / (3 * statcky)) * 2);
for (int x = 0; x < stlicex / 2;)
{
for (int y = 0; y < statcky