1.下載 data.zip, windows.zip, glut32.dll 三個
2.把解壓縮後的data及glut32.dull資料夾複製到 windows 資料夾內
3. 打開 Transformation
4.在 Screen-space view點右鍵 能切換模型
5.下面可分別調整大小位子旋轉等等..
上周程式碼
2.把解壓縮後的data及glut32.dull資料夾複製到 windows 資料夾內
3. 打開 Transformation
4.在 Screen-space view點右鍵 能切換模型
5.下面可分別調整大小位子旋轉等等..
上周程式碼
#include <stdio.h>
#include <GL/glut.h>
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)
{
}
void motion(int x,int y)
{
teapotX=(x-150)/150.0;
teapotY=(150-y)/150.0;///依照motion時的x,y來改teapot的座標
glutPostRedisplay();///讀3M Post便利貼,貼出來說,有空時記得要Redisplay()
}
int main (int argc,char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week03 Mouse");
glutDisplayFunc(display);
glutMouseFunc(mouse);
glutMotionFunc(motion);///mouse()滑鼠motion事件
glutMainLoop();
}
沒有留言:
張貼留言