2.1 Core-profile vs Immediate mode 19
2.1 Core-profile vs Immediate mode
In the old days, using OpenGL meant developing in immediate mode (often referred to as the fixed function
pipeline) which was an easy-to-use method for drawing graphics. Most of the functionality of OpenGL
was hidden in the library and developers did not have much freedom at how OpenGL does its calculations.
Developers eventually got hungry for more flexibility and over time the specifications became more flexible;
developers gained more control over their graphics. The immediate mode is really easy to use and understand,
but it is also extremely inefficient. For that reason the specification started to deprecate immediate mode
functionality from version 3.2 and started motivating developers to develop in OpenGL’s core-profile mode
which is a division of OpenGL’s specification that removed all old deprecated functionality.
When using OpenGL’s core-profile, OpenGL forces us to use modern practices. Whenever we try to
use one of OpenGL’s deprecated functions, OpenGL raises an error and stops drawing. The advantage of
learning the modern approach is that it is very flexible and efficient, but unfortunately is also more difficult to
learn. The immediate mode abstracted quite a lot from the
actual
operations OpenGL performed and while
it was easy to learn, it was hard to grasp how OpenGL actually operates. The modern approach requires the
developer to truly understand OpenGL and graphics programming and while it is a bit difficult, it allows
for much more flexibility, more efficiency and most importantly a much better understanding of graphics
programming.
This is also the reason why our tutorials are geared at Core-Profile OpenGL version 3.3. Although it is
more difficult, it is greatly worth the effort.
As of today, much higher versions of OpenGL are published (at the time of writing 4.5) at which you
might ask: why do I want to learn OpenGL 3.3 when OpenGL 4.5 is out? The answer to that question
is relatively simple. All future versions of OpenGL starting from 3.3 basically add extra useful features
to OpenGL without changing OpenGL’s core mechanics; the newer versions just introduce slightly more
efficient or more useful ways to accomplish the same tasks. The result is that all concepts and techniques
remain the same over the modern OpenGL versions so it is perfectly valid to learn OpenGL 3.3. Whenever
you’re ready and/or more experienced you can easily use specific functionality from more recent OpenGL
versions.
When using functionality from the most recent version of OpenGL, only the most modern
graphics cards will be able to run your application. This is often why most developers generally
target lower versions of OpenGL and optionally enable higher version functionality.
In some tutorials you’ll sometimes find more modern features which are noted down as such.
2.2 Extensions
A great feature of OpenGL is its support of extensions. Whenever a graphics company comes up with a
new technique or a new large optimization for rendering this is often found in an extension implemented
in the drivers. If the hardware an application runs on supports such an extension the developer can use
the functionality provided by the extension for more advanced or efficient graphics. This way, a graphics
developer can still use these new rendering techniques without having to wait for OpenGL to include the
functionality in its future versions, simply by checking if the extension is supported by the graphics card.
Often, when an extension is popular or very useful it eventually becomes part of future OpenGL versions.
The developer then has to query whether any of these extensions are available (or use an OpenGL
extension library). This allows the developer to do things better or more efficient, based on whether an
extension is available:
if(GL_ARB_extension_name)
{
// Do cool new and modern stuff supported by hardware
}
else
{
// Extension not supported: do it the old way