2016年3月21日 星期一

[表特]資傳炎亞倫

課堂作業1





Translatef
 調整之後 以車子為中心軸旋轉
Rotate
調整了一下 發現只有背景(黑色的那塊)在轉動

課堂作業 1-2


老師上課講解 把車子變形>移動到鍋子右邊>開始旋轉
就像喜酒盤一樣 把菜放在旋轉盤子邊邊 然後旋轉 旋轉盤

課堂作業1-3


SWAP之後  先rotate再Translate  變成車子以自己中心旋轉


課堂作業2
Q1:什麼是 glPushMatrix(); 備份Matrix (Matrix裡有translate , rotate , scale )
什麼是glPopMartix();  還原Matrix (回到剛剛push時的樣子)
Q2:什麼是Buffers? Double? 
BUFFERS做一次測試用
 DOUBLE做兩次圖片更完整

課堂 2-1

#include <GL/glut.h>
float rotX=0;
void display()
{
    glClearColor(1,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("hello");

    glutDisplayFunc(display);
    glutMotionFunc(motion);

    glutMainLoop();


}

課堂作業3

#include <GL/glut.h>
float rotX=0,rotY=0;
void display()
{
    glClearColor(1,1,1,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glRotatef(rotY, 1,0,0); //依照Y軸和X軸旋轉
        glRotatef(rotX, 0,1,0);//
        glColor3f(1,0,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(300,300); glutInitWindowPosition(600,0); //改變視窗的位置與大小
    glutCreateWindow("hello");

    glutDisplayFunc(display);
    glutMotionFunc(motion);

    glutMainLoop();
}






沒有留言:

張貼留言