Getting Started

Revision as of 12:01, 10 May 2011 by EddyLuten (Talk | contribs) (Moved around link to the appropriate section.)

Jump to: navigation, search












64 bits Windows versions









Mac OS X





Accessing OpenGL functions

The OpenGL ABI (application binary interface) is frozen to version GL 1.1 on Windows, and GL 1.2 on Linux. This means that you can not link directly to any function provided by newer versions of GL.

So how do you use newer features? The answer is to get function pointers for those features at runtime (the same method for getting function pointers for extensions).

Note: The following shows how to do this process manually. There are a number of automatic extension loading libraries, and you are encouraged to use them.

If you will be programming for Windows, typically compilers comes with a standard OpenGL 1.1 header (gl.h) and the library file (opengl32.lib). To gain access to more recent versions or extension functions, you will need to use glext.h and either wglext.h (for windows) or glxext.h (for linux). These define function pointers for all extensions and versions of OpenGL 1.2 and above.

Download glext.h and wglext.h/glxext.h from The Extensions Registry. You can put these files directly under the compiler's "GL" folder, or you can put them in some other folder that will be in your project's include path. As long as you can find them. The example code will assume that they are in the "GL" folder.

include <GL/gl.h>
include <GL/glext.h>
include <GL/wglext.h>

PFNGLACTIVETEXTUREPROC glActiveTexture;    //Declare a OpenGL function pointer in a .cpp file

PFNGLACTIVETEXTUREPROC is a typedef defined in glext.h that represents a function pointer to this particular OpenGL function. Every OpenGL core function (in a version 1.2 or greater) and every OpenGL extension function has a typedef. They all begin with PFN, followed by the function name in ALL CAPS, followed by PROC.

If you wish to expose this function pointer to other .cpp files, you will need to put the following in a header file that those .cpp files include:

//Some header file.
include <GL/gl.h>
include <GL/glext.h>
include <GL/wglext.h>


After creating an OpenGL context, and only after creating an OpenGL context, you may use wglGetProcAddress (or glXGetProcAddress for *nix systems) to get the function pointer.

glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTexture");

This must be done for each function you intend to use that is not a core OpenGL 1.1 function and there are plenty of functions. You will have hundreds of lines of code just calling wglGetProcAddress. Or you can use an extension loading library and not have to worry about it.

We should also state that you should always check the GL version supported to make sure the system supports your program. For more info

OpenGL 3.0 and Above


The OpenGL specification now is broken into two specifications: core and compatibility. Compatibility provides full backwards compatibility with GL 2.1 and below, while Core does not. A new context creation model exists; it is the only way to create core contexts of OpenGL 3.1 and above.


More detailed instructions for Creating an OpenGL Context are available.

OpenGL specifications

How to make your first OpenGL Program







OpenGL Viewers


Tutorials and How To Guides

User contributed tutorials and getting started guides

Deferred Shading Tutorials

Development Tools


See Also

External Links