作業一
![]() |
| 車子繞著中心轉動,類似於貼著鍋邊開動 |
![]() |
| 車子移動至右邊轉動,以自身為軸心轉動,是自轉
作業二
|
{
glClearColor(1,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotx,0,1,0); /////glRotatef(朝著X軸為角度移動,0,Y軸,0);
glColor3f(1,1,0);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
rotx=x;
display();
}
int main(int argc,char**argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("hellow3D");
glutDisplayFunc(display);兩者都是當程式執行到這裡時,就將該函數叫出執行
glutMotionFunc(motion);
glutMainLoop();
}
作業三
Q1:BUFFER是什麼呢?
是記憶體緩衝區。
Q2:DOUBLE BUFFERS是什麼呢?
DOUBLE BUFFERS 給你兩個緩衝區,然後將作畫輪流於兩的緩衝區交替,
利用人視覺暫留的現象,使得圖片不會有Lag的感覺。
Q3:Push Pop?
Push():將資料存入堆疊,在堆疊的頂端新增資料。
Pop():從堆疊取出資料,每執行一次,就從頂端取出一個資料。
Q4:Matrix?
矩陣。
作業四
float rotx=0,roty=0;//記得變數要增加一個
void display()
{
glClearColor(1,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotx,0,1,0);
glRotatef(roty,1,0,0);//增加以X軸為中心,Y軸轉動的函數。
glColor3f(1,1,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);
glutInitWindowSize(600,600);
glutInitWindowPosition(700,0); 更改畫面大小
glutCreateWindow("hellow3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
作業四
float rotx=0,roty=0;//記得變數要增加一個
void display()
{
glClearColor(1,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotx,0,1,0);
glRotatef(roty,1,0,0);//增加以X軸為中心,Y軸轉動的函數。
glColor3f(1,1,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);
glutInitWindowSize(600,600);
glutInitWindowPosition(700,0); 更改畫面大小
glutCreateWindow("hellow3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}








沒有留言:
張貼留言