Lazy Foo' Productions

SDL Forums external link SDL Tutorials Articles OpenGL Tutorials OpenGL Forums external link
Follow BlueSky Follow Facebook Follow Twitter Follow Threads
Donate
News FAQs Contact Bugs

The Introduction to Introduction to OpenGL

Last Updated: Aug 9th, 2012

Welcome to Introduction to OpenGL, a tutorial set designed to getting newbie programmers started with OpenGL.

What we'll be covering

In OpenGL, pretty much all rendering is done by rendering polygons. In this tutorial, we'll be
  • Rendering polygons in 2D.
  • Texturing the polygons to render bitmaps.
  • Applying transformations like scaling and rotation to the polygons.
  • Rendering fonts using textured polygons.
  • Using OpenGL buffers to render.
  • Using programmable shader programs to render.
  • Transitioning from the old fixed function pipeline rendering to the modern OpenGL programmable pipeline.

What we won't be covering

This tutorial set was designed to get OpenGL programmers with 2D concepts. We will not be covering 3D rendering. To make a decent 3D tutorial set, I would have to make the tutorial set roughly 3 times as big which is something I just don't currently have time for.

Whether rendering in 2D or 3D, OpenGL still renders with polygons. To move over to 3D rendering, just using a perspective matrix as opposed to an orthographic matrix. If you didn't understand that last sentence, you'll find out later in the tutorial set it isn't that hard to do.

What is fixed function pipeline?

A pipeline is just a set of functionality to process data. For the first part of this tutorial, we use fixed function pipeline calls. Back in the early days of OpenGL, the API had calls built in to handle things like matrix transformations and lighting. It made it easy to start rendering things, but you were limited to the built in functionality (hence "Fixed Function Pipeline").

Then programmable pipelines came along which allowed programmers to make their own GPU pipelines. Eventually, fixed function pipelines became obsolete because programmable pipelines could do everything they could and far more. Hardware today actually almost always uses programmable pipelines, even to do fixed function stuff.

Why are you using fixed function if it's so outdated?

In the initial versions of the tutorials, I was going to use programmable pipelines from the beginning. Then I started testing the tutorials on people new to graphics programming. This is where I found out if you want to create a sea of blank stares, talk about vertex shaders and fragment shaders to people who have never rendered a polygon.

I then thought of making a wrapper framework to abstract the low level programmable pipeline calls. At that point I realized that if I used my own framework, I'm still teaching new programmers non-standard code that they are probably never going to use. As far as I saw, if I wanted to make the tutorials accessible to new OpenGL programmers I might as well just use the old easier to use fixed function calls and then transition them to modern programmable pipelines.

Just compare tutorial 2 and tutorial 33, both of which do the simple task of rendering a multicolored quad. Contrast the amount of things that could go wrong in either one of them. I would rather allow the new programmer to get their hands dirty with simpler code than be overwhelmed with complex code which they can't mess with for fear that they'll break something.

Besides, as much as OpenGL programmers bemoan the existence of legacy OpenGL, it's going to be sticking around for a while. There's lots of old systems that still use it, and as recently as 2011 I worked with systems that only had OpenGL 1.3. Their knowledge of old OpenGL may prove useful at some point. Considering during the protyping stage for these tutorials I had users with GPUs that didn't support OpenGL 2.0, legacy OpenGL is still alive and kicking.

As I see it, by the end of the tutorial set they're using OpenGL 3.0+ code anyway so they are learning what they should be learning. When they see the power that modern OpenGL offers and they learn how to use it, I doubt new programmers will ever want to go back to the old ways.