finally fix laptop build
This commit is contained in:
@@ -25,6 +25,7 @@ add_subdirectory("${CMAKE_SOURCE_DIR}/dependency/minidef")
|
|||||||
# Engine
|
# Engine
|
||||||
file(GLOB_RECURSE sources_engine engine/*.cpp engine/*.h)
|
file(GLOB_RECURSE sources_engine engine/*.cpp engine/*.h)
|
||||||
add_executable(PuzGameEngine ${sources_engine})
|
add_executable(PuzGameEngine ${sources_engine})
|
||||||
|
target_compile_definitions(PuzGameEngine PUBLIC "_AMD64_")
|
||||||
set_property(TARGET PuzGameEngine PROPERTY CXX_STANDARD 17)
|
set_property(TARGET PuzGameEngine PROPERTY CXX_STANDARD 17)
|
||||||
target_include_directories(PuzGameEngine PUBLIC dependency/tracy/public/)
|
target_include_directories(PuzGameEngine PUBLIC dependency/tracy/public/)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#include "bx/filepath.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@@ -14,9 +15,7 @@
|
|||||||
#include "Shared.h"
|
#include "Shared.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
// #define VISUAL_STUDIO
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
#ifdef VISUAL_STUDIO
|
|
||||||
constexpr const char* DLLPath = "PuzGame.dll";
|
constexpr const char* DLLPath = "PuzGame.dll";
|
||||||
constexpr const wchar_t* DLLWatch = L"PuzGame2.dll";
|
constexpr const wchar_t* DLLWatch = L"PuzGame2.dll";
|
||||||
#else
|
#else
|
||||||
@@ -180,40 +179,52 @@ bool ReloadDLL()
|
|||||||
{
|
{
|
||||||
FreeLibrary(DevData.GameLib);
|
FreeLibrary(DevData.GameLib);
|
||||||
}
|
}
|
||||||
#ifdef VISUAL_STUDIO
|
|
||||||
if (!CopyFile("PuzGame2.dll", "PuzGame.dll", false))
|
char exePath[1024];
|
||||||
{
|
GetModuleFileName(nullptr, exePath, BX_COUNTOF(exePath));
|
||||||
printf("Failed to copy game DLL!\n");
|
bx::FilePath exeFilePath{exePath};
|
||||||
return false;
|
bx::FilePath exeDir{exeFilePath.getPath()};
|
||||||
}
|
bx::FilePath libPath = exeDir;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
libPath.join("PuzGame.dll");
|
||||||
#else
|
#else
|
||||||
if (!CopyFile("cmake-build\\libPuzGame2.dll", "cmake-build\\libPuzGame.dll", false))
|
libPath.join("libPuzGame.dll");
|
||||||
|
#endif
|
||||||
|
bx::FilePath lib2Path = exeDir;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
lib2Path.join("PuzGame2.dll");
|
||||||
|
#else
|
||||||
|
lib2Path.join("libPuzGame2.dll");
|
||||||
|
#endif
|
||||||
|
if (!CopyFile(lib2Path.getCPtr(), libPath.getCPtr(), false))
|
||||||
{
|
{
|
||||||
printf("Failed to copy game DLL!\n");
|
DWORD err = GetLastError();
|
||||||
|
printf("[%lu] Failed to copy game DLL from %s to %s!\n", err, libPath.getCPtr(), lib2Path.getCPtr());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
HMODULE gameLibReloaded = LoadLibraryEx(DLLPath, NULL, 0);
|
HMODULE gameLibReloaded = LoadLibraryEx(DLLPath, NULL, 0);
|
||||||
if (gameLibReloaded == NULL)
|
if (gameLibReloaded == NULL)
|
||||||
{
|
{
|
||||||
printf("Failed to load game DLL from %s!\n", DLLPath);
|
DWORD err = GetLastError();
|
||||||
|
printf("[%lu] Failed to load game DLL from %s!\n", err, DLLPath);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DevData.GameLib = gameLibReloaded;
|
DevData.GameLib = gameLibReloaded;
|
||||||
|
|
||||||
#ifdef VISUAL_STUDIO
|
#ifdef _MSC_VER
|
||||||
Startup StartupReloaded = (Startup)GetProcAddress(DevData.GameLib, "?Setup@Game@@YAXPEAX@Z");
|
Startup StartupReloaded = (Startup)GetProcAddress(DevData.GameLib, "?Setup@Game@@YAXAEAUSharedData@@@Z");
|
||||||
#else
|
#else
|
||||||
Startup StartupReloaded = (Startup)GetProcAddress(DevData.GameLib, "_ZN4Game5SetupER10SharedData");
|
Startup StartupReloaded = (Startup)GetProcAddress(DevData.GameLib, "_ZN4Game5SetupER10SharedData");
|
||||||
#endif
|
#endif
|
||||||
if (StartupReloaded == NULL)
|
if (StartupReloaded == NULL)
|
||||||
{
|
{
|
||||||
printf("Failed to load startup function from game DLL!\n");
|
DWORD err = GetLastError();
|
||||||
|
printf("[%lu] Failed to load startup function from game DLL!\n", err);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VISUAL_STUDIO
|
#ifdef _MSC_VER
|
||||||
Update UpdateReloaded = (Update)GetProcAddress(DevData.GameLib, "?Update@Game@@YAXXZ");
|
Update UpdateReloaded = (Update)GetProcAddress(DevData.GameLib, "?Update@Game@@YAXXZ");
|
||||||
#else
|
#else
|
||||||
Update UpdateReloaded = (Update)GetProcAddress(DevData.GameLib, "_ZN4Game6UpdateEv");
|
Update UpdateReloaded = (Update)GetProcAddress(DevData.GameLib, "_ZN4Game6UpdateEv");
|
||||||
@@ -224,7 +235,7 @@ bool ReloadDLL()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VISUAL_STUDIO
|
#ifdef _MSC_VER
|
||||||
Shutdown ShutdownReloaded = (Shutdown)GetProcAddress(DevData.GameLib, "?Shutdown@Game@@YAXXZ");
|
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");
|
||||||
|
|||||||
@@ -49,8 +49,9 @@ namespace Game
|
|||||||
long fileSize = ftell(file);
|
long fileSize = ftell(file);
|
||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
|
|
||||||
void* rawMem = AllocateScratch(fileSize + 1);
|
long fileSizeX = appendZero ? fileSize + 1 : fileSize;
|
||||||
const bgfx::Memory* mem = bgfx::makeRef(rawMem, fileSize + 1);
|
void* rawMem = AllocateScratch(fileSizeX);
|
||||||
|
const bgfx::Memory* mem = bgfx::makeRef(rawMem, fileSizeX);
|
||||||
fread(mem->data, 1, fileSize, file);
|
fread(mem->data, 1, fileSize, file);
|
||||||
if (appendZero)
|
if (appendZero)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user