// A sample code using OpenGL and GLUT to render a black square on a white window #include #include using namespace std; #define WINDOW 400 void myInit() { glClearColor(1.0,1.0,1.0,0.0); glColor3f(0.0,0.0,0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0,400,0,400); glMatrixMode(GL_MODELVIEW); } void display() { glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); glVertex2f(100,100); glVertex2f(300,100); glVertex2f(300,300); glVertex2f(100,300); glEnd(); glFlush(); } int main (int argc , char **argv) { glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(WINDOW,WINDOW); glutInitWindowPosition(100.0,100.0); glutCreateWindow("Hello World"); glutDisplayFunc(display); myInit(); glutMainLoop(); return 0; }