2016年3月22日 星期二

Week 05 林品至



作業一


先開啟
Transformation


右鍵

                                               

旋轉      glRotatef

移動         glTranslatef

縮放         glScalef

begin     end



想像老師講的佛跳牆的那個畫面


作業二
可旋轉的茶壺



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

作業三
Q1:什麼是BUFFER

A:緩衝記憶體

Q2什麼是DOUBLE BUFFER

A:兩倍的緩衝記憶體


Q3什麼是Depth
A:徒行深度Z

作業四
可以全方位旋轉的茶壺

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


沒有留言:

張貼留言