// Using the keyboard is extrememly simple, all you need is a function for the keyboard
// in this case 'keyboard', it must have '(unsigned char key, int x, int y)' 
// with code somewhat like what I have. Instead of 'if' you could easily change
// that to 'switch' and then use 'case's. But anyway, all you have to edit after that
// is the 'main' function. Just add the line:
// glutKeyboardFunc (keyboard); 
// where 'keyboard' is the name of your keyboard function.

// also keep in mind that because we are using GLUT we can easily gather input
// from the arrow keys with GLUT_KEY_LEFT, UP, DOWN, RIGHT, along with the f1-12 keys.
// to do that, just replace the 27 in this case to GLUT_KEY_DOWN.

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

void display (void) {
	glClearColor (0.0,0.0,0.0,1.0);
	glClear (GL_COLOR_BUFFER_BIT);
	glLoadIdentity();  
	gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
	glFlush();
}

void keyboard (unsigned char key, int x, int y) {
	if (key==27) { //27 is the ascii code for the ESC key
		exit (0); //end the program
	}
}

int main (int argc, char **argv) {
	glutInit (&argc, argv);
	glutInitDisplayMode (GLUT_SINGLE);
	glutInitWindowSize (500, 500);
	glutInitWindowPosition (100, 100);
	glutCreateWindow ("A basic OpenGL Window");
	glutDisplayFunc (display);
	glutKeyboardFunc (keyboard);//the call for the keyboard function.
	glutMainLoop ();
    return 0;
}

