WEEK 5
作業 1 :
作業 1 :
- 判斷 Translatef 與 Rotatef 轉動的差別
- Translatef 是軸的原點為轉動的中心點
- Rotatef 是以物件為轉動的中心點
作業 2 :
做可以旋轉的茶壺
****Buffer 繪圖暫存記憶體空間*****
*****DoubleBuffer兩倍記憶體空間*****
今天的程式碼 :
#include <GL\glut.h>
float rotX=0;
void display()
{
glClearColor(0, 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();
}
作業 3 :
Q1: Buffer ? 是一個緩衝區,讓電腦準備下一張圖的地方
Q2: Double ? 有兩個地方 以遮住螢幕A,把螢幕換到螢幕B,螢幕A準備下一張圖
Q3: Depth? 圖型深度Z 讓重疊的圖有距離,呈現最前面的圖
作業 4 :
可以上下旋轉
#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();
}







沒有留言:
張貼留言