I am currently creating a 2D game/game engine using an ECS architecture. Currently I have a
renderer_2d system which is a function that takes all
Text components and draws them using a
draw function in a
Renderer interface. The
draw function takes in a handle to a texture, pipeline and an array of vertices to be drawn. The
Renderer is an interface to the Graphics API, currently Vulkan or OpenGL and handles texture creation and draw calls.
I would like to allow my
renderer_2d system to be extensible and I am wondering what the best way to do this would be. I would like to add other types of objects to be rendered, such as tilemaps, etc. and in the future support multiple passes (e.g. world and UI). I was thinking of a few various methods.
- Allowing systems to queue draw calls and placing them in the graphics queue at end of frame
- Registering callback functions/lambdas called when the system is executed which each make draw calls
I am a unsure on what would be the ideal way(s) to implement this. The engine is targeting 2D games and so I do not plan to support complex 3D meshes, etc.