2015年6月10日 星期三

Week16 課堂作業, 許志遙

複習-基本TRT

#include <GL/glut.h>

float angle1=0;
void display(){
    glEnable(GL_DEPTH_TEST);
    glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);

    glPushMatrix();///Part 0,
        glColor3f(0, 0, 1);
        glutSolidTeapot(0.3);///body base 先做基本的身體, 再藏起來

        glPushMatrix();
            glTranslatef(0.5, 0.15, 0);
            glRotatef(angle1, 0,0,1);
            glTranslatef(0.3, 0, 0);

            glScalef(1, 0.3, 0.3);
            glColor3f(1, 0, 0);
            glutSolidSphere(0.3, 30, 30);
            glPopMatrix();
        glPopMatrix();

    glFlush();
}

void motion(int x, int y){
    angle1=x;
    glutPostRedisplay();
}

int main(int argc, char**argv){
    glutInit(&argc, argv);
    glutCreateWindow("Robot");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();
}




沒有留言:

張貼留言