圖二是以車子中心點為元新開始旋轉。
所以兩方的旋轉起來的樣子會有所不同。
#include <GL/glut.h>
float rotx=0;
float roty=0;
void display()
{
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotx,0,1,0);
glColor3ub(255,0,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
rotx=x;
roty=y;
display();
}
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
Q1
glPushMatrix();
置入資料並且固定。
glPopMatrix();
輸出資料可供改變。
Q2
Buffers:
記憶體緩衝,使圖片完整。
Double Buffers:
兩倍記憶體緩衝。



沒有留言:
張貼留言