SAGIT B.
SOFTWARE DEVELOPER
sagitbolat@gmail.com  ·  © Sagit Bolat

Writing a Game Engine Part I: Introduction

Posted Nov 9, 2022

Background

I should first note that this is NOT my first game engine. My first serious attempt was just over a year ago. As is evident from the fact that I am now on my second attempt, the first one did not pan out very successfully. The biggest reason was a lack of understanding of the scope of the project. A few months prior to starting, I had completed a college project that involved generating dungeons and having the user explore them. My partner and I implemented dynamic tile-based lighting, and I felt a surge of inspiration from being able to program a game-like project without an engine.

This is likely where my drive to start working on games at a lower level began. I enjoyed having nuanced control over how the final product behaved. The API we used felt more like a canvas to draw onto rather than an abstract system to interact with indirectly.

How we got here

Unfortunately, I quickly realized that creating a full game engine from scratch — even with a library to handle most of the platform code — was a much deeper commitment than my college projects led me to believe. As I added more and more to my first engine, the project became harder and harder to work on. Looking back, it was clear that my understanding of what a game engine is and what it is meant to do was flawed. It was akin to flailing in the dark, hoping to accidentally bump into the light switch.

My second attempt began after a 5-month break spent researching and figuring out what I did wrong the first time. I abandoned heavy inheritance hierarchies and focused on writing a simpler approach. The resulting project was easier to get started on and to maintain.

What now?

Today, the engine I am working on is called SkyEngine. I have learned a lot while working on it, and I believe I can share some of what I've learned. When I first started out, most resources were either too advanced or too general to be practical. With this devlog, I hope to provide a more structured approach for people like me who had no idea where to start.

Helpful Resources

1. The Handmade Hero Series by Casey Muratori — A great resource to get started. I followed the series until about Day 15 and ended up with a working platform layer. What I learned is worth far more than just the platform layer code.

2. Game Engine Architecture by Jason Gregory — A good reference manual. If you need a primer on a certain topic in engine programming, there is a good chance this book has a chapter on it. I particularly recommend the sections on 3D math (Chapter 4), rendering (Chapter 10), and physics (Chapter 12).

3. Game Engine Black Book: Doom by Fabien Sanglard — More of a book you read through than a reference. It provides a detailed look into the Doom source code and gives good insight into how an objectively good programming team approached game and engine design.

Writing a Game Engine Part II: Platform Layer

Posted Nov 10, 2022

As I mentioned in the previous post, I used Handmade Hero as a starting point for writing the platform layer. It is a great resource I cannot recommend highly enough.

That said, I wasn't the biggest fan of using the Win32 API directly, because I wanted to be able to work on Linux. My solution was to use the SDL library to do the cross-platform heavy lifting. I was able to isolate the SDL code from the rest of my codebase so that if I want to swap SDL for Win32 in the future, it will be as easy as writing a new platform layer and replacing the file in the build path.

In this article I will walk through how the platform layer is structured. (Full write-up coming soon — this post is still a work in progress.)