Debug Render System
To incorporate debug rendering in Polytree Engine, I designed a Debug Render System capable of handling its own cameras as well as being able to draw both 2D and 3D shapes in the scene.
Here’s what the scene looks like when drawing all debug shapes and billboarded texts:

Debug shapes and texts rendered
To incorporate this, I implemented a DebugRenderer class which serves as the interface used by a game to call into. Below is the header for my DebugRender system:
The general purpose of the system is to allow adding debug geometry to the screen from anywhere else in the application at any point during a frame. The debug geometry will have a specified lifetime and may change color over that lifetime.
Below is the logic for adding a debug wire sphere to the list of debug primitives that are to be rendered.
As can be seen above, an instance of a DebugRenderGeometry object is created and properties of the debug primitive such as lifetime, its own timer, its rasterization details among other data are fed in and added to the list of debug primitives owned by the debug render system.
When the debug render function is called, the DebugRenderWorld function executes all draw calls for 3D objects and world text in the scene. This is what the DebugRenderWorld function on DebugRenderer looks like:
When the debug render function is called, the DebugRenderScreen function executes all draw calls for all the 2D text on screen in the scene. This is what the DebugRenderScreen function on DebugRenderer looks like:
Logic to support billboarded texts and objects was also implemented to add in more functionality to the debug render system. Billboarded textured primitives are also in use in the Doomenstein project. all the enemies in that game use billboards to always face the player.
Example of billboarded enemies in Doomenstein
Below are the types of billboards supported by the engine and its code structure:
Logic to generate the different types of billboard transform matrices:
Considerations Made
-
This was a debug system so performance wasn’t as important
-
I want something easy to use
-
Should be able to use it’s own debug cameras to render
-
2D and 3D should be completely different draw calls and draw logic