Dario Scarpa, TOo BUsy TO Mantain A BLOg

Learning OpenGL: a few months later

Yeah, I know, I failed to post at least once a month, the previous post dates back to April… but hey, did you read the title of the blog?

In this post, in March, I wrote about documentation and libraries I found useful in getting started with modern OpenGL.
After a few months, I have a small addendum to do, both regarding documentation and libraries.

Documentation

When I wrote the old post, I suggested some tutorials and online documentation I had been consulting, and I wrote that I hadn’t heard of any single book suitable to learn modern OpenGL. A few weeks after my post, the OpenGL Programming Guide (8th edition), also known as “the red book“, was published – and things changed.
I bought it from Amazon (33,50 € – definitely affordable) and spent the last week reading it cover to cover: it’s great stuff, clearly written, well organized, with the amount of detail I expected (not so much to make you feel lost, but enough to give a comprehensive introduction to the API).
I wish I had it when I started learning, and I strongly advise anybody trying to learn OpenGL to buy it right now – it will be a time saver.

I read that the previous editions were heavily criticized for mixing modern OpenGL with deprecated stuff, probably as a result of incrementally updating the book. Moreover, GLSL had its own book (“OpenGL Shading Language”, a.k.a. the “orange book”) that, I guess, you definitely needed to supplement the “red book” if you were using shaders.

The 8th edition, instead, is a complete rewrite: it doesn’t use or describe the deprecated API, and it covers GLSL too. Yay! Thankyou, book authors!

Libraries

If you read the old post, you might remember that I was quite confused about what was the best image handling library to be used with OpenGL.

I listed DevIL, FreeImage, ImageMagick, OpenGL Image (GLI), and Simple OpenGL Image Library (SOIL).
Recently, I also stumbled on GL Image, part of the Unofficial OpenGL SDK, that looks promising.

The “Unofficial OpenGL SDK” deserves a special mention by itself: it’s a collection of libraries and utilities helpful in getting started with OpenGL development.

I motivated my library-picks (GLFW, GLM, GLEW, Assimp) in my previous post, and I was glad to see that more experienced developers also choosed GLFW and GLM for their SDK. For image handling, the thing I was mostly in doubt about, they provided a custom library: I guess I wasn’t the only one unsatisfied in some way by all the popular libs?
On the paper, GL Image rocks, and only lazyness and the dependancy on GL Load (the SDK alternative to GLEW, that I’m using) have prevented me to try it up to now.

I don’t exclude switching to the SDK: as for the “red book”, I wish it was available earlier. Anyway, it’s worth noting that the SDK currently misses an asset loading library. Why don’t they include Assimp? I’m using it, so I hope they don’t have any good reason! 🙂

A comparison of all the image handling libraries on some key points (formats supported, features, syntax, license, usability, portability, documentation) would be interesting: it looks like a lot of work, but maybe I’ll try to write something about it in the future.

If you were wondering what I am using now, it’s DevIL.
The library API is similar in some way to the OpenGL one, and for the very limited usage I’m doing, no problems arise.
Unfortunately, it looks like DevIL development ceased in 2010 – you’ve been warned.

Anyway, postponing my final choice about image handling, there’s another library I’d like to suggest today: AntTweakBar, a GUI library.

At the beginning, I limited myself to using keyboard/mouse events to select/move objects and adjust colors or other properties in my test programs.
Of course, after a while, I ended up having an unspokable number of unpractical keyboard shortcuts, and no visual feedback about the current state (for example: coordinates of the selected object), that I only printed to the console in response to some key-presses.

Don’t even reach that point: use a GUI library to interact with your OpenGL programs right from the beginning, you’ll save time later.

I think Ant Tweak Bar is a very valuable choice in this field:

it’s easy to integrate into your project (with simplified interfacing to popular libs such as GLUT, SDL, GLFW, SFML)

Nice post, the original post reminded me of when I was starting out a while back.

I’m using OpenGL and the GLM libraries, and AssImp also as part of my asset conditioning pipeline (though I don’t use AssImp directly, I use it to produce an intermediate format that my engine will handle natively)

I never saw the point of using window toolkits, it seemed pretty straight forward on a lot of platforms to roll a custom GL context.. and I really wanted direct control of when the drawing occurs. Not for any good reason, I think I just don’t like relying on libraries in case I’m confronted with a target platform where that library isn’t available… or perhaps I’m just mad 🙂

Image handling, this one was easy..
The rather excellent STB libraries, are a collection of single-header libs to handle all kinds of things..

Biggest stumbling blocks for me so far?
Skeletal animation, closely followed by vertex skinning. This stuff really hurt my head, and some of the code I’ve written is horrendous! Really needs a refactor now 🙂

For audio libraries, you might want to look at Wwise. The other one I’ve been hearing a lot about it fMod. I tossed a coin and went with Wwise, no regrets yet.

Offline resources? The ABSOLUTE BEST purchase I’ve ever made in this regard could only be.. Game Engine Development by Jason Gregory.

Seriously, it is both a great read and has helped me out of many a conundrum! It’s my bible. I want to marry it. I know, I’m strange.

Things I will one day have to to consider?
Physics and collision detection.. and perhaps some more complex lighting, and shadows. I’m looking at something like Havoc, but.. the free edition is PC only.. and then there’s that fact that.. well, it isn’t free in the first place.

ANyway – this went on a bit. I wonder how far along you are now since this post!a

Hey, thanks for your interesting additions!
The STB Image library and Wwise sound promising. For character animation, the only library I found at the time was Cal3D, did you check it out? I was focusing on rendering for my thesis, so I skipped that for lack of time.
That book you mention has been in my Amazon shop cart since a while, I haven’t bought it yet only because I know that currently I wouldn’t have the time to study it properly. Currently I’m working professionally as game programmer and I had to stop with engine programming experimentation for lack of time. But I hope to refactor/enhance my OpenGL sandbox and port it to Vulkan when it will be out 🙂

I didn’t get to Cal3D, no.. again, it was a case of really wanting to know the nuts and bolts of skeletal + vertex skinning. Now that it’s done (and that I’m happy with it), some of the seemingly more difficult stuff just flows – and having done it all myself, it gives me the means to then tackle problems that perhaps I wouldn’t have the background knowledge if I’d used Cal3D..

eg: I can reason and understand the issues around animation mixing, the sliding-feet problem, other quirks around animation timing and solving for inverse kinematics.

For the record, I haven’t solved all of these things – but I like to think maybe I’ll know where to start.

Nice work on the game dev gig. I’m thinking about generalising my engine to run across Direct-X and perhaps Metal… But I think maybe I should think about, i don’t know – an actual game rather than a tech demo maybe? 🙂

Sure, I know the feeling, building subsystems from scratch gives lot of satisfaction 😉
Good luck with your projects… abstracting the rendering interface to use different different graphics APIs might be interesting, but if I were you I’d prefer trying to build up something on what you already engineered in OpenGL, which already gives you a good degree of portability 🙂