2020年3月17日 星期二

<冠宏 我左邊好臭 柏仁>

float teapotX=0, teapotY=0;
void display()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
    glTranslatef(teapotX,teapotY,0);
    glutSolidTeapot(0.3);
    glPopMatrix();
    glutSwapBuffers();
}
void mouse(int button,int state,int x,int y)
{
    printf("%d %d\n",(x-150)/150.0,(y-150)/150.0);
    teapotX=(x-150)/150.0;
    teapotY=-(y-150)/150.0;
}
讓茶壺可以隨著滑鼠點擊移動
用座標做出圖片
這是我做不完的大嘴鳥

沒有留言:

張貼留言