消除锯齿可以分为:

1,点,线

//glEnable(GL_POINT_SMOOTH);
    //glHint(GL_POINT_SMOOTH, GL_NICEST);

    //glEnable(GL_LINE_SMOOTH);
    //glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

    //glEnable(GL_POLYGON_SMOOTH_HINT);
    //glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);




2,多边形。

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_MULTISAMPLE);



//采用了多重采样,点线设置将会忽略掉
    //glEnable(GL_POINT_SMOOTH);
    //glHint(GL_POINT_SMOOTH, GL_NICEST);

    //glEnable(GL_LINE_SMOOTH);
    //glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

    //glEnable(GL_POLYGON_SMOOTH_HINT);
    //glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);



例子:

void CShape3D::drawTriangle(void) {
    glClear(GL_COLOR_BUFFER_BIT);

    glEnable(GL_MULTISAMPLE);
    glEnable(GL_BLEND); //enable 
    glBlendFunc(GL_ONE, GL_ONE); //设置混合后的颜色
    glBegin(GL_TRIANGLE_STRIP);
        glColor3f(0.0f, 1.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT);
        glVertex3fv(vTanglePoint[0]);
        glVertex3fv(vTanglePoint[1]);
        glVertex3fv(vTanglePoint[2]);
        glVertex3fv(vTanglePoint[3]);
    glEnd();    

    glBegin(GL_TRIANGLE_STRIP);
        glColor3f(1.0f, 0.0f, 0.0f);
        glClear(GL_COLOR_BUFFER_BIT);
        glVertex3fv(vDesTanglePoint[0]);
        glVertex3fv(vDesTanglePoint[1]);
        glVertex3fv(vDesTanglePoint[2]);
        glVertex3fv(vDesTanglePoint[3]);
    glEnd();

    glFlush();
    glDisable(GL_BLEND);// 画完后disable掉
    glDisable(GL_MULTISAMPLE);
    glutSwapBuffers();
}



注:

GL_MULTISAMPLE这个宏,是

glew库中的,

GLUT_MULTISAMPLE

freeglut库中的