사각형을 좌우로 움직여야 되는데
왼쪽으로 안움직여요 ㅜㅜ흑흑
어떻게 하면 좌우로 움직이게 할 수 있을까요
고수님들 제발 도와주세요 ㅜㅜ
#include <glut.h>
#include <gl.h>
#include <glu.h>
GLfloat Delta = 0.0;
void MyDisplay()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3f(0.0, 0.5, 0.9);
glVertex3f(-1.0 + Delta, -0.5, 0.0);
glVertex3f(0.0 + Delta, -0.5, 0.0);
glVertex3f(0.0 + Delta, 0.5, 0.0);
glVertex3f(-1.0 + Delta, 0.5, 0.0);
glEnd();
glutSwapBuffers();
}
void MyTimer(int Value)
{
Delta = Delta + 0.01;
if (Delta >= 1)
Delta = Delta - 0.1;
else if (Delta <= -1)
Delta = Delta + 0.1;
glutPostRedisplay();
glutTimerFunc(40, MyTimer, 1);
}
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE);//Doubel->SwapBuffers
glutInitWindowSize(300,300);
glutInitWindowPosition(0,0);
glutCreateWindow(\"OpenGL Drawing Example\");
glClearColor (1.0, 1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glutDisplayFunc(MyDisplay);
glutTimerFunc(40, MyTimer, 1);
glutMainLoop();
return 0;
}
댓글 0