1.www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10裡面先下載data,win32,glut32.dll
2.將windows解壓縮
3.將data解壓縮至windows的資料夾,並將glut32.dll移進去
4.按滑鼠右鍵點選swap translate/rotate
5.https://www.transmissionzero.co.uk/software/freeglut-devel/
6.freeglut解壓縮到桌面,點進lib資料夾將libfreeglut.a複製並改名為libglut32.a
7.新增一個project選擇glut project
8.複製程式碼並執行
#include <GL/glut.h>
void display()
{
glutSolidTeapot(0.3);
glutSwapBuffers();
}
int main(int argc, char ** argv)
{
glutInit( &argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week10 TRT");
glutDisplayFunc(display);
glutMainLoop();
}
9.新增一個圓錐體,做茶壺的延伸
程式碼:
#include <GL/glut.h>
float angle=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glTranslatef(0,0.5,0);
glutSolidTeapot(0.3);
glPopMatrix();
glPushMatrix();
glTranslatef(0.51,0.63,0);
glRotatef(angle,0,0,1);
glTranslatef(0.6,0,0);
glRotatef(-90,0,1,0);
glutWireCone(0.1,0.6,10,10);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
angle=x;
display();
}
int main(int argc, char ** argv)
{
glutInit( &argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("Week10 TRT");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMainLoop();
}
沒有留言:
張貼留言