下載data.zip, windows.zip, glut32.dll 這3個檔案
解壓縮data.zip, windows.zip後把程式都放在同一個資料夾
點開Transformation的程式來理解,旋轉
在codeblocks中寫出旋轉的程式
#include <GL/glut.h>
float myAngle=0,oldX=0;
void motion(int x,int y)
{
myAngle += (x-oldX);
oldX = x;
glutPostRedisplay();
}
void mouse(int button,int state,int x, int y)
{
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();
}




沒有留言:
張貼留言