Project Soon

Dynamic Library Loading and Rendering Pipeline

Some should know by now that I have been thinking to add some sort of pipeline or add-on system used for the rendering. The rendering pipeline itself is currently set in stone, where you can only specify what parts to include and it will be done in proper order. I later thought of adding some sort of pipeline string where you can customize this, but I don’t expect people to find it intuitively enough.

But before I found enough reasons to implement it, I had already implemented the most necessity framework for dynamic library loading. This was intended to move away heavy dependencies from the main library and allow a vast expansion of the render possibilities, like with OpenGL. Though, lowering the expectation a little and instead implement the first library as a prototype with Lua made it a bit easier. Adding a framework to be utilized on top of the currently highly efficient rendering may result in severe performance degradation, but that is not a big concern for an extra feature.

As I got some free time and barely any internet for a couple of days, I sat down with WSL2, VSCode, Lua and a couple of more tools. I used Lua over 10 years ago and have forgotten quite a bit of it, but felt that it was the best tool to try this out on, but more about that an another day. The framework for the library itself was quite straightforward, where everything is set up in stages:

  1. Load the library.

  2. The constructor is being called inside the library itself, setting up important variables and features.

  3. Retrieve the version, if it exist at all. Will be useful if versioning is important, but also for logging purposes.

  4. Load arguments, could be anything that can fit inside a list of void pointers. For the prototype it contains the file to load.

  5. Use the library.

  6. Unload the library, calling the destructor to clean up anything previously created.

In addition to this, a very simple framework was created where the library provide two functions, a construct and a destruct, needed to allocate any implementation of classes into objects that can be used by the main library. This is neatly designed to be quite automatic, so one only need to provide the name of the class and it will happily allocate it and later destroy it automatically.

The whole system is called “moduling”, where the library is a module being loaded and we can interact with it seemingly straightforward. It might be too simple of certain tasks, but for its intention and purpose, this will do for now. I have only tried this on Linux, but I have added some code that should work with Windows too.