#include <GL/gl.h>
#include <GL/glut.h>
#include <stdio.h>
void redraw(void);
void keyboardPress(unsigned char, int, int);
int main( int argc, char** argv )
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowPosition(100, 100);
glutInitWindowSize(100, 100);
glutCreateWindow("Window 1");
glutInitWindowPosition(250, 100);
glutInitWindowSize(100, 100);
glutCreateWindow("Window 2");
glutDisplayFunc(redraw);
glutKeyboardFunc(keyboardPress);
glutMainLoop();
return 0;
}
void redraw(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
{
glVertex2f(-0.5, -0.5);
glVertex2f(0.5, -0.5);
glVertex2f(0.5, 0.5);
glVertex2f(-0.5, 0.5);
}
glEnd();
glFlush();
}
void keyboardPress(unsigned char key, int x, int y)
{
switch(key)
{
case '1':
glutSetWindow(1);
glutPostRedisplay();
break;
case '2':
glutSetWindow(2);
glutPostRedisplay();
break;
}
}