2016年3月22日 星期二

Week 05 柯君翰

1.課堂作業--旋轉 & 移動
教材 jsyeh.org/3dcg10
載win32 & data & glut32.dII
解壓縮

data & glut32.dII 放入 win32
(1)
移動 glTranslatef
旋轉 glRotatef
縮放 glScalef
glBegin();glEnd()

(2)
縮放 glScalef
移動 glTranslatef
旋轉 glRotatef
glBegin();glEnd()


2.課堂作業--做swap交換
#進行旋轉(左右)
開啟GLUT檔
程式碼--
#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("hellow3D");

    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("hellow3D");

    glutDisplayFunc(display);
    glutMotionFunc(motion);

    glutMainLoop();
}






沒有留言:

張貼留言