OpenGL Programming/Installation/Linux
Contents |
[edit] OpenGL Installation on Linux
Installations of all kinds on Linux 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 installed), 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 apt-get install build-essential
[edit] Libraries
In this wikibooks, we'll make great use of GLEW, FreeGLUT and GLM, make sure you install the development libraries:
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 glmath.
[edit] Drivers
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.
[edit] Proprietary options
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.
[edit] Free/Open-Source options
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.
[edit] Check your OpenGL installation
Type this in a terminal to get much info about your OpenGL driver, including supported extensions:
glxinfo | grep OpenGL
[edit] IDEs
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:
- Code::Blocks
- Anjuta
- KDevelop
- Eclipse CDT
It is very simple to adapt the Makefiles to these environments.
[edit] Installing your own OpenGL headers
Headers compatible with OpenGL are available from the Mesa3D project. In the unlikely event that your distribution does not contain development files for the Mesa3D project, Mesa3D comes equipped 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