Maciej Mróz Personal Blog

Because why not

Mar 4, 2012 - 3 minute read - Technology Programming Books

If you haven't noticed, OpenGL API is alive and kicking

Recently I somehow found enough time to read “OpenGL SuperBible, 5th edition”. It was something done purely for fun, just to see how things are looking today for modern graphics APIs. Last time I did any serious graphics programming, OpenGL was slowly dying.

In fact, my M.Sc. thesis used Direct3D as implementation API. I simply had no choice. There was no standard for anything - every single important feature was exposed through extensions. At the same time, Direct3D 9 was well thought, simple, and forward looking. Microsoft was leading the way, and everyone knew that. As an example: somewhere around 2005, EXT_framebuffer_object appeared, giving GL functionality that was available since Direct3D 7! Good news: things have changed, and they have changed for better.

In fact, todays OpenGL is awesome. And that’s despite Microsoft API advancing two versions forward since then! Extension hell is gone - core OpenGL defines 99.9% of the stuff you need (I think that the only universally supported functionality that is not in the core is anisotropic filtering and S3TC formats). And there is such thing as “core profile”, making OpenGL shader-only API, with all the legacy stuff removed. What’s also great is that GL went the way of D3D and states pretty clear minimum requirements to support any feature: texture units, inputs and outputs of specific shader stages, texture and renderbuffer formats etc. These minimums are set quite high, and generally correspond to what you see in D3D. Now, I am sure thare are still some differences between the two APIs, but I believe they are pretty much irrelevant.

Let’s go back to the book, because by that time you might be wondering “is it any good?”. The reviews on Amazon aren’t really favorable but my personal opinion is that it is a very, very good book to teach the API and get yourself started with modern GPU programming. Author does not waste time describing legacy fixed function functionality, which is a big plus. You might wonder how to achieve that without falling back to specification-like language - in shader-only environment there’s a lot you have to do before anything actually appears on screen: write, compile and link your shaders (even if simplistic ones), upload geometry data to the GPU, activate shaders, set uniform variables, draw the geometry … a lot of things to do, and you can’t really understand it bit by bit. The book solves “chinken and egg” problem in very elegant way of its own utility libraries. Sample code relies on utility functions that are gradually replaced/extended with newly introduced functionality.

OpenGL SuperBible is not about complex rendering algorithms and shader authoring - every sample is meant to illustrate specific API functionality. At the same time samples are not artificial, which is a big plus (i.e. there is clear example of why you might want to to multisample resolve in the shader in case of HDR rendering). Also, this book is not going to teach anyone about inner workings of modern GPUs. I think that clear focus on just teaching the API is the right thing. Considering the target of this book (beginners) it’s also really hard not to forgive that math part isn’t very thorough :) For me it was a very good read simply to catch up with things, but I also think this book is very good place to start adventure with graphics programming, and then continue education with more advanced resources. Even then, this book will probably remain a valuable reference that you’ll keep handy :)