課堂作業1-1
先旋轉
再移動
結論:移動中再繞中心轉
課堂作業1-2
先移動
再旋轉
結論:繞著大鍋子邊緣轉
課堂作業二
Q1:buffer? 記憶體(緩衝區)
Q2:double(buffers)?兩被遮蔽 增加緩衝Q3:push pop?資料堆疊(push堆入 pop取出)
Q4:Matrix?矩陣
課堂作業三
製作一個會旋轉的茶壺
程式碼:
#include <GL/glut.h>
float rotX=0;
void display()
{
glClearColor(0,0,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX,0,1,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("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
課堂作業四
會上下左右旋轉的茶壺
#include <GL/glut.h>
float rotX=0,rotY=0;
void display()
{
glClearColor(0,0,1,1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotY,1,0,0);
glRotatef(rotX,0,1,0);
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);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}






沒有留言:
張貼留言