Separate game engine from game

I'm building a simple game engine (or mostly rendering engine) and I would like to separate the "engine" part from the "game" part. So, I've come up with an idea to build "engine" part as a library (static or dynamic) and the "game" part will link to this library. Simple.

However, there is one problem - "engine" part needs to reference some assets i.e. files with source code of builtin shaders (defualt shaders of the rendering engine).

Is there a way to include these shader files into an "engine" library? Or is there any other solution to this problem?

Answers 1

  • All my engine's core shaders are provided as data files, and we simply expect each game to include those files as part of their game data. We load them exactly the same way we load any other game asset. Creating a new game? First thing you do is copy those default shaders into your game's asset directory. (The engine complains and refuses to start if they're not there)

    I felt it was important for individual games to have the ability to modify those default shaders, which is why I wanted them to be included in the game's data, rather than in a separate "engine data" directory. I wanted it to be possible for a particular game to replace the 'default' shaders simply by changing their contents, and without needing to touch the engine itself.

    With that said, I do also have a few simple rendering effects (blurs, bloom, etc) which include their own minimal shaders in static string buffers inside the engine, as they're just simple utilities; if somebody wanted something particular, they'd make it themselves rather than use the engine's simple built-in effects.


Related Questions