課堂作業 1 :
移動、旋轉
移動到畫面右邊後 在畫面的右邊 以車子本身為中心做旋轉
課堂作業 2 :
旋轉、移動
車子移動到畫面右邊後 整個畫面以畫面中心為中心做旋轉 (車子沿中心繞圈)
課堂作業 3 :
Q1 : Buffer -> 記憶體緩衝區
Q2 : Double (Buffers) -> 多一倍的遮蔽,增加緩衝時間
課堂作業 4 :
Q1 : Push Pop ->
Q2 : Maytrix ->
課堂作業 5 :
鑽寫一個程式碼 寫出一個會轉的茶壺
程式碼 :
#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(rotX, 0, 1, 0);
glRotatef(rotY, 1, 0, 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();
}
程式碼 :
#include <GL/glut.h>
float rotX=0, rotY=0;
void display()
{
glClearColor(0, 0, 1, 1);
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glRotatef(rotX, 0, 1, 0);
glRotatef(rotY, 1, 0, 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);
glutInitWindowSize(600, 600);
glutInitWindowPosition(700, 0);
glutCreateWindow("hello3D");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}






沒有留言:
張貼留言