OpenGL Installation on Linux
Most Linux distributions rely on the Mesa3D project to provide their OpenGL implementation. This supplies libraries for regular OpenGL as well as OpenGL ES 1.x and 2.0.
The exact names of the packages you need to install are highly dependent on distribution. Referring to your distro's packages can save you a lot of time and headache in installation. For example, on Debian-based distros (with apt-get or equivalent tools), you can use the following commands:
- Install the header files of OpenGL libraries.
sudo apt-get update sudo apt-get install libgl1-mesa-dev
- Install the GCC C/C++ compilers and associated tools such as make:
sudo apt-get update sudo apt-get install build-essential
In this wikibooks, we'll make great use of GLEW, FreeGLUT and GLM, make sure you install the development libraries:
sudo apt-get install libglew1.5-dev freeglut3-dev libglm-dev
GLM is (as of 2011-10) recently packaged in the Debian only. If you use another distribution, we recommend you install it in the compiler path, that is in the
/usr/include/glm directory. Since it's a headers-only library, you do not need to compiler a .so library - just copy the code there.
The GLM library is available for Arch Linux in the AUR under the name glm.
OpenGL is the primary 3D graphics API on GNU/Linux-based systems. If your device supports 3D acceleration on GNU/Linux, it probably includes an OpenGL distribution.
nVidia provides generally excellent but non-free drivers via the nvidia driver from their website. Fglrx drives many modern ATI devices; it is also closed-source, and available from ATI's website.
If your CPU is an Intel one with built-in graphics, then the necessary open-source drivers come as a standard part of the Linux kernel.
Currently, some older ATI chips will run well with the open source radeon driver. If you have a newer chip, you may be forced to use the mediocre fglrx driver. AMD has recently released the specifications for their chips, so a new driver, radeon-hd, should become usable in the few months.
Check http://www.x.org/wiki/RadeonFeature for a completion status.
The open-source nouveau driver supports nVidia chipsets, but at the time of writing is not as complete as nVidia's closed-source drivers.
The OpenGL driver on Linux systems consists of two files:
- libGL.so for the GL itself; libGL.so must be in the accessible to the Linux library loader (refer to man pages for ldconfig)
- glx.so (this name may vary) for Xorg support for OpenGL; glx.so will be in Xorg's extensions path and must be loaded by xorg.conf (refer to man pages for xorg.conf)
Many OpenGL applications require libGLU.so as well; GLU operations are not hardware-accelerated, so the implementation provided by Mesa is an excellent option.
Check your OpenGL installation
Type this in a terminal to get much info about your OpenGL driver, including supported extensions:
glxinfo | grep OpenGL
The tutorials will mostly rely on simple
Makefiles to build the code, and let you edit the source with your favorite text editor, such as Emacs, vim, gedit, kwrite, etc.
Several IDEs exist for GNU/Linux, such as:
- Eclipse CDT
It is very simple to adapt the Makefiles to these environments.
Installing your own OpenGL headers
In the unlikely event that your distribution does not supply packages for Mesa3D, you can build it from source with the usual
./configure make make install
installation procedure; however, BE CAREFUL OF CONFLICTING OPENGL LIBRARIES.
Mesa's software implementation may override your distribution's libraries or libraries manually installed, such as the nVidia or fglrx OpenGL binaries. When this happens, search (slocate or find) all directories listed in /etc/ld.so.conf for libGL.so. Multiple copies of libGL.so under the LD_LIBRARY_PATH, if not referring to the same file, usually indicates a conflict. Remove all but the copy you want executed.
The headers will be installed to [install_root]/include/GL - on Debian systems, this is /usr/local/include/GL when compiled from source or /usr/include/GL when installed from a pre-built package.
"Official" OpenGL headers are available from SGI, however, they are hopelessly out of date.
< OpenGL Programming/Installation