You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have started to use the pixel game engine in a more complex project structure, where the main engine is running in the main process (.exe), but you can load dynamic components (.dll), which are kind of plugged in into the UI drawing. In my case I would like to have the dynamically loaded components to be able to draw on my olc::TransformedView, which represents my main canvas and the UI elements where I am using the DearImGui implementation for the olcPixelGameEngine.
But caused by the design how the PGEX base class holds the pointer to the actual engine, it´s not possible to use extensions on the dll side. Since the pge pointer is a static class member, the dll which also has to include the required pixelGameEngine headers, has a different context.
The pointer to the actual engine is set in the constructor of the engine (which by design would not allow to have multiple engines running by the way?)
PixelGameEngine::PixelGameEngine()
{
sAppName = "Undefined";
olc::PGEX::pge = this;
// Bring in relevant Platform & Rendering systems depending// on compiler parametersolc_ConfigureSystem();
}
Proposal
Since I have a single point where my dynamically loaded components register their draw callbacks, I currently use this step to pass the actual olc::PixelGameEngine* to the DLL. Further I added a public static method to the PGEX base class, to be able to set the engine pointer with this function simple as that. This allowes me to set the extension context in all loaded DLLs
The DearImGui implementation handles this problem by providing static methods GetCurrentContext() and SetCurrentContext(), which also works fine for me. So if you think this improvement is worth to be implemented, maybe such Interface would be a little bit more intuitive?
The text was updated successfully, but these errors were encountered:
Issue
I have started to use the pixel game engine in a more complex project structure, where the main engine is running in the main process (.exe), but you can load dynamic components (.dll), which are kind of plugged in into the UI drawing. In my case I would like to have the dynamically loaded components to be able to draw on my
olc::TransformedView
, which represents my main canvas and the UI elements where I am using theDearImGui
implementation for the olcPixelGameEngine.But caused by the design how the
PGEX
base class holds the pointer to the actual engine, it´s not possible to use extensions on the dll side. Since thepge
pointer is a static class member, the dll which also has to include the required pixelGameEngine headers, has a different context.The pointer to the actual engine is set in the constructor of the engine (which by design would not allow to have multiple engines running by the way?)
Proposal
Since I have a single point where my dynamically loaded components register their draw callbacks, I currently use this step to pass the actual
olc::PixelGameEngine*
to the DLL. Further I added a public static method to thePGEX
base class, to be able to set the engine pointer with this function simple as that. This allowes me to set the extension context in all loaded DLLsThe
DearImGui
implementation handles this problem by providing static methodsGetCurrentContext()
andSetCurrentContext()
, which also works fine for me. So if you think this improvement is worth to be implemented, maybe such Interface would be a little bit more intuitive?The text was updated successfully, but these errors were encountered: