#include<GL/glut.h>
#include<GL/glu.h>
#include<GL/gl.h>
#include<math.h>

GLfloat x = -0.8f;
GLfloat y = 0.0f;
GLfloat rsize = 0.2;

GLfloat xstep = 0.0f;
GLfloat ystep = 0.0f;

void RenderScene(void)
	{
	glClear(GL_COLOR_BUFFER_BIT);

	glColor3f(1.0f, 1.0f, 1.0f);

	glRectf(x, y, x + rsize, y + rsize);
	
    	glutSwapBuffers();
	}


void SetupRC(void)
    {
    
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    }

void ChangeSize(int w, int h)
    {
	
	if(h == 0)
		h = 1;

	// Set Viewport to window dimensions
	glViewport(0, 0, w, h);

	// Reset projection matrix stack
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
        // Reset modelview matrix stack
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
    }

void IdleScene()
{
 xstep+=0.005f;
 x=0.5*sin(xstep);
 glutPostRedisplay();
}

int main(int argc, char* argv[])
	{
	glutInit(&argc, argv);

	glutInitWindowSize(600,600);
	glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE);
	
        glutCreateWindow("Animazione");
	glutDisplayFunc(RenderScene);
        glutReshapeFunc(ChangeSize);

	glutIdleFunc(IdleScene);

	SetupRC();

	glutMainLoop();
        
        return 0;
    }
