26.3 Generic OpenGL code
Let's look at an example of the kinds of calls that we feed into the OpenGL state-machine hopper so as to prepare to draw something. Specifically, let's see what it would take to draw a white square.
//Initialize the Window (Described in next subsection)
::glClearColor(0.0, 0.0, 0.0, 0.0);
::glClear(GL_COLOR_BUFFER_BIT);
::glColor3f(1.0, 1.0, 1.0);
::glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
::glBegin(GL_POLYGON)
::glVertex(0.25, 0.25, 0.0);
::glVertex(0.75, 0.25, 0.0);
::glVertex(0.75, 0.75, 0.0);
::glVertex(0.25, 0.75, 0.0);
::glEnd();
::glFinish();
//Update the Window (Described in next subsection)
You can view a lot more code like this in the Pop Framework's graphicsopengl.cpp file.
|