TRT旋轉
#include <GL/glut.h>
float angle=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslated(0,0.5,0);
        glutSolidTeapot(0.3);
    glPopMatrix();
    glPushMatrix();
        glTranslatef(0.50,0.625,0);///三角形位置
        glRotatef(angle,0,0,1);
        glTranslatef(0.6,0,0);///旋轉中心
        glRotatef(-90,0,1,0);
        glutSolidCone(0.2,0.6,30,30);///三角形
    glPopMatrix();
    glutSwapBuffers();
}
void motion(int x,int y)
{
    angle = x;
    display();
}
int main(int argc, char**argv)
{
    glutInit(&argc,argv);
    glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
    glutCreateWindow("week10");
    glutDisplayFunc(display);
    glutMotionFunc(motion);///滑鼠動作
    glutMainLoop();
}

 
沒有留言:
張貼留言