Look back at the code for CPopView::OnDraw(CDC* pDC) that we gave in Section 24.4: Graphics in the Pop Framework. Here is a bulleted list showing some of the corresponding OpenGL calls made by the _pgraphics member of CPopView if _pgraphics is of the type cGraphicsOpenGL*.
Wake up the graphics with
::wglMakeCurrent( _pDC->GetSafeHdc(), _hRC )
Clear the graphics background with
::glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
Install the projection and view matrices with these lines.
These in turn call:
::glMatrixMode(GL_MODELVIEW) ::glLoadMatrixf(_pviewpointcritter->attitude().inverse()); ::glMatrixMode(GL_PROJECTION) ::gluPerspective (fieldofviewangleindegrees, xtoyaspectratio, nearzclip, farzclip); //Values from _pviewpointcritter
Draw your game world and then the critters with
This generates a variety of ::gl and ::glu calls like, in the case of polygons
::glEnableClientState(GL_VERTEX_ARRAY); ::glVertexPointer(...); ::glDrawArrays(...);
Send the graphics to your video display with
::glFinish();// Tell OpenGL to flush its pipeline ::SwapBuffers( _pDC->GetSafeHdc() ); // Now Swap the buffers