2016年3月22日 星期二

Week05, 郭芳蓁

1.

先移動再旋轉:



心得:先移動再旋轉會繞著中心點旋轉。

先旋轉再移動:



心得:先旋轉再移動會繞著軸移動。
2.
Q1.   buffer:記憶體緩衝區
Q2.   double buffers:兩被遮蔽,增加緩衝
Q3.   push pop:push是堆入,pop是取出,所以push pop是資料堆疊
Q4.   Matrix:矩陣

3.
左右旋轉的茶壺:




程式碼:
#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();
}

4.
上下左右旋轉的茶壺:




程式碼:
#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);
    glutInitWindowSize(600,600);
    glutInitWindowPosition(700,0);
    glutCreateWindow("Hello 3D");

    glutMotionFunc(motion);
    glutDisplayFunc(display);

    glutMainLoop();
}

沒有留言:

張貼留言