26.1 Linking to OpenGL


To use OpenGL, you link your executable to the special OpenGL libraries and include some special OpenGL headers. Typically you do the 'linking' by adding 536these additional libraries to your project: opengl32.lib and glu32.lib . (You can see Appendix C for how to add libraries to a Visual Studio project.) And you do the 'including' by putting lines like the following into any files that mention the OpenGL functions. (In particular, the Pop framework has these lines in its graphicsopengl.h header.)

 #include "gl\gl.h"  #include "gl\glu.h" 

Once your code is linked up, you can make OpenGL function calls in your code. The OpenGL functions begin with one of the prefixes gl or glu . We usually put the scope resolution operator ' :: ' in front of these functions names as a reminder that these are global functions, rather than being members of any class. In addition, Windows has some special functions designed for linking to OpenGL. Some, but not all, of these functions start with the prefix wgl .

The functions our code uses are found in the following libraries:

  • gl functions from OpenGL ( gl.h, opengl32.lib )

  • glu functions from OpenGL Utilities ( glu.h glu.lib )

  • wgl functions from OpenGL Extension for Windows ( windows.h, opengl32.lib )

And of course our code will, as usual, use special functions defined in the MFC libraries and in the basic Win32 libraries. Figure 26.1 shows how Pop and the various libraries depend upon each other.

Figure 26.1. Component diagram for Pop's use of OpenGL libraries

graphics/26fig01.gif



Software Engineering and Computer Games
Software Engineering and Computer Games
ISBN: B00406LVDU
EAN: N/A
Year: 2002
Pages: 272

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