1. 主題: Transformation
到圖學網站下載Data,windows,glut32.dll檔案,
並一同解壓丟入windows解壓檔
開啟Transformation-->對右上方的圖點右鍵-->選取AI Capone
3. 主題: 旋轉
1.開啟CodeBlocks載入freeglut檔


2.茶壺旋轉
#include <GL/glut.h>
float myAngle=0,oldx=0;
void motion(int x,int y)
{
myAngle+=(x-oldx);
oldx=x;
glutPostRedisplay();
}
void mouse(int srate,int button,int x,int y)--->mouse函式
{
oldx=x;
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(myAngle,0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week04");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
float myAngle=0,oldx=0;
void motion(int x,int y)
{
myAngle+=(x-oldx);
oldx=x;
glutPostRedisplay();
}
void mouse(int srate,int button,int x,int y)--->mouse函式
{
oldx=x;
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(myAngle,0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
int main(int argc, char ** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode( GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("week04");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}

沒有留言:
張貼留言