2016年3月21日 星期一

Week05課堂作業

Week05課堂作業

作業1.到jsyeh/3dcg10/下載[data],[win32],glut32.dll,解壓縮
然後開transformation

glScalef 可以調整汽車大小
(縮小)

(放大)

glTraslatef 可以移動汽車

glRotatef 可以旋轉汽車

glTraslatef + glRotatef  可以在旁邊旋轉


作業2.開啟CodeBlocks
解壓縮freeglut
開啟project
左右旋轉物品

上下左右旋轉物品

放大移動視窗

#include <GL/glut.h>
float rotX=0, rotY=0;
void display()
{
    glClearColor(1,1,1,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glPopMatrix();
        glRotatef(rotX,0,1,0);///X的移動量,對準Y軸旋轉
        glRotatef(rotY,1,0,0);///Y的移動量,對準X軸旋轉
        glColor3f(1,0,0);
        glutSolidTeapot(0.3);
    glPopMatrix();///還原Matrix回到剛剛push時的樣子
    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);///double buffers兩倍記憶體
    glutInitWindowSize(600,600);///調整視窗大小
    glutInitWindowPosition(500,0);///移動視窗位置
    glutCreateWindow("hello3D");

    glutDisplayFunc(display);
    glutMotionFunc(motion);

    glutMainLoop();

}








沒有留言:

張貼留言