Anton's OpenGL 4 Tutorials

Mid 2012, I started teaching myself OpenGL 4 for lecturing at Blekinge Tekniska Högskola in Karlskrona in Sweden. This was new, because most of my graphics experience was with older "fixed-function" libraries that work mostly on the CPU. OpenGL 4 is very different to OpenGL 2.1. In code there is no more glBegin() and glEnd(). The problem-solving approach is also different, as most algorithms are implemented in shader programmes where your algorithm is designed to suit the hardware. It was really hard to find good practical guides for OpenGL 4, so I started making some, and I've kept revising this, and making it easier to learn for the last few years.

Published an eBook

I was asked by several readers if I would make an off-line version that would work on e-readers or mobile devices. I have finally done that! You can now get the book of the film Anton's OpenGL 4 Tutorials on Amazon in Kindle format. I've published my complete list of tutorials there, with some extra opinion and discussion chapters, and some new tutorials.

I write most of this material in my free time, generated by lots of coffee, so it's priced such that one copy sold gives me exactly the price of a coffee at the Science Gallery next door! If you'd like to donate me a coffee, and speed up future work, I would not complain. If you'd like to request I publish on a different platform, or think that it would be worthwhile making a print version, let me know. I'll maintain a page of book Errata and Source Code Information here.

Site Redesign

I've re-designed this site so that it still has the "get you started" chapters, and the most popular tutorials, and I'll keep putting new material here as I develop it - hopefully I'll have some nice follow-up material with GLSL compute shaders after the summer holidays! I occasionally write about small, experimental, work on my blog.

I usually say something on Twitter @capnramses when I write a new article or find something related and interesting. I hope that you find this work useful and/or entertaining! Please let me know if you spot an error or typo.

Dr Anton Gerdelan


Here you'll find the basic concepts to get you started, and you can see if you like my teaching style or not!

"Hello Triangle" easy. 2 hours. Minimal code to draw a triangle using simple shaders and vertex buffers.
Extended Initialisation easy. 2 hours. Specifying OpenGL version, configuring the display, getting driver information, extension handling with GLEW, and adding a frames-per-second counter.
Shaders moderate. 2 hours. Shaders determine the style of rendering.
Vertex Buffer Objects easy. 2 hours. Vertex buffer objects hold the mesh data to render on the graphics hardware. We add a vertex buffer with colours to our triangle and show vertex-fragment interpolation.

Selected Tutorials

By popular demand, here are some selected favourite tutorials.

Ray-Based Picking moderate. a couple of hours. Cast rays from mouse pointer to various primitive "bounding" shapes.
Cube Maps: Sky Boxes and Environment Mapping moderate. 1 day. Look at using GL cube maps for sky boxes, and environment-mapping reflection and refraction effects.

New and Experimental Tutorials

On my list after the summer holidays are: compute shaders, and some detailed optimisation strategies, HDR, Bloom with HDR. I can also do some interesting WebGL tutorials, which I've been using a lot lately.

Morph Target Animation moderate. 4 hours Using interpolation between animation "targets". AKA "blend shapes".
WebGL Starter easy. 2 hours Moving into WebGL.

Useful References

Source Code

All of the source code required can be found in snippets in the tutorials. I go to great pains not to refer to any custom code framework, and use minimal third-party libraries. If you'd like to download my entire collection of stand-alone demo code, with project files, you'll find the instructions in the opening pages of the e-book!

SDL2 Fork

Dr Aidan Delaney at the University of Brighton has made an SDL2-based fork of the source code for graphics in the Computer Science (Games) BSc (Hons) programme. SDL2 replaces GLFW3 as the main helper library in this fork.