DEV Community

Cover image for My 2 Year Journey In Writing A Game Engine in C++
Shreyas
Shreyas

Posted on

My 2 Year Journey In Writing A Game Engine in C++

Hello Fellow Viewers,

I’m Shreyas, and today marks a significant milestone: two years of work on my game engine project.

I embarked on this journey back in August 2022, right after finishing high school. My goal has always been to develop a complete, production-ready game engine. Although I faced a few setbacks with earlier attempts, I just really want to do it. I’m excited to introduce you to Xenode, a general-purpose, cross-platform engine (at least in theory—we’re on the way to making that a reality).

As of now, I’ve developed a 2D renderer and successfully integrated 2D physics and scripting into the engine. Additionally, the project features a Level Editor named Xen, which is crafted using ImGui for a user-friendly interface. For graphics, I've utilized the OpenGL API, Box2D for handling 2D physics, and Lua for scripting, all of which together form the core of Xenode's functionality.

From Java to C++

As the title suggests, I developed the game engine using C++. When I first decided to embark on this project, my experience with C++ was minimal, as I was more familiar with Java. Initially, I tried to build the engine using Java and a Library called LWJGL (Light Weight Java Game Library) , but my lack of experience with graphics programming in general led to several setbacks.

Realizing that most engines are written in C++, I shifted my focus to learning C++. The early stages were challenging, but the effort proved worthwhile. Despite facing multiple failures in my attempts to create a game engine in C++, I eventually succeeded in developing a robust foundation for Xenode. This experience has been incredibly rewarding and has set the stage for further development.


Here's the link to the GitHub repository: Xenode
Let's dive into the structure and architecture of Xenode.

The Game Engine.

The project as a whole is mainly divided into three parts:

  1. Xenode - The game engine core
  2. XenodeRuntime - The game engine runtime
  3. Xen - The game engine level editor

The core of the game engine is implemented as a static library, which is linked both to the game's runtime and to the level editor. For managing the build system, I chose Premake, which stood out for its use of Lua which is a straightforward and flexible scripting language. Development was carried out using Visual Studio IDE, paired with the MSVC Compiler to streamline the coding and compilation process.

The Architecture of the Game Engine Core

Game engines in general are quite complex. Since Xenode is intended to be a general purpose and cross platform game engine, there are various sub-systems within the game engine core for the working of the engine.

A few of the subsystems are:

  • The Base Application sub-system
  • The 2D Batch Renderer
  • The 2D Physics sub-system
  • The Scripting sub-system
  • The Scene sub-system

The Base Application sub-system

This sub-system serves as the foundational framework for the engine’s core, managing essential functions such as setting up the rendering surface, initializing the main game loop, and handling the graphics context. It also incorporates a layer system, allowing "layers" to be dynamically pushed or popped from the base application as needed. Each layer comes with its own set of methods, which are called at various stages of the engine’s lifecycle.

Given that Xenode is designed to be cross-platform, there are distinct implementations of the Base Application sub-system for desktop and mobile devices. This distinction is necessary due to the different ways rendering surfaces are managed across desktop and mobile operating systems. At present, Xenode has been tested on Microsoft Windows, while builds for Android and Linux are still in development.

The 2D Batch Renderer

This sub-system is dedicated to rendering 2D graphics to the screen. Currently, the 2D renderer can handle textured quads, circles, and also implemented a basic particle system.

It's important to note that the renderer employs a batching approach. This means it accumulates all the primitives that need to be drawn and processes them in one or more batches, rather than issuing a separate draw call for each primitive. This batching technique greatly enhances the performance of the renderer, providing a more efficient solution for the engine.

Some of the features I plan to implement in the game engine in the future include 2D lighting, both hard and soft shadows, HDR support, text rendering, and various post-processing effects such as bloom and color grading. Additionally, I aim to integrate a robust 2D animation system to enhance the engine's capabilities.


There is not much to talk about the other sub-systems of the engine, so stay tuned for the posts related to the other sub-systems.

The Editor project

A game engine level editor is a crucial tool that enables developers to design and construct the various stages and environments within a game, Hence I designed a level editor in ImGui which is not only easy library to work on, but heavily customizable. I named the editor 'Xen'.
Here are some early development screenshots of the level editor:

Early development

Early Development 2

Here's how it looks at the time of writing:

Current Development


As I look back on the two years spent developing Xenode, I’m excited about what’s been achieved and eager for what’s next. Creating a game engine from scratch, especially switching from Java to C++ and building a functional 2D renderer and level editor, has been a rewarding challenge.

There’s still much to do, including expanding features and improving the engine. Your support can make a big difference—whether by providing feedback, helping with code, or just exploring the project on GitHub. I invite you to join this journey, contribute, and help make Xenode a powerful tool for game development.

Contribute to Xenode

Top comments (0)