OpenGL

I’ve finally got OpenGL rendering Banished with identical output to both the DX9 and DX11 renderers. I’ve still got a little bit of work to support the boring parts of a rendering engine, such as handling window resizes, switches to fullscreen, and handling renderer changes at runtime. But all that’s platform specific code. What really matters here is I now have a working GL implementation that should (hopefully) seamlessly work on OSX and Linux.

Here’s a screenshot – which is pretty boring, except it’s rendered with OpenGL and isn’t missing any features.



Initial tests show that the OpenGL renderer is currently not as fast as DX11, but faster than DX9. Not having even tried an optimization pass yet, I’m fairly happy with the level of performance so far.

Getting OpenGL to work has been a bit of a learning experience. I hadn’t used GL since around 2003 – and obviously it’s changed a lot from 1.1 to 4.5. At least I no longer have to use a ton of extensions (but still a few!).

To support a large variety of systems, I’m limiting the renderer to using version 3.2. I like some of the API features in OpenGL/GLSL 4 better, but 3.2 supports everything Banished needs, and potentially supports everything I’d need for future games in the next few years.

Now that I do have OpenGL working, I can’t say that it’s any better or worse than Direct3D 9 or 11 (not that I didn’t do a bit of yelling and face palming while getting the implementation working). I don’t like the API as much as some others, but I’ve got a lot of years of bias on graphics APIs.

In the end it’s still just getting triangles on the screen mapped with textures with some fancy shader programs running. Anytime I’ve used a new system it’s required a new platform specific renderer – Playstation 2, 3, GameCube, Wii, Xboxs, etc all use different APIs, and in the end you get the same picture on the screen at the end of the day. Using GL is really no different. When Vulkan, Mantle, and DX 12 are more widely used, I’ll be doing this all again, but probably with different games.