glPushMatrix(); //備份矩陣
glTranslatef(x,y,z); //移動
glRotatef(angle,x,y,z); //旋轉
glScalef(x,y,z); //放大縮小
glBegin(GL_POLYGON); //開始畫
glColor3f(r,g,b); //顏色
glVertex3f(x,y,z); //頂點
glNormal3f(nx,ny,nz); //打光法向量
glTexCoord3f(tx,ty); //貼圖座標
glEnd(); //結束
glPopMatrix(); //還原矩陣
Two. 旋轉
float angle=0;
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
angle++;
glPushMatrix();
glRotatef(angle,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
///1
glPushMatrix();
glTranslatef(0,0.6,0);
glutSolidTeapot(0.3);
glPopMatrix();
///2
glPushMatrix();
glTranslatef(0,-0.6,0);
glutSolidTeapot(0.3);
glPopMatrix();
///3
glutSwapBuffers();
}
沒有留言:
張貼留言