week04
旋轉Rotate
1、到https://jsyeh.org/3dcg10/
2、下載data.zip、window.zip
3、解壓縮 把data放到windows裡面
4、選AI Capone
5、嘗試旋轉角度
week04-2
1、下載moodle-freeglut mingw檔案,libfreeglut改libglut32.a
2、codeblocks開new project-GLUT project
3、打程式碼
#include<GL/glut.h>
float angle=0,oldX=0;
void display()
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(angle,0,0,1);
glutSolidTeapot(0.3);
glPopMatrix();
glutSwapBuffers();
}
void motion(int x,int y)
{
angle+=(x-oldX);
oldX=x;
display();
}
void mouse(int button,int state,int x,int y)
{
oldX=x;
}
int main(int argc,char**argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_DEPTH);
glutCreateWindow("Week04 Rotate");
glutDisplayFunc(display);
glutMotionFunc(motion);
glutMouseFunc(mouse);
glutMainLoop();
}
沒有留言:
張貼留言