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.

     _pviewpointcritter->loadProjectionMatrix();  _pviewpointcritter->loadViewMatrix(); 

    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

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

    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

     _pgraphics->display(this, pDC) 

    This calls

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

Software Engineering and Computer Games
Software Engineering and Computer Games
Year: 2002
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net