mid's site

you're logged in as loser

🌍 Go Paperful

🔗 Subscribe via RSS

Journey into OpenGL: Introduction


  1. The Series
  2. the First Triangle
  3. the Framebuffer and Depth Buffer
  4. Transformations
  5. Spaces
  6. the Cube?
  7. Vertex Arrays
  8. Index Arrays
  9. ...

This series is still in beta, so contents may change.

Here I shall take you through a bottom-up approach to learning the OpenGL API, which you may use to draw high-performance digital 3D graphics across a wide range of platforms.

This guide will go through many nooks and crannies of OpenGL, from the first versions popularized by games such as Quake, to the ones of today that power the likes of Doom 2016. Rest assured, this will not negatively impact your skill as a programmer. Dare I say it will be improved, because:

  • There is plenty of wisdom to be found in old graphics programming practices - things that would never be thought of because of the convenience brought on by newer OpenGL versions.
  • Old GL features less boilerplate and allows us to start off quicker before continuing to more advanced concepts.
  • Older GL versions naturally support more hardware. Though it's easy to point to statistics such as Steam surveys, the data there is heavily skewed towards a particular demographic. If my laptop is from 2009, it's obvious why I don't install Steam there. This old hardware still exists, however, abandoned yet more than ever still willing to help. Not using it would be negligence.
  • Lastly, it is practically guaranteed these old GL features will be available indefinitely, so you're ultimately hurting nobody by using them.

A common misconception is that OpenGL is a piece of software. In reality it is a specification, a single, specific programming interface. For each hardware a separate driver must be written under this interface, and they have a lot of headroom in how they work internally. Many times you will question the properties or performance of a function, when there is no answer. On the other hand, it is this that gives OpenGL such extreme portability.

OpenGL is easily compatible with many programming languages. So much so, you're likely to be well off with just this document. Regardless, I shall be writing everything in C for its ubiquity and easy-to-read nature. If you decide on a different language, it's easy to port the C code. I shall additionally use the following libraries:

  • GLFW, which will give us a window in which to draw;
  • glad, which will grant us access to the OpenGL interface.
  • cglm, a linear algebra library for dealing with vectors and matrices

Alternatives to these libraries exist (FreeGLUT, direct OS interfaces, Eigen, etc.), should you decide not to go with my choices. With that said, let's get started.