glPushMartix();//備份矩陣
glRotatef(angle,x,y,z);//旋轉
glTranslatef(x,y,z);//移動
glScalef(x,y,z);//縮放
glBegin(GL_POLYGON)//開始畫
glNormal3f(nx,ny,nz);打光的法向量
glTexCoord2f(tx,ty);貼圖的座標
glColor3f(r,g,b);顏色
glEnd();結束畫
glPopMartix();還原矩陣
2.
打光
const GLfloat light_position[] = { 2.0f, -5.0f, -5.0f, 0.0f };
3.
static void display(void)
{
angle++;
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0,0.6,0);
glutSolidTeapot(0.3);
glPopMatrix();
glPushMatrix();
glRotatef(angle,0,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
glutIdleFunc(display);
glutDisplayFunc(display);
4. 幾何圖形
static void display(void)
{
angle++;
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0,0.6,0);
glutSolidTeapot(0.3);
glPopMatrix();
glPushMatrix();
glRotatef(angle,0,1,0);
glutSolidCone(0.5,0.2,50,50);
glPopMatrix();
glutSwapBuffers();
}




沒有留言:
張貼留言