用push和pop保護程式
下周程式碼
#include <GL/glut.h>
float x=0,y=0;
void display()
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glPushMatrix();///備份矩陣
glTranslatef((x-150)/150.0,-(y-150)/150.0,0);///f浮點數
glutSolidTeapot(0.3);
glPopMatrix();///還原矩陣
glutSwapBuffers();
}
void motion(int nowx,int nowy)
{
x=nowx; y=nowy;
display();
}
int main(int argc, char ** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("06160823");
glutDisplayFunc(display);
glutMainLoop();
}
沒有留言:
張貼留言