SweetDream
高歌一壶新酿酒,醉抱青山不必归。

 

平移函数:glTranslatef(-1.5f,0.0f,-6.0f);

平移当前位置。

重置函数:glLoadIdentity();

把当前位置置于屏幕中心(0.0f,0.0f,0.0f)     

 

 

OPENGL中画一个三角形的方法如下:

glBegin(GL_TRIANGLES);                // Drawing Using Triangles

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

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

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

glEnd();                              // Finished Drawing The Triangle

 

其中glBegin函数后面所带的参数是GLenum,它有很多种格式,分别对应不同图元的画法:

GL_POINTSGL_LINESGL_LINE_STRIPGL_LINE_LOOPGL_TRIANGLESGL_TRIANGLE_STRIP

GL_TRIANGLE_FANGL_QUADSGL_QUAD_STRIPGL_POLYGON

 

比如画一个四边形:

glTranslatef(3.0f,0.0f,0.0f);                   // Move Right 3 Units

    glBegin(GL_QUADS);                          // Draw A Quad

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

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

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

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

glEnd();                           

posted on 2006-02-08 14:13  SweetDream  阅读(344)  评论(0编辑  收藏  举报