2015年5月27日 星期三

week14 02160200課堂作業

todo畫茶壺
todoTRT
程式碼
#include <GL/glut.h>
float angle=0;
void display()
{
    GLfloat pos []={0,0,-1,0};
    glLightfv(GL_LIGHT0,GL_POSITION,pos);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);

    glEnable(GL_DEPTH_TEST);

    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(0.6,0.2,0);
        glRotatef(angle,0,0,1);
        glTranslatef(0.3,0,0);///把柄當中心
        glutSolidTeapot(0.3);
    glPopMatrix();
     glutSolidTeapot(0.3);
    glFlush();
}
void timer(int t)
{
    glutTimerFunc(20,timer,t+1);
    angle++;
    glutPostRedisplay();
}
int main(int argc ,char **argv)
{
    glutInit(&argc,argv);
    glutCreateWindow("T-R-T test");
    glutDisplayFunc(display);
    glutTimerFunc(20,timer,0);

    glutMainLoop();
}


沒有留言:

張貼留言