OpenGL Programming/APIs, Libraries and acronyms
Landscape[edit | edit source]
There are a lot of technologies and acronyms around OpenGL. Here's how they are organized, and where to make choices.
(The technologies presented here may rely on any lower-lever ones, not just the one right to the left.)
|Graphic card||OpenGL||WGL (for Windows)||EGL||GLEW||GLUT||SFML Graphics, ClanLib... (2D)|
|OpenGL ES||GLX (for X11)||EAGL (iOS)||Glee||GLFW||Irrlicht, OGRE, Unity, (3D)|
|WebGL||CGL/AGL (for OS X)||SDL, SFML||OpenSG, OpenScenegraph...|
|Your main choice here :)|
- On top of it, you have a system-dependent OpenGL implementation (WGL, GLX, etc.). It provides the standard glXxx functions and a way to integrate OpenGL in the OS display.
- EGL should provide a single interface to embedded systems' OpenGL ES implementations, for instance Android's. EGL still requires platform-specific code, and only deals with low-level graphic context and texture setup. Apple's iPhone uses a modified/extended version called EAGL. You can work at this level, but usually parts of your program will be specific to one platform and not portable.
- GLEW and GLee provide some help with calling the OpenGL base functions and extensions in C; you can choose either one, as they imply almost no change to your code, or even neither and use
#define GL_GLEXT_PROTOTYPESfor basic uses.
- GLUT, as well as GLFW, SDL and SFML, provide a truly platform-independant wrapper to start the OpenGL screen (exactly the same C code). Usually they also come with support for keyboard, joystick, and possibly other features. You can choose a technology at this level when you do portable, direct OpenGL programming, or to target a specific version of OpenGL. These technologies tend to rely on full OpenGL, but support for OpenGL ES and EGL is coming. This book uses this layer!
- Libraries can be based on OpenGL to provide to higher-level features, such as game 2D sprite management (SFML Graphics, ClanLib...), or complete 3D engines (Irrlicht, Ogre...). They may completely shield the user from OpenGL, or only hide the nitty-gritty details (e.g. only give access to GLSL). We can distinguish render engines, scenegraphs, and more abstract game engines. Your choice will depend on what kind of application you are working on (2D, 3D, scene, game...).
- DirectX/Direct3D, from Microsoft, is the main competitor to OpenGL. It covers most of the layers we saw above, up to (and including) the GLUT/GLFW one. Unlike OpenGL, it only runs on the Windows platform and is a proprietary technology.
- OpenCL is for executing generic (non-graphic) code on the graphic card GPU, for parallel programming. CUDA is a proprietary nVidia-specific alternative.
- Mesa3D provides implementation for several technologies, for instance EGL, OpenGL, OpenGL ES, as well as a software implementation of OpenGL that works without a 3D card, so it spans several base layers. It also allows using OpenGL ES from GNU/Linux (X11) desktops.
Comparison between GLEW and GLee (as of 2015-08):
- GLee supports 3.0 while GLEW supports 4.5
- GLee does not require any initialization while GLEW does (
- GLee does not ship mingw-compatible binary release (only VC++-compatible), and neither does GLEW
- GLee does not cross-compile (AFAICS) while GLEW does (cf. Windows setup)
- GLee's appear to be unmaintained
Hardware support[edit | edit source]
Mobile / smartphones:
- OpenGL ES 1.1 is supported in most smartphones. Only a few early (2009) or low-end models, such as HTC G1/Dream/Hero/Magic (Qualcomm MSM72XX GPU) do not support 3D acceleration. It's supported in all iPhones and iPod Touches (PowerVR MBX GPUs and SGX GPUs).
- OpenGL ES 2.x is supported in most smartphones released after mid-2010, except low-end ones. This includes iPhone 3GS, iPod Touch 3rd generation (PowerVR SGX535 GPU), Samsung Galaxy S (PowerVR SGX540 GPU), HTC Legend, Samsung Galaxy Ace (Qualcomm MSM7227 GPU), Nexus One (Qualcomm Snapdragon chipset / Adreno >= 200 GPU)...
- Screen size (in pixels) may vary a lot, from 240x320 to 640x960.
- Android has statistics on OpenGL 2.0 deployment.
- OpenGL 2.x is available since 2002/2003. Current graphic cards support OpenGL 3.x or 4.x.
- Free (as in freedom) drivers for GNU/Linux support OpenGL 3.1 as of June 2013 (cf. Xorg wiki's RadeonFeature).
- Radeon r600 supports GLSL 1.3 with mesa-dri >= 9.0, OpenGL 3.0 with also Linux kernel >= 3.6 (tested), and apparently OpenGL 3.1 with also mesa-dri >= 9.1 and xorg-xserver >= 1.13 (to test)
$ glxinfo | grep -i opengl OpenGL version string: 3.0 Mesa 9.1.3 OpenGL shading language version string: 1.30