opengl 画圆

    float center_x = -pos.X();
    float center_y = -pos.Y();
    float center_z = -pos.Z();
    const float PI = 3.1425f;

//    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    glBegin(GL_TRIANGLE_FAN);//扇形连续填充三角形串
    glPointSize(5.0);
    int n =50;
    qglColor(QColor(255, 0, 0));
    int i = 0;
    for (i = 0; i <= n; i ++)
    {
        float p = 2* PI / n *i;
        glVertex3f(radius*sin(p)+center_x, radius*cos(p)+center_y, center_z);
    }
    glEnd();

 

 

当 开启 glenable(GL_CULL_FACE)  时,导致在反面看不到圆形;

posted @ 2019-09-12 14:37  eric_zw  阅读(532)  评论(0)    收藏  举报