2019年3月8日 星期五

其實是我翹課Week03


glTranslatef(0.3,0.3,0); (改變茶杯位置)
glPushMatrix();+glPopMatrix(); (讓茶杯不亂跑)

#include <GL/glut.h>
#include <stdio.h>
float x=0, y=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
    glTranslatef((x-150)/150.0,-(y-150)/150.0,0);
    glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
}
void motion(int nowx,int nowy){
    x=nowx;
    y=nowy;
    display();
}
int main(int argc,char ** argv){
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
    glutCreateWindow("xdd");
    glutMotionFunc(motion);
    glutMainLoop();
}

沒有留言:

張貼留言