http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/?fbclid=IwAR121cMd8uzG5XpT8VUXKbIahCy-q_ccKHyViIsj0NxkTvl_oBSAov8FeXw
下載 data win32 glut.32dull
解壓縮windows
window移至桌面
__________________________________________________________________________
用滑鼠轉動的模型
開啟GLUT file
加入 glutMotionFunc(motion);///TODO:加了mouse motion函式可捉mouse的動態
void motion(int x,int y)///TODO:mouse motion現在動到哪裡了?!
{
myAngle=x;///TODO:我的角度就是x的值
}
float myAngle=0;///TODO:我們的變數宣告
改const double a = myAngle;///TODO:把角度塞進去 ///t*90.0
_________________________________________________________________________________
float myAngle=0;///TODO:我們的變數宣告
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);///清畫面
glPushMatrix();
glRotatef(myAngle,0,0,1);///TODO:對z軸,做旋轉
glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
myAngle=x;///TODO:我的角度,等下拿來用
display();///TODO:每次做動作,就重劃畫面
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week04 rotate");
glutMotionFunc(motion); ///TODO:加montion函式
glutDisplayFunc(display);
glutMainLoop();
}
_________________________________________________________________________________
跟著滑鼠位置移動的茶壺
#include <GL/glut.h>float myAngle=0;///TODO:我們的變數宣告
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);///清畫面
glPushMatrix();
glRotatef(myAngle,0,0,1);///TODO:對z軸,做旋轉
glutSolidTeapot( 0.3 );
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
myAngle=x;///TODO:我的角度,等下拿來用
display();///TODO:每次做動作,就重劃畫面
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("week04 rotate");
glutMotionFunc(motion); ///TODO:加montion函式
glutDisplayFunc(display);
glutMainLoop();
}








沒有留言:
張貼留言