2016年3月21日 星期一

Liu Workingshop Week V

課堂作業2:
 #include <GL/glut.h>
float rotX=0;
void display()
{
    glClearColor(1,1,1,1);
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
        glRotated(rotX, 0,1,0); //這邊的是自可以改變旋轉的中心軸
        glColor3f(1,0,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
}
void motion(int x,int y)
{
    rotX=x;
    display();//glutPostRedisplay();

}
int main(int argc, char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("hello 3D");

    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();
        glRotated(rotX, 0,1,0);//X的移動量,讓他對Y軸轉
        glRotated(rotY, 1,0,0);//Y的移動量,讓他對X軸轉
        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(700,700);glutInitWindowPosition(600,0);//hello 3D的視窗設定
    glutCreateWindow("hello 3D");

    glutDisplayFunc(display);
    glutMotionFunc(motion);

    glutMainLoop();
}




沒有留言:

張貼留言