fixes for vs

This commit is contained in:
Asuro
2025-02-08 02:21:52 +01:00
parent b263c3aa82
commit 14e923873a
4 changed files with 19 additions and 9 deletions

4
src/.gitignore vendored
View File

@@ -32,4 +32,6 @@
*.app *.app
# build dirs # build dirs
cmake-build/ cmake-build/
out/
.vs/

View File

@@ -7,7 +7,7 @@
#include <bx/string.h> #include <bx/string.h>
#include <bgfx/bgfx.h> #include <bgfx/bgfx.h>
//#define VISUAL_STUDIO #define VISUAL_STUDIO
typedef void (*Startup)(void*); typedef void (*Startup)(void*);
typedef void (*Update)(); typedef void (*Update)();
@@ -16,7 +16,7 @@ typedef void (*Shutdown)();
constexpr UINT WM_CUSTOM_DLL_CHANGE = WM_USER + 1; constexpr UINT WM_CUSTOM_DLL_CHANGE = WM_USER + 1;
#ifdef VISUAL_STUDIO #ifdef VISUAL_STUDIO
const char* DLLPath = "Debug/PuzGame.dll"; const char* DLLPath = "PuzGame2.dll";
#else #else
const char* DLLPath = "libPuzGame.dll"; const char* DLLPath = "libPuzGame.dll";
#endif #endif
@@ -166,7 +166,7 @@ bool ReloadDLL()
} }
#ifdef VISUAL_STUDIO #ifdef VISUAL_STUDIO
Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "_ZN4Game8ShutdownEv"); Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "?Shutdown@Game@@YAXXZ");
#else #else
Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "_ZN4Game8ShutdownEv"); Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "_ZN4Game8ShutdownEv");
#endif #endif
@@ -189,6 +189,11 @@ int main()
HWND window = InitWindow(); HWND window = InitWindow();
if (window == NULL) return 1; if (window == NULL) return 1;
char PathBuf[512]{ 0 };
GetCurrentDirectory(sizeof(PathBuf), PathBuf);
printf("Current path: %s", PathBuf);
if (!ReloadDLL()) return 1; if (!ReloadDLL()) return 1;
DWORD fileWatcherThreadId = 0; DWORD fileWatcherThreadId = 0;

View File

@@ -9,6 +9,8 @@ namespace
void Log(const char *format, ...) void Log(const char *format, ...)
{ {
va_list args; va_list args;
va_start(args, format);
bx::snprintf(LineBuffer, sizeof(LineBuffer), "%s\n", format); bx::snprintf(LineBuffer, sizeof(LineBuffer), "%s\n", format);
bx::printf(LineBuffer, args); bx::vprintf(LineBuffer, args);
va_end(args);
} }

View File

@@ -83,7 +83,9 @@ namespace Game
filePath.join(fileName); filePath.join(fileName);
bx::FileReader fileReader; bx::FileReader fileReader;
bgfx::ShaderHandle result = bgfx::createShader(loadMem(&fileReader, filePath.getCPtr())); const bgfx::Memory* mem = loadMem(&fileReader, filePath.getCPtr());
if (mem == nullptr) return {};
bgfx::ShaderHandle result = bgfx::createShader(mem);
return result; return result;
} }
} }
@@ -97,8 +99,8 @@ namespace Game
init.platformData.nwh = (void*)window; init.platformData.nwh = (void*)window;
init.platformData.ndt = nullptr; init.platformData.ndt = nullptr;
init.platformData.type = bgfx::NativeWindowHandleType::Default; init.platformData.type = bgfx::NativeWindowHandleType::Default;
init.resolution.width = 1920; init.resolution.width = State.WindowWidth;
init.resolution.height = 1080; init.resolution.height = State.WindowHeight;
init.resolution.reset = BGFX_RESET_VSYNC; init.resolution.reset = BGFX_RESET_VSYNC;
if (!bgfx::init(init)) if (!bgfx::init(init))
{ {
@@ -173,7 +175,6 @@ namespace Game
bgfx::setIndexBuffer(IndexBuffer); bgfx::setIndexBuffer(IndexBuffer);
bgfx::setState(state); bgfx::setState(state);
// Submit primitive for rendering to view 0.
bgfx::submit(0, Shader); bgfx::submit(0, Shader);
} }
bgfx::dbgTextPrintf(1, 1, 0x0F, "Time: %f", time); bgfx::dbgTextPrintf(1, 1, 0x0F, "Time: %f", time);