it works?

This commit is contained in:
Asuro
2025-02-08 01:46:25 +01:00
parent 60640a708f
commit b263c3aa82
19 changed files with 801 additions and 18 deletions

View File

@@ -11,6 +11,7 @@
typedef void (*Startup)(void*);
typedef void (*Update)();
typedef void (*Shutdown)();
constexpr UINT WM_CUSTOM_DLL_CHANGE = WM_USER + 1;
@@ -38,6 +39,7 @@ namespace
DevelopmentData DevData;
Startup StartupFunc;
Update UpdateFunc;
Shutdown ShutdownFunc;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
@@ -163,8 +165,20 @@ bool ReloadDLL()
return false;
}
#ifdef VISUAL_STUDIO
Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "_ZN4Game8ShutdownEv");
#else
Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "_ZN4Game8ShutdownEv");
#endif
if (ShutdownReloaded == NULL)
{
printf("Failed to load shutdown function from game DLL\n");
return false;
}
StartupFunc = StartupReloaded;
UpdateFunc = UpdateReloaded;
ShutdownFunc = ShutdownReloaded;
printf("Loaded Game DLL successfully!\n");
return true;
@@ -177,19 +191,10 @@ int main()
if (!ReloadDLL()) return 1;
bgfx::Init init;
init.platformData.nwh = (void*)window;
init.platformData.ndt = nullptr;
init.platformData.type = bgfx::NativeWindowHandleType::Default;
init.resolution.width = 1920;
init.resolution.height = 1080;
init.resolution.reset = BGFX_RESET_VSYNC;
bgfx::init(init);
StartupFunc(window);
DWORD fileWatcherThreadId = 0;
CreateThread(NULL, 0, FileWatcherThread, NULL, 0, &fileWatcherThreadId);
StartupFunc(window);
bool isRunning = true;
while (isRunning)
{
@@ -198,7 +203,7 @@ int main()
{
if (msg.message == WM_QUIT)
{
isRunning = false;
}
TranslateMessage(&msg);
@@ -208,9 +213,11 @@ int main()
if (DevData.FileWatcher.Change)
{
DevData.FileWatcher.Change = false;
ShutdownFunc();
ReloadDLL();
StartupFunc(window);
}
UpdateFunc();
}
return 0;