textures almost work?
This commit is contained in:
@@ -4,19 +4,19 @@
|
||||
#include <processthreadsapi.h>
|
||||
#include <synchapi.h>
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <Windows.h>
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
#include <cstdio>
|
||||
#include <bx/string.h>
|
||||
#include <bx/mpscqueue.h>
|
||||
#include <bx/allocator.h>
|
||||
#include <bx/mpscqueue.h>
|
||||
#include <bx/string.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include "Shared.h"
|
||||
#include "Window.h"
|
||||
|
||||
//#define VISUAL_STUDIO
|
||||
// #define VISUAL_STUDIO
|
||||
|
||||
#ifdef VISUAL_STUDIO
|
||||
constexpr const char* DLLPath = "PuzGame.dll";
|
||||
@@ -28,285 +28,307 @@ constexpr const wchar_t* DLLWatch = L"libPuzGame2.dll";
|
||||
|
||||
namespace
|
||||
{
|
||||
bx::AllocatorI* defaultAllocator = new bx::DefaultAllocator{};
|
||||
bx::AllocatorI* defaultAllocator = new bx::DefaultAllocator{};
|
||||
}
|
||||
|
||||
enum class FileChangeType
|
||||
{
|
||||
DLL,
|
||||
Shader,
|
||||
CompiledShader,
|
||||
DLL,
|
||||
Shader,
|
||||
CompiledShader,
|
||||
};
|
||||
|
||||
struct FileWatcherStartup
|
||||
{
|
||||
char DirPath[512]{0};
|
||||
wchar_t CompName[512]{0};
|
||||
FileChangeType ChangeType = FileChangeType::Shader;
|
||||
bool Shutdown = false;
|
||||
char DirPath[512]{0};
|
||||
wchar_t CompName[512]{0};
|
||||
FileChangeType ChangeType = FileChangeType::Shader;
|
||||
bool Shutdown = false;
|
||||
};
|
||||
|
||||
struct FileWatcherData
|
||||
{
|
||||
FileWatcherStartup DLLWatcher;
|
||||
FileWatcherStartup ShaderWatcher;
|
||||
FileWatcherStartup CompiledShaderWatcher;
|
||||
bx::MpScUnboundedQueueT<FileChangeNotification> ShaderQueue{defaultAllocator};
|
||||
bx::MpScUnboundedQueueT<FileChangeNotification> DLLQueue{defaultAllocator};
|
||||
FileWatcherStartup DLLWatcher;
|
||||
FileWatcherStartup ShaderWatcher;
|
||||
FileWatcherStartup CompiledShaderWatcher;
|
||||
bx::MpScUnboundedQueueT<FileChangeNotification> ShaderQueue{defaultAllocator};
|
||||
bx::MpScUnboundedQueueT<FileChangeNotification> DLLQueue{defaultAllocator};
|
||||
};
|
||||
|
||||
struct DevelopmentData
|
||||
{
|
||||
HMODULE GameLib = NULL;
|
||||
FileWatcherData FileWatcher;
|
||||
HMODULE GameLib = NULL;
|
||||
FileWatcherData FileWatcher;
|
||||
};
|
||||
|
||||
struct EngineData
|
||||
{
|
||||
EngineWindow Window;
|
||||
EngineWindow Window;
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
DevelopmentData DevData;
|
||||
EngineData Engine;
|
||||
SharedData Shared;
|
||||
Startup StartupFunc;
|
||||
Update UpdateFunc;
|
||||
Shutdown ShutdownFunc;
|
||||
}
|
||||
DevelopmentData DevData;
|
||||
EngineData Engine;
|
||||
SharedData Shared;
|
||||
Startup StartupFunc;
|
||||
Update UpdateFunc;
|
||||
Shutdown ShutdownFunc;
|
||||
} // namespace
|
||||
|
||||
void FileChangeCheck(HANDLE dirHandle, FileChangeType changeType, const wchar_t* compName = nullptr)
|
||||
{
|
||||
if (dirHandle == NULL) return;
|
||||
if (dirHandle == NULL) return;
|
||||
|
||||
uint8_t fileChangeBuffer[1024]{ 0 };
|
||||
bx::memSet(fileChangeBuffer, 0, sizeof(fileChangeBuffer));
|
||||
DWORD bytesReturned = 0;
|
||||
if (ReadDirectoryChangesW(dirHandle, fileChangeBuffer, sizeof(fileChangeBuffer), true, FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE, &bytesReturned, NULL, NULL))
|
||||
{
|
||||
uint32_t offset = 0;
|
||||
while (true)
|
||||
{
|
||||
FILE_NOTIFY_INFORMATION* notifyData = reinterpret_cast<FILE_NOTIFY_INFORMATION*>(&fileChangeBuffer[offset]);
|
||||
if (notifyData->Action == FILE_ACTION_ADDED || notifyData->Action == FILE_ACTION_MODIFIED || notifyData->Action == FILE_ACTION_RENAMED_NEW_NAME)
|
||||
{
|
||||
if (compName == nullptr || compName[0] == 0 || wcscmp(notifyData->FileName, compName) == 0)
|
||||
{
|
||||
FileChangeNotification notif;
|
||||
wcscpy(notif.FileName, notifyData->FileName);
|
||||
if (changeType == FileChangeType::DLL)
|
||||
{
|
||||
DevData.FileWatcher.DLLQueue.push(¬if);
|
||||
}
|
||||
else if (changeType == FileChangeType::Shader)
|
||||
{
|
||||
std::system("shadercompile.bat");
|
||||
}
|
||||
else if (changeType == FileChangeType::CompiledShader)
|
||||
{
|
||||
DevData.FileWatcher.ShaderQueue.push(¬if);
|
||||
}
|
||||
printf("detected file change of type %u!\n", changeType);
|
||||
}
|
||||
}
|
||||
uint8_t fileChangeBuffer[1024]{0};
|
||||
bx::memSet(fileChangeBuffer, 0, sizeof(fileChangeBuffer));
|
||||
DWORD bytesReturned = 0;
|
||||
if (ReadDirectoryChangesW(dirHandle,
|
||||
fileChangeBuffer,
|
||||
sizeof(fileChangeBuffer),
|
||||
true,
|
||||
FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_SIZE,
|
||||
&bytesReturned,
|
||||
NULL,
|
||||
NULL))
|
||||
{
|
||||
uint32_t offset = 0;
|
||||
while (true)
|
||||
{
|
||||
FILE_NOTIFY_INFORMATION* notifyData = reinterpret_cast<FILE_NOTIFY_INFORMATION*>(&fileChangeBuffer[offset]);
|
||||
if (notifyData->Action == FILE_ACTION_ADDED || notifyData->Action == FILE_ACTION_MODIFIED ||
|
||||
notifyData->Action == FILE_ACTION_RENAMED_NEW_NAME)
|
||||
{
|
||||
if (compName == nullptr || compName[0] == 0 || wcscmp(notifyData->FileName, compName) == 0)
|
||||
{
|
||||
FileChangeNotification notif;
|
||||
wcscpy(notif.FileName, notifyData->FileName);
|
||||
if (changeType == FileChangeType::DLL)
|
||||
{
|
||||
DevData.FileWatcher.DLLQueue.push(¬if);
|
||||
}
|
||||
else if (changeType == FileChangeType::Shader)
|
||||
{
|
||||
std::system("shadercompile.bat");
|
||||
}
|
||||
else if (changeType == FileChangeType::CompiledShader)
|
||||
{
|
||||
DevData.FileWatcher.ShaderQueue.push(¬if);
|
||||
}
|
||||
printf("detected file change of type %u!\n", changeType);
|
||||
}
|
||||
}
|
||||
|
||||
if (notifyData->NextEntryOffset == 0) break;
|
||||
offset += notifyData->NextEntryOffset;
|
||||
}
|
||||
}
|
||||
if (notifyData->NextEntryOffset == 0) break;
|
||||
offset += notifyData->NextEntryOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HANDLE LoadDirHandle(const char* name)
|
||||
{
|
||||
HANDLE h = CreateFileA(name,
|
||||
FILE_LIST_DIRECTORY,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
HANDLE h = CreateFileA(name,
|
||||
FILE_LIST_DIRECTORY,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
|
||||
if (h == NULL)
|
||||
{
|
||||
printf("Failed to load dir handle for %s", name);
|
||||
}
|
||||
return h;
|
||||
if (h == NULL)
|
||||
{
|
||||
printf("Failed to load dir handle for %s", name);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
unsigned long FileWatcherThread(void* data)
|
||||
{
|
||||
FileWatcherStartup* startupData = reinterpret_cast<FileWatcherStartup*>(data);
|
||||
printf("Starting file watcher of type %u\n", startupData->ChangeType);
|
||||
if (startupData->DirPath[0] == 0)
|
||||
{
|
||||
printf("Invalid file watcher path!\n");
|
||||
return 1;
|
||||
}
|
||||
HANDLE dirHandle = LoadDirHandle(startupData->DirPath);
|
||||
if (dirHandle == NULL)
|
||||
{
|
||||
printf("Failed to load dir %s for file watcher!\n", startupData->DirPath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (!startupData->Shutdown)
|
||||
{
|
||||
FileChangeCheck(dirHandle, startupData->ChangeType, startupData->CompName);
|
||||
}
|
||||
printf("File watcher thread ended!\n");
|
||||
return 0;
|
||||
FileWatcherStartup* startupData = reinterpret_cast<FileWatcherStartup*>(data);
|
||||
printf("Starting file watcher of type %u\n", startupData->ChangeType);
|
||||
if (startupData->DirPath[0] == 0)
|
||||
{
|
||||
printf("Invalid file watcher path!\n");
|
||||
return 1;
|
||||
}
|
||||
HANDLE dirHandle = LoadDirHandle(startupData->DirPath);
|
||||
if (dirHandle == NULL)
|
||||
{
|
||||
printf("Failed to load dir %s for file watcher!\n", startupData->DirPath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (!startupData->Shutdown)
|
||||
{
|
||||
FileChangeCheck(dirHandle, startupData->ChangeType, startupData->CompName);
|
||||
}
|
||||
printf("File watcher thread ended!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ReloadDLL()
|
||||
{
|
||||
if (DevData.GameLib != NULL)
|
||||
{
|
||||
FreeLibrary(DevData.GameLib);
|
||||
}
|
||||
if (DevData.GameLib != NULL)
|
||||
{
|
||||
FreeLibrary(DevData.GameLib);
|
||||
}
|
||||
#ifdef VISUAL_STUDIO
|
||||
if (!CopyFile("PuzGame2.dll", "PuzGame.dll", false))
|
||||
{
|
||||
printf("Failed to copy game DLL!\n");
|
||||
return false;
|
||||
}
|
||||
if (!CopyFile("PuzGame2.dll", "PuzGame.dll", false))
|
||||
{
|
||||
printf("Failed to copy game DLL!\n");
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
if (!CopyFile("cmake-build\\libPuzGame2.dll", "cmake-build\\libPuzGame.dll", false))
|
||||
{
|
||||
printf("Failed to copy game DLL!\n");
|
||||
return false;
|
||||
}
|
||||
if (!CopyFile("cmake-build\\libPuzGame2.dll", "cmake-build\\libPuzGame.dll", false))
|
||||
{
|
||||
printf("Failed to copy game DLL!\n");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
HMODULE gameLibReloaded = LoadLibraryEx(DLLPath, NULL, 0);
|
||||
if (gameLibReloaded == NULL)
|
||||
{
|
||||
printf("Failed to load game DLL from %s!\n", DLLPath);
|
||||
return false;
|
||||
}
|
||||
DevData.GameLib = gameLibReloaded;
|
||||
HMODULE gameLibReloaded = LoadLibraryEx(DLLPath, NULL, 0);
|
||||
if (gameLibReloaded == NULL)
|
||||
{
|
||||
printf("Failed to load game DLL from %s!\n", DLLPath);
|
||||
return false;
|
||||
}
|
||||
DevData.GameLib = gameLibReloaded;
|
||||
|
||||
#ifdef VISUAL_STUDIO
|
||||
Startup StartupReloaded = (Startup)GetProcAddress(DevData.GameLib, "?Setup@Game@@YAXPEAX@Z");
|
||||
Startup StartupReloaded = (Startup)GetProcAddress(DevData.GameLib, "?Setup@Game@@YAXPEAX@Z");
|
||||
#else
|
||||
Startup StartupReloaded = (Startup)GetProcAddress(DevData.GameLib, "_ZN4Game5SetupER10SharedData");
|
||||
Startup StartupReloaded = (Startup)GetProcAddress(DevData.GameLib, "_ZN4Game5SetupER10SharedData");
|
||||
#endif
|
||||
if (StartupReloaded == NULL)
|
||||
{
|
||||
printf("Failed to load startup function from game DLL!\n");
|
||||
return false;
|
||||
}
|
||||
if (StartupReloaded == NULL)
|
||||
{
|
||||
printf("Failed to load startup function from game DLL!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef VISUAL_STUDIO
|
||||
Update UpdateReloaded = (Update)GetProcAddress(DevData.GameLib, "?Update@Game@@YAXXZ");
|
||||
Update UpdateReloaded = (Update)GetProcAddress(DevData.GameLib, "?Update@Game@@YAXXZ");
|
||||
#else
|
||||
Update UpdateReloaded = (Update)GetProcAddress(DevData.GameLib, "_ZN4Game6UpdateEv");
|
||||
Update UpdateReloaded = (Update)GetProcAddress(DevData.GameLib, "_ZN4Game6UpdateEv");
|
||||
#endif
|
||||
if (UpdateReloaded == NULL)
|
||||
{
|
||||
printf("Failed to load update function from game DLL!\n");
|
||||
return false;
|
||||
}
|
||||
if (UpdateReloaded == NULL)
|
||||
{
|
||||
printf("Failed to load update function from game DLL!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef VISUAL_STUDIO
|
||||
Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "?Shutdown@Game@@YAXXZ");
|
||||
Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "?Shutdown@Game@@YAXXZ");
|
||||
#else
|
||||
Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "_ZN4Game8ShutdownEv");
|
||||
Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "_ZN4Game8ShutdownEv");
|
||||
#endif
|
||||
if (ShutdownReloaded == NULL)
|
||||
{
|
||||
printf("Failed to load shutdown function from game DLL\n");
|
||||
return false;
|
||||
}
|
||||
if (ShutdownReloaded == NULL)
|
||||
{
|
||||
printf("Failed to load shutdown function from game DLL\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
StartupFunc = StartupReloaded;
|
||||
UpdateFunc = UpdateReloaded;
|
||||
ShutdownFunc = ShutdownReloaded;
|
||||
StartupFunc = StartupReloaded;
|
||||
UpdateFunc = UpdateReloaded;
|
||||
ShutdownFunc = ShutdownReloaded;
|
||||
|
||||
printf("Loaded Game DLL successfully!\n");
|
||||
return true;
|
||||
printf("Loaded Game DLL successfully!\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
char PathBuf[512]{ 0 };
|
||||
GetCurrentDirectory(sizeof(PathBuf), PathBuf);
|
||||
printf("Current path: %s\n", PathBuf);
|
||||
char PathBuf[512]{0};
|
||||
GetCurrentDirectory(sizeof(PathBuf), PathBuf);
|
||||
printf("Current path: %s\n", PathBuf);
|
||||
|
||||
if (!ReloadDLL()) return 1;
|
||||
if (!ReloadDLL()) return 1;
|
||||
|
||||
Engine.Window.Startup(Shared.Window);
|
||||
if (Shared.Window.Handle == nullptr)
|
||||
{
|
||||
printf("Failed to set up window!\n");
|
||||
return 1;
|
||||
}
|
||||
Engine.Window.Startup(Shared.Window);
|
||||
if (Shared.Window.Handle == nullptr)
|
||||
{
|
||||
printf("Failed to set up window!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
DevData.FileWatcher.DLLWatcher.ChangeType = FileChangeType::DLL;
|
||||
DevData.FileWatcher.ShaderWatcher.ChangeType = FileChangeType::Shader;
|
||||
DevData.FileWatcher.CompiledShaderWatcher.ChangeType = FileChangeType::CompiledShader;
|
||||
|
||||
bx::strCopy(DevData.FileWatcher.DLLWatcher.DirPath, sizeof(DevData.FileWatcher.DLLWatcher.DirPath), "cmake-build");
|
||||
bx::strCopy(DevData.FileWatcher.ShaderWatcher.DirPath, sizeof(DevData.FileWatcher.ShaderWatcher.DirPath), "game/shaders");
|
||||
bx::strCopy(DevData.FileWatcher.CompiledShaderWatcher.DirPath, sizeof(DevData.FileWatcher.CompiledShaderWatcher.DirPath), "game/compiled-shaders/dx11");
|
||||
DevData.FileWatcher.DLLWatcher.ChangeType = FileChangeType::DLL;
|
||||
DevData.FileWatcher.ShaderWatcher.ChangeType = FileChangeType::Shader;
|
||||
DevData.FileWatcher.CompiledShaderWatcher.ChangeType = FileChangeType::CompiledShader;
|
||||
|
||||
wcscpy(DevData.FileWatcher.DLLWatcher.CompName, DLLWatch);
|
||||
|
||||
DWORD fileWatcherThreadId = 0;
|
||||
HANDLE dllThread = CreateThread(NULL, 0, FileWatcherThread, &DevData.FileWatcher.DLLWatcher, 0, &fileWatcherThreadId);
|
||||
HANDLE shaderThread = CreateThread(NULL, 0, FileWatcherThread, &DevData.FileWatcher.ShaderWatcher, 0, &fileWatcherThreadId);
|
||||
HANDLE compiledShaderThread = CreateThread(NULL, 0, FileWatcherThread, &DevData.FileWatcher.CompiledShaderWatcher, 0, &fileWatcherThreadId);
|
||||
bx::strCopy(DevData.FileWatcher.DLLWatcher.DirPath, sizeof(DevData.FileWatcher.DLLWatcher.DirPath), "cmake-build");
|
||||
bx::strCopy(
|
||||
DevData.FileWatcher.ShaderWatcher.DirPath, sizeof(DevData.FileWatcher.ShaderWatcher.DirPath), "game/shaders");
|
||||
bx::strCopy(DevData.FileWatcher.CompiledShaderWatcher.DirPath,
|
||||
sizeof(DevData.FileWatcher.CompiledShaderWatcher.DirPath),
|
||||
"game/compiled-shaders/dx11");
|
||||
|
||||
Shared.Game.PermanentStorageSize = 1024*1024;
|
||||
Shared.Game.PermanentStorage = VirtualAllocEx(GetCurrentProcess(), NULL, Shared.Game.PermanentStorageSize, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
|
||||
Shared.Game.EntityStorageSize = 1024*1024;
|
||||
Shared.Game.EntityStorage = VirtualAllocEx(GetCurrentProcess(), NULL, Shared.Game.EntityStorageSize, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE);
|
||||
StartupFunc(Shared);
|
||||
|
||||
bool isRunning = true;
|
||||
while (isRunning)
|
||||
{
|
||||
Engine.Window.Update(Shared.Window);
|
||||
if (Engine.Window.CloseRequested)
|
||||
{
|
||||
isRunning = false;
|
||||
}
|
||||
FileChangeNotification* DLLChange = nullptr;
|
||||
if (DevData.FileWatcher.DLLQueue.pop())
|
||||
{
|
||||
// Empty queue to avoid multiple reloads
|
||||
while (DevData.FileWatcher.DLLQueue.pop()) {}
|
||||
ShutdownFunc();
|
||||
ReloadDLL();
|
||||
StartupFunc(Shared);
|
||||
}
|
||||
wcscpy(DevData.FileWatcher.DLLWatcher.CompName, DLLWatch);
|
||||
|
||||
FileChangeNotification* CompiledShaderChange = nullptr;
|
||||
while ((CompiledShaderChange = DevData.FileWatcher.ShaderQueue.pop()))
|
||||
{
|
||||
if (Shared.Dev.ChangedShaderCount < BX_COUNTOF(Shared.Dev.ChangedShaders))
|
||||
{
|
||||
wcscpy(Shared.Dev.ChangedShaders[Shared.Dev.ChangedShaderCount].FileName, CompiledShaderChange->FileName);
|
||||
++Shared.Dev.ChangedShaderCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Ran out of shader change buffer!\n");
|
||||
}
|
||||
}
|
||||
DWORD fileWatcherThreadId = 0;
|
||||
HANDLE dllThread =
|
||||
CreateThread(NULL, 0, FileWatcherThread, &DevData.FileWatcher.DLLWatcher, 0, &fileWatcherThreadId);
|
||||
HANDLE shaderThread =
|
||||
CreateThread(NULL, 0, FileWatcherThread, &DevData.FileWatcher.ShaderWatcher, 0, &fileWatcherThreadId);
|
||||
HANDLE compiledShaderThread =
|
||||
CreateThread(NULL, 0, FileWatcherThread, &DevData.FileWatcher.CompiledShaderWatcher, 0, &fileWatcherThreadId);
|
||||
|
||||
UpdateFunc();
|
||||
}
|
||||
|
||||
ShutdownFunc();
|
||||
Engine.Window.Shutdown();
|
||||
Shared.Game.PermanentStorageSize = 1024 * 1024;
|
||||
Shared.Game.PermanentStorage = VirtualAllocEx(
|
||||
GetCurrentProcess(), NULL, Shared.Game.PermanentStorageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
|
||||
Shared.Game.EntityStorageSize = 1024 * 1024;
|
||||
Shared.Game.EntityStorage = VirtualAllocEx(
|
||||
GetCurrentProcess(), NULL, Shared.Game.EntityStorageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
|
||||
Shared.Game.TransientStorageSize = 1024 * 1024 * 100;
|
||||
Shared.Game.TransientStorage = VirtualAllocEx(
|
||||
GetCurrentProcess(), NULL, Shared.Game.TransientStorageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
|
||||
StartupFunc(Shared);
|
||||
|
||||
DevData.FileWatcher.DLLWatcher.Shutdown = true;
|
||||
DevData.FileWatcher.ShaderWatcher.Shutdown = true;
|
||||
DevData.FileWatcher.CompiledShaderWatcher.Shutdown = true;
|
||||
WaitForSingleObject(dllThread, 100);
|
||||
WaitForSingleObject(shaderThread, 100);
|
||||
WaitForSingleObject(compiledShaderThread, 100);
|
||||
|
||||
return 0;
|
||||
bool isRunning = true;
|
||||
while (isRunning)
|
||||
{
|
||||
Engine.Window.Update(Shared.Window);
|
||||
if (Engine.Window.CloseRequested)
|
||||
{
|
||||
isRunning = false;
|
||||
}
|
||||
FileChangeNotification* DLLChange = nullptr;
|
||||
if (DevData.FileWatcher.DLLQueue.pop())
|
||||
{
|
||||
// Empty queue to avoid multiple reloads
|
||||
while (DevData.FileWatcher.DLLQueue.pop())
|
||||
{
|
||||
}
|
||||
ShutdownFunc();
|
||||
ReloadDLL();
|
||||
StartupFunc(Shared);
|
||||
}
|
||||
|
||||
FileChangeNotification* CompiledShaderChange = nullptr;
|
||||
while ((CompiledShaderChange = DevData.FileWatcher.ShaderQueue.pop()))
|
||||
{
|
||||
if (Shared.Dev.ChangedShaderCount < BX_COUNTOF(Shared.Dev.ChangedShaders))
|
||||
{
|
||||
wcscpy(Shared.Dev.ChangedShaders[Shared.Dev.ChangedShaderCount].FileName,
|
||||
CompiledShaderChange->FileName);
|
||||
++Shared.Dev.ChangedShaderCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Ran out of shader change buffer!\n");
|
||||
}
|
||||
}
|
||||
|
||||
UpdateFunc();
|
||||
}
|
||||
|
||||
ShutdownFunc();
|
||||
Engine.Window.Shutdown();
|
||||
|
||||
DevData.FileWatcher.DLLWatcher.Shutdown = true;
|
||||
DevData.FileWatcher.ShaderWatcher.Shutdown = true;
|
||||
DevData.FileWatcher.CompiledShaderWatcher.Shutdown = true;
|
||||
WaitForSingleObject(dllThread, 100);
|
||||
WaitForSingleObject(shaderThread, 100);
|
||||
WaitForSingleObject(compiledShaderThread, 100);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user