Candle-Fire / umbra

1 stars 3 forks source link

Module system base #8

Closed dpeter99 closed 1 year ago

dpeter99 commented 2 years ago

This PR adds the base of the Module system. It allows loading the game-specific code at runtime from a DLL.

The game module is loaded based on the run argument -game that specifies a DLL to be loaded. This DLL has to have a shadow_main entry point as an extern "C". The DLL can then add new Modules to the engine. Later this will be the point where they can request additional modules.

The engine has all of its members exported by the build setup, so there is no need to __declspec(dllexport) the things that are needed from the game DLL side.

Changes:

Cmake clean up

Module system

Misc

TheCurle commented 1 year ago

The engine has all of its members exported by the build setup, so there is no need to __declspec(dllexport) the things that are needed from the game DLL side.

The MSVC packaged with Visual Studio 2022 does not export global or static variables by default. Therefore, the vars in Time.cpp and the instance in ModuleManager must be conditionally imported or exported manually.

That looks something like:

#ifdef EXPORTING_SH_ENGINE
#define API __declspec(dllexport)
#else
#define API __declspec(dllexport)
#endif

Then placing API before the type of global/static declarations will allow the game module to access this information.

TheCurle commented 1 year ago

Other than that, the only thing preventing me from approving this is the major bugs in CLion and Visual Studio that prevent me from being able to debug the engine while the game module is running.