26.5 OpenGL in the Pop Framework

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


    This calls

    ::wglMakeCurrent( _pDC->GetSafeHdc(), _hRC ) 
  • Clear the graphics background with


    This calls

  • Install the projection and view matrices with these lines.


    These in turn call:

    ::gluPerspective (fieldofviewangleindegrees, xtoyaspectratio, 
        nearzclip, farzclip); //Values from _pviewpointcritter 
  • Draw your game world and then the critters with

    pgame()->drawCritters(_pgraphics, _drawflags). 

    This generates a variety of ::gl and ::glu calls like, in the case of polygons

  • Send the graphics to your video display with

    _pgraphics->display(this, pDC) 

    This calls

    ::glFinish();// Tell OpenGL to flush its pipeline 
    ::SwapBuffers( _pDC->GetSafeHdc() ); // Now Swap the buffers 

    Part I: Software Engineering and Computer Games
    Part II: Software Engineering and Computer Games Reference