SweetDream
高歌一壶新酿酒,醉抱青山不必归。
    设置一个顶点的颜色我们可以通过调用glColor3f函数,传入的参数为指定的颜色,这样以后绘制顶点都将使用这种颜色,除非重新设置颜色。比如我们要绘制一个三个角分别为红,绿,蓝的三角型,我们可以使用以下代码:

glBegin(GL_TRIANGLES);                // Drawing Using Triangles

    glColor3f(1.0f,0.0f,0.0f);        // Set The Color To Red

    glVertex3f( 0.0f, 1.0f, 0.0f);    // Top

    glColor3f(0.0f,1.0f,0.0f);        // Set The Color To Green

    glVertex3f(-1.0f,-1.0f, 0.0f);    // Bottom Left

    glColor3f(0.0f,0.0f,1.0f);        // Set The Color To Blue

    glVertex3f( 1.0f,-1.0f, 0.0f);    // Bottom Right

glEnd();                              // Finished Drawing The Triangle

posted on 2006-02-10 01:17  SweetDream  阅读(241)  评论(0编辑  收藏  举报