
#include<GL/glut.h>
#include<math.h>
static float Xvalue = 0.0, Yvalue = 0.0; 
static float Angle = 0.0; 
void display(void)
{
   glClear(GL_COLOR_BUFFER_BIT);

   glLoadIdentity();
//glColor3f(0.0,0.0,0.0);
glTranslatef(Xvalue, Yvalue, -15.0);

 glRotatef(Angle, 0.0, 1.0, 0.0);

 glColor3f(0.0, 1.0, 0.0);

glutWireCube(5.0);

   glutSwapBuffers();
}
void init(void) 
{
   glClearColor(1.0, 1.0, 1.0, 0.0);
}
void keyInput(unsigned char key, int x, int y)
{
   switch (key) 
   {
      case 'r':
         Xvalue = Yvalue = Angle = 0.0;
         glutPostRedisplay();
         break;
      case ' ':
         Angle += 10.0;
         glutPostRedisplay();
         break;
      case 27:
         exit(0);
         break;
	  default:
	     break;
   }
}
void specialKeyInput(int key, int x, int y)
{
   if(key == GLUT_KEY_UP) Yvalue += 0.1;
   if(key == GLUT_KEY_DOWN) Yvalue -= 0.1;
   if(key == GLUT_KEY_LEFT) Xvalue -= 0.1;
   if(key == GLUT_KEY_RIGHT) Xvalue += 0.1;
   glutPostRedisplay();
   
   
   }
   void resize(int w, int h)
{
   glViewport(0, 0, w, h); 
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glFrustum(-5.0, 5.0, -5.0, 5.0, 5.0, 100.0);

   glMatrixMode(GL_MODELVIEW);
}
int main(int argc, char **argv) 
{
   glutInit(&argc, argv);

  

   glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); 
   glutInitWindowSize(500, 500);
   glutInitWindowPosition(100, 100); 
   glutCreateWindow("boxWithLookAt.cpp");
   glutDisplayFunc(display); 
   glutReshapeFunc(resize);  
   glutKeyboardFunc(keyInput);

   glutSpecialFunc(specialKeyInput);
   
  init(); 

   glutMainLoop(); 
}

