1-1
有三個移動變形效果
Translate 是平移
rolate是旋轉
scale是放大

1-2

第一個的意思是以中間為中心(恆星),車子會以行星的方式對著恆星
繞著轉
1-3

第二個的意思是上一個的視角互換,這次以車子做為恆星為中心點旋轉
作業2

#include <GL/glut.h>
float rotX=0;
void display()
{
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX,0,1,0);
glColor3f(1,0,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("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
Q&A
Q1:什麼是glPushMatrix();?glPopMatrix();?
glPushMatrix();
備份Matrix(matrix裡有translate,rotate,scale的量值)
glPopMatrix();
還原Matrix(回到剛剛push時的樣子)
Q2:什麼是double buffers?
兩倍記憶體。
沒有留言:
張貼留言