主題:旋轉Rotation
實作:glRotatef()
滑鼠轉,自動轉
滑鼠事件:把大象放入冰箱


開啟CodeBlocks GLUT
Download Freeglut3.0.0 MSVC Package
將檔案解壓縮後複製一個libfreeglut.a檔並重新命名為libglut32.a
開啟Code Blocks>新增一個新的專案>點選Glut project
執行

#include <GL/glut.h>
float angle=0;///今天教的!!!
void display()
{///沒有使用 glclear()去清畫面會有殘影....
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();///PUsh備份保護Matrix
glRotatef(angle, 0,1,0);///今天教的!!!!對Y軸,轉angle度
glutSolidTeapot(0.3);
glPopMatrix();///Pop還原Matrix
glutSwapBuffers();
angle+=3;///今天新教的!!!! 每次執行到這行
}
void motion(int x,int y)///現在要新加的!!!
{///當你的mouse去drag作motion動作時,
angle=x;///現在要新加的!!!
display();///現在要新加的!!!
}
int main(int argc, char**argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week05_06160326");
glutDisplayFunc(display);
glutIdleFunc(display);///今天新教的!!!! Idle閒閒沒事,就重畫
glutMotionFunc(motion);///現在要新加的!!!
glutMainLoop();///如果忘了寫glutMainLoop() 或是忘了寫圓括號() 就會離開
}
滑鼠事件:把大象放入冰箱
TODO:www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10
下載:windows.zip 下載\windows\Transformation.exedata.zip
下載\windows\data\模型glut32.dll
下載\windows\glut32.dll
先去網站下載data,win32,glut32.dll
然後解壓縮把data放進去windows裡面

然後開啟Transformation.exe

開啟CodeBlocks GLUT
Download Freeglut3.0.0 MSVC Package
將檔案解壓縮後複製一個libfreeglut.a檔並重新命名為libglut32.a
開啟Code Blocks>新增一個新的專案>點選Glut project
執行

然後做一個茶壺
做一個可以旋轉的茶壺
程式碼:
float angle=0;///今天教的!!!
void display()
{///沒有使用 glclear()去清畫面會有殘影....
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();///PUsh備份保護Matrix
glRotatef(angle, 0,1,0);///今天教的!!!!對Y軸,轉angle度
glutSolidTeapot(0.3);
glPopMatrix();///Pop還原Matrix
glutSwapBuffers();
angle+=3;///今天新教的!!!! 每次執行到這行
}
void motion(int x,int y)///現在要新加的!!!
{///當你的mouse去drag作motion動作時,
angle=x;///現在要新加的!!!
display();///現在要新加的!!!
}
int main(int argc, char**argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week05_06160326");
glutDisplayFunc(display);
glutIdleFunc(display);///今天新教的!!!! Idle閒閒沒事,就重畫
glutMotionFunc(motion);///現在要新加的!!!
glutMainLoop();///如果忘了寫glutMainLoop() 或是忘了寫圓括號() 就會離開
}
沒有留言:
張貼留言