Friday Facts #230 - Engine modernisation

Posted by jiri on 2018-02-16

Hello, on Thursday we received a belated Christmas package from our friends over at Steam:

They definitely won't be lasting long :-).

Getting rid of Allegro

As you may know, one of the foundational blocks of the Factorio engine is Allegro. In fact, it has been part of the game since the very first commit! It is a library for handling all sorts of platform interaction, like creating windows, sound playback, handling input, and graphics rendering. Over the course of the last 5 years, we have hacked a lot of custom enhancements and optimizations into Allegro.

Since it is a library with a long history, Allegro copes with a lot of legacy hardware that we don't really have to worry about, which makes it hard to expand and build upon. We also have to deal with a lot of technical issues and driver problems due to the old graphics API that Allegro uses (DirectX 9 & OpenGL 1.2). This has ultimately become a real issue for us and we decided it was time to part with it. The plan is replace the graphics engine with our own code, and leave window management, event handling, and input, to SDL.

We hope that using SDL will result in fewer technical issues, better support for multiple platforms, and greater overall stability. Further down the line we can also explore supporting different input methods, such as gamepads and touch-interfaces.

Graphics engine rewrite

Allegro has sneaked it's way into a huge portion of our codebase, so for the past few months, I have been removing Allegro from as many places as I could, and I've replaced some of its functionality with our own code. I've managed to reduce the number of places we call into Allegro by roughly 50%, and now has come the time to start working on the graphics engine.

So a month ago, HanziQ and I have started on a long and painful journey of replacing the Allegro rendering completely. There is not really a better way to do this than to just rip the band-aid off, so we removed all Allegro rendering and started writing our own from scratch. We are using OpenGL 3.2 for now, but DirectX 11 support is definitely coming before we release it.

We are obviously very good at it and encountered no problems whatsoever.

The whole process was smooth sailing from the get-go.

In fact, it was so easy, that we even had time to unwind with some controlled substances.

Right now, we've got the game back to rendering almost everything properly, and within a few weeks it should be just the same as the Allegro rendering. From this we can start building out our own feature set designed around what we need, and do more advanced work. For instance, DirectX 11 allows us to use a new shader model which has a higher instruction count limit, which will let us do more complex and interesting things with shaders. The more modern API's also have much better developer tools for diagnostics and debugging.

There are a lot of other possibilities moving forward with our own rendering engine, and it is a good step towards the long term viability of the 'Factorio engine'.

T-shirt shop re-opens

Jitka has arrived back from her vacation this week, so we have now re-opened the t-shirt shop. Orders will be sent out every Wednesday as before.

As always, let us know what you think on our forum.