之前的10行程式碼
glClearColor(1.0,0.1,0.9,1.0);///清背景的紫色
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);///清背景
glRotatef(angle,0,0,1);
讓他可以旋轉
float s = 1;///旋轉角度
glScalef(s,s,s);///縮放
void keyboard(unsigned char key, int x, int y){
printf("key: %c x: %d y: %d\n",key,x,y);
}
顯示滑鼠的x,y座標
void mouse(int button, int state, int x,int y){
oldX=x;///當mouse按下,記錄他的位置
}
void motion(int x,int y){
angle +=(x-oldX);
oldX=x;
display();
}
去網站 https://jsyeh.org/3dcg10/
解壓縮兩個檔案
再把data放到win32
開啟Transformation
glRotatef(angle++///讓角度一直增加,0,0,1);
glutIdleFunc(display);///有空就重製畫面
可以不用點擊滑鼠就會自己轉動
glTranslatef(0.7,0,0);///放到右邊去
glRotatef(angle++,0,0,1);///轉動中的
這是自轉
這是公轉










沒有留言:
張貼留言