Drain Engine

Project Details

Technologies used: Java, C++, LWJGL (OpenGL, OpenAL and Vulkan native library bindings), Vulkan


While working on the Heavy Rain port, I was looking for a solution I could use for rendering in Java, but unfortunately there were not many options available, so I've decided to create a simple minimal engine capable of 3D graphics. The project is still work in progress, but the OpenGL rendering backend is already implemented and being used by the Heavy Rain port.

While the project started out as a Java-based OpenGL engine, after being faced with the constraints of Java I experimented doing a full rewrite in C++ using Vulkan as the primary rendering backend. Working with Vulkan allowed me to understand the graphics pipeline better, which resulted in a more optimised architecture in the C++ implementation.

The project has since evolved to include a simple scene editor and asset management tools that allow creating custom game projects using the engine.

Main loop

The main loop of the engine makes use of a thread pool which in turn executes a set of jobs for the frame. The set can consist of entity updates, resource uploads, render command submissions, etc. To reduce the number of rendering pipeline changes the engine prepares a set of rendering command buffers for each pipeline and records them from multiple threads to later submit them from the main thread.

Entity/Component System

The core of the engine is based on the entity/component system, a scene updates and renders a set of entities, which can have parents, children, and a set of components which define the entity's behaviour.

Rendering

The rendering is abstracted, with OpenGL used as the currently implemented renderer in the Java edition, and a work-in-progress Vulkan renderer in the C++ version. Basic support for cameras, diffuse and specular shading, custom shaders and skeletal animation of the 3D meshes is available. A Resource Manager is used for loading/unloading scene resources, which loads resources from a priority queue in-between update cycles. It also provides an easy way of verifying the loaded state of a batch of resources, as well as performing a cleanup.

The engine also features an FFmpeg based video player, allowing for animated textures and compressed video/audio formats

Audio

The audio in the engine is implemented in OpenAL, with 3D spatial audio support, supporting multiple audio formats with FFmpeg.