
The arguments for glOrtho are as follows:
void glOrtho(double left, double right, double bottom, double top, double near, double far);
Now, lets continue with the application:
glutDisplayFunc(display);
glutMainLoop();
The first function sets the function that GLUT will use whenever it needs to update the view. We then call glutMainLoop() which actually runs the program. From this point on our work is done; GLUT will handle the details of managing the window and calling our painting function to display it.
Here is the display function again:
void display(void) {
glClear(GL_COLOR_BUFFER_BIT);
glRectf(-5.0, 5.0, 5.0, –5.0);
glutSwapBuffers();
}
The first thing we do is call glClear with GL_COLOR_BUFFER_BIT parameter. This will clear the window with the color we specified earlier using glClearColor. Next, we actually draw our rectangle, using the glRectf function.
Now's the time I should bring up something about OpenGL function calls – they often come in different forms. For example, take glColor, which sets the current foreground color. This function has several prototypes, for example:
glColor3f(float, float, float);
glColor4f(float, float, float, float);
glColor3d(double, double, double);
glColor3i(int, int, int);
etc, etc, etc.
As you can see, OpenGL functions are usually formatted like this:
gl Color 3 f
