首页 > 解决方案 > 使用 for 循环绘制球体

问题描述

我想用for循环画一个球体(我想画一个球体而不是圆,请帮忙)

void drawCircle(double x, double y, double r)
{
    glColor3f(nodeBGClolor.r, nodeBGClolor.g, nodeBGClolor.b);
    int iterations = 500;
    glBegin(GL_POLYGON);
    for (int i = 0; i < iterations; i++)
    {
        double currX = r * cos(2 * PI * (i / (iterations * 1.0)));
        double currY = r * sin(2 * PI * (i / (iterations * 1.0)));
        glVertex2f(x + currX, y + currY);
    }
    glEnd();
}

标签: openglopengl-3

解决方案


推荐阅读