(一)下載win32/data/glut32.dll
http://www.cmlab.csie.ntu.edu.tw/~jsyeh/3dcg10/打開Transformation複習移動、旋轉、縮放
自轉(自己為中心旋轉)如上
公轉(繞中心點轉)如上
(二)下載freeglut 開啟codeblock
程式碼:
#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();
}
------------------------------------------------------------
程式碼:
#include <GL/glut.h> float angle=0; void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); glTranslatef(0,0.5,0); glutWireTeapot(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(); }
沒有留言:
張貼留言