Getting Started

From OpenGL Wiki
Revision as of 07:54, 9 January 2007 by V-man (talk | contribs)
Jump to navigation Jump to search

Installing OpenGL

So you want to take advantage of the OpenGL power ?

  • to use a game or software that uses OpenGL, you need to install the appropriate graphic driver
  • to program using the OpenGL API, you need the driver and the development package (depends on platform and programming langage)

More platform-dependent details are described below.

Windows

If you are running Windows 98/Me/NT/2000/XP/2003, the OpenGL library has already been installed on your system. Win95A did not come with GL, so Microsoft has made this available Windows OpenGL library Remember that GL is a system component on Windows. DO NOT modify or copy opengl32.dll from one OS to another. The filename is opengl32.dll and is either in WINDOWS\SYSTEM, WINNT\SYSTEM32 or WINDOWS\SYSTEM32

This library alone will not give you hardware acceleration for OpenGL, though, so you will need to install the latest drivers for your graphics card:

Some sites also distribute beta versions of graphics drivers, which may give you access to bug fixes or new functionality before an official driver release from the manufacturer:

GLU is also included in the system folder as glu32.dll This is also a system component. Updated dll should be placed in your program's folder. You can get a GLU's source code from MESA3D You can get precompiled lib from vmelkon's GLU The current version is 1.3

Other libraries like GLUT, freeGLUT, QT, etc are not part of the OS. These should be downloaded from the net. GLUT and OpenGL Utility Libraries

Windows 95, 98, Me, 2000 support GL 1.1 as a software rasterizer implemented in opengl32.dll There is no support for hw acceleration therefore installing drivers is necessary. Windows XP supports GL 1.1 as a D3D wrapper in opengl32.dll Since performance will be lousy, installing drivers is a good idea. On Windows 2003, you aren't suppose to use it as a desktop machine, but it is similar to Win 2000 Windows Vista will support GL 1.4 as a D3D wrapper. Always install drivers.

Linux

Graphics on Linux is almost exclusively implemented using the X windows system. Supporting OpenGL on Linux involves using GLX extensions to the X Server. There is a standard Application Binary Interface defined for OpenGL on Linux that gives application compatability for OpenGL for a range of drivers. In addition the Direct Rendering Infrastucture (DRI) is a driver framework that allows drivers to be written and interoperate within a standard framework to easily support hardware acceleration, the DRI is included in of XFree86 4.0 but may need a card specific driver to be configured after installation. These days, XFree86 has been rejected in favor of XOrg due to the change in the license of XFree86, so many developers left Xfree86 and joined the XOrg group. Popular Linux distros come with XOrg now. Developers

Vendors have different approaches to drivers on Linux, some support Open Source efforts using the DRI, and others support closed source frameworks but all methods support the standard ABI that will allow correctly written OpenGL applications to run on Linux.

For more information on developing OpenGL applications on Linux, see Platform specifics: Linux

Linux comes with Mesa libraries, which implements GL as a software rasterizer. Most Linux distros don't come with hw acceleration. Some distros may include hw acceleration. Also, some GPUs have Open Source drivers developed by the community even though a close source driver may be available from the manufacturer.

Mac OS X

Every version of Mac OS X has shipped with OpenGL runtime libraries pre-installed. Users who want to run OpenGL applications do not need to install or configure anything.

Unlike other platforms, where the OS and OpenGL implementations are often updated separately, OpenGL updates are usually included as part of Mac OS X system updates. To obtain the latest OpenGL on Mac OS X, users should upgrade to the latest OS release [1].

For developers, a default installation of Mac OS X does not include any OpenGL headers, nor does it include other necessary development tools. These are installed by a separate developer tools package [2]. This installer includes the OpenGL headers, compilers (gcc), debuggers (gdb), Apple's Xcode IDE, and a number of performance tools useful for OpenGL application development.

For more information on developing OpenGL applications on Mac OS X, see Platform specifics: Mac OS X.

OpenGL 2.0 and extensions

If you will be programming for Windows, typically compilers comes with a standard GL 1.1 .h and .lib
For Linux and others, you might want to borrow the same idea (getting function pointers for the GL functions)
To access higher GL functions, you would have to get the function pointers.
For example, in C or C++, this is what you would do

Download glext.h and wglext.h from The Extensions Registry

Put it in your compiler's GL folder

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

extern PFNGLACTIVETEXTUREPROC glActiveTexture; //Put this in a .h so that you can include the header in all your other .cpp
PFNGLACTIVETEXTUREPROC glActiveTexture; //Declare your function pointer in a .cpp file

Once you create a GL context, you can use wglGetProcAddress to get a pointer to the function.

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


This would be tedious if you had to do this for all the functions and it's is even more work if you want to detect a certain GL version, then load all the core functions. Then, detect if a certain extension is present, then load all the functions.

There exists a few libraries out there that will get the function pointers for you. All you have to do is create a GL context and call the library's init function. The recent version of GLee doesn't require a call to its init function.
Examples are :