OpenGL Programming/Installation/Linux< OpenGL Programming
OpenGL Installation on LinuxEdit
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. Use your favorite package manager and search for the package name. You may need to install packages that come with a dev suffix, these are development packages (usually header files). Also look for packages with a lib prefix, which refer to libraries.
Install the GCC C/C++ compilers and associated tools such as make.
All in all, install Mesa, Make and GCC/g++:
sudo apt-get install build-essential libgl1-mesa-dev # Debian, Ubuntu sudo dnf install make gcc-c++ # Fedora
In this wikibooks, we'll make great use of GLEW, SDL2 (+SDL2_Image), GLM and FreeType. Make sure you install the development libraries:
sudo apt-get install libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev # Debian, Ubuntu sudo dnf install glew-devel SDL2-devel SDL2_image-devel glm-devel freetype-devel # Fedora sudo pacman -S glew sdl2 sdl2_image glm freetype2 # Arch
If GLM is not available in your distribution repository, you have the option to install it manually. Make sure the headers end in the
/usr/include/glm directory. Since it's a headers-only library, you do not need to compile a .so library - just copy the code there.
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.
OpenGL is included in drivers, so you'll have to make sure drivers are properly installed if you want to enjoy programs using OpenGL. Open source drivers actually make use of Mesa's OpenGL implementation. Proprietary drivers embed their own OpenGL library.
Nvidia provides generally excellent but non-free drivers via the nvidia driver from their website. fglrx drives many modern AMD devices; it is also closed-source, and available from AMD'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.
If you have one of the newest chips, you may be forced to use the mediocre fglrx driver. However since AMD released the specifications for their chips, the open source 'radeon' made its way to become a full-featured 2D and 3D driver.
As of June 2013, most AMD chips will run well with the open source 'radeon' driver. 3D performance is still better with the AMD Catalyst driver on modern cards, but this may change in the future. Check the feature matrix 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, 3D support may not be satisfactory.
The OpenGL driver on Linux systems consists of two files:
- libGL.so for the GL itself; libGL.so must be 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 installationEdit
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 (can interface with Make)
It is very simple to adapt the Makefiles to these environments.