2019年4月25日 星期四

郁峰的筆記

                                                glut


#include<GL/glut.h>
float angle=0;
void display(){
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
        glTranslatef(0,0.5,0);///往上移動
        glutSolidTeapot(0.3);///this is a teapot
    glPopMatrix();
    glPushMatrix();
        ///glutSolidSphere(0.3,30,30);
    glPopMatrix();
    glPushMatrix();
        glTranslatef(0.5,0.625,0);///(3) 把它掛在你要放的地方
        glRotatef(angle,0,0,1);///(1) 先有個轉動,但怪怪的(因為不在正確的地方)
        glTranslatef(0.6,0,0);///(2) 要更早去移動旋轉中心
        glRotatef(-90,0,1,0);///(0)轉動90度的CONE
        glutSolidCone(0.2,0.6,30,30);///直直的cone
    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("week10TRT");
    glutDisplayFunc(display);
    glutMotionFunc(motion);
    glutMainLoop();
}



沒有留言:

張貼留言