transforms 地形演示,可調整軸向及旋轉角度⏫
讓程式圖形隨著滑鼠移動⏫
讓程式圖形隨著滑鼠移動⏫
float my =0; //宣告角度變數
void display(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //要記的的清除畫面
glPushMatrix();
glRotatef(my,0,0,1); //對x,y,z軸做旋轉
glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
}
void mo(int x,int y){
my=x; //我的角度,等等拿來用
display(); //每次動作就清除一次畫面
}
int main(int argc,char**argv){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week 04 rotate");
glutMotionFunc(mo); //加入motion函式
glutDisplayFunc(display);
glutMainLoop();
}





沒有留言:
張貼留言