1.下載 data
2.下載 win32 並解壓縮(放到你想放的地方
3.下載 glut32.dll 並複製到與win32同一個地方
4.解data壓縮至與win32同一個地方
5.執行Transformation.exe
glTranslatef (.....)
glRotate(...)
左邊右邊自轉
glRotate(...)
glTranslatef (.....)
右邊車子繞畫面中心
自己做茶壺 旋轉(手動
#include <GL/glut.h>
float angle = 0 ; ///旋轉的角度
void motion (int x , int y) ///mouse motion 拖著移動時 , 會叫motion()
{
angle = x ; ///老師用上周比較差的方法 , 直接把mouse座標,變轉動角度
glutPostRedisplay(); ///請畫面重畫
}
void display() ///畫面要display時呼叫這個涵式
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ///先清畫面
glPushMatrix();
glRotatef(angle , 0 , 0 , 1 ); ///rotate/translate/scale都會把矩陣改變
glTranslatef(0.45 , -0.08 , 0 );///移動,讓茶壺的柄,放到畫面的中心
glutSolidTeapot(0.3);
glPopMatrix(); ///還原矩陣(乾淨的矩陣)
glutSwapBuffers();
}
int main(int argc , char**argv)
{
glutInit(&argc , argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week05 TRT");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
兩個茶壺
#include <GL/glut.h>
float angle = 0 ; ///旋轉的角度
void motion (int x , int y) ///mouse motion 拖著移動時 , 會叫motion()
{
angle = x ; ///老師用上周比較差的方法 , 直接把mouse座標,變轉動角度
glutPostRedisplay(); ///請畫面重畫
}
void display() ///畫面要display時呼叫這個涵式
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ///先清畫面
glPushMatrix();
glutSolidTeapot(0.3); ///放在中間
glTranslatef(0.5 , 0.15 , 0); ///把會旋轉的茶壺柄,放到右上角
glRotatef(angle , 0 , 0 , 1 ); ///rotate/translate/scale都會把矩陣改變
glTranslatef(0.45 , -0.08 , 0 );///移動,讓茶壺的柄,放到畫面的中心
glutSolidTeapot(0.3);
glPopMatrix(); ///還原矩陣(乾淨的矩陣)
glutSwapBuffers();
}
int main(int argc , char**argv)
{
glutInit(&argc , argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week05 TRT");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
#include <GL/glut.h>
float angle = 0 ; ///旋轉的角度
void motion (int x , int y) ///mouse motion 拖著移動時 , 會叫motion()
{
angle = x ; ///老師用上周比較差的方法 , 直接把mouse座標,變轉動角度
glutPostRedisplay(); ///請畫面重畫
}
void display() ///畫面要display時呼叫這個涵式
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ///先清畫面
glPushMatrix();
glutSolidTeapot(0.3); ///放在中間
glTranslatef(0.5 , 0.15 , 0); ///把會旋轉的茶壺柄,放到右上角
glRotatef(angle , 0 , 0 , 1 ); ///rotate/translate/scale都會把矩陣改變
glTranslatef(0.45 , -0.08 , 0 );///移動,讓茶壺的柄,放到畫面的中心
glutSolidTeapot(0.3);
glPopMatrix(); ///還原矩陣(乾淨的矩陣)
glutSwapBuffers();
}
int main(int argc , char**argv)
{
glutInit(&argc , argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week05 TRT");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}

沒有留言:
張貼留言