setup
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -7,3 +7,6 @@
|
|||||||
[submodule "src/dependency/bimg"]
|
[submodule "src/dependency/bimg"]
|
||||||
path = src/dependency/bimg
|
path = src/dependency/bimg
|
||||||
url = https://github.com/bkaradzic/bimg
|
url = https://github.com/bkaradzic/bimg
|
||||||
|
[submodule "src/dependency/bgfx.cmake"]
|
||||||
|
path = src/dependency/bgfx.cmake
|
||||||
|
url = https://github.com/bkaradzic/bgfx.cmake
|
||||||
|
|||||||
@@ -1,30 +1,31 @@
|
|||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(PuzGameProj)
|
project(PuzGameProj)
|
||||||
|
|
||||||
|
if (MSVC)
|
||||||
|
|
||||||
|
else()
|
||||||
|
add_compile_options(-g -gcodeview)
|
||||||
|
add_link_options(-fuse-ld=lld -g -Wl,--pdb=)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Engine
|
||||||
file(GLOB_RECURSE sources_engine engine/*.cpp engine/*.h)
|
file(GLOB_RECURSE sources_engine engine/*.cpp engine/*.h)
|
||||||
#file(GLOB_RECURSE data resources/xyz)
|
add_executable(PuzGameEngine ${sources_engine})
|
||||||
|
set_property(TARGET PuzGameEngine PROPERTY CXX_STANDARD 17)
|
||||||
add_executable(PuzGame ${sources_engine})
|
|
||||||
#target_compile_options(PuzGame PUBLIC xyz)
|
|
||||||
set_property(TARGET PuzGame PROPERTY CXX_STANDARD 17)
|
|
||||||
#file(COPY ${data} DESTINATION resources)
|
#file(COPY ${data} DESTINATION resources)
|
||||||
|
|
||||||
# BGFX
|
#target_compile_options(PuzGameEngine PUBLIC xyz)
|
||||||
add_library(bx STATIC IMPORTED)
|
#file(GLOB_RECURSE data resources/xyz)
|
||||||
add_library(bimg STATIC IMPORTED)
|
|
||||||
add_library(bgfx STATIC IMPORTED)
|
# Game
|
||||||
set_target_properties(bx PROPERTIES
|
file(GLOB_RECURSE sources_game game/*.cpp game/*.h)
|
||||||
IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/dependency/bgfx/.build/win64_vs2022/bin/bxDebug.lib"
|
add_library(PuzGame SHARED ${sources_game})
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/dependency/bx/include/"
|
set_property(TARGET PuzGame PROPERTY CXX_STANDARD 17)
|
||||||
)
|
|
||||||
set_target_properties(bimg PROPERTIES
|
SET(BGFX_BUILD_TOOLS OFF)
|
||||||
IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/dependency/bgfx/.build/win64_vs2022/bin/bimgDebug.lib"
|
SET(BGFX_BUILD_EXAMPLES OFF)
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/dependency/bimg/include/"
|
add_subdirectory("${CMAKE_SOURCE_DIR}/dependency/bgfx.cmake")
|
||||||
)
|
|
||||||
set_target_properties(bgfx PROPERTIES
|
|
||||||
IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/dependency/bgfx/.build/win64_vs2022/bin/bgfxDebug.lib"
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/dependency/bgfx/include/"
|
|
||||||
)
|
|
||||||
target_link_libraries(PuzGame bx bimg bgfx)
|
target_link_libraries(PuzGame bx bimg bgfx)
|
||||||
target_compile_definitions(PuzGame PUBLIC BX_CONFIG_DEBUG=1)
|
target_link_libraries(PuzGameEngine bx)
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
cmake --build cmake-build && start ./cmake-build/PuzGame.exe
|
cmake --build cmake-build && .\cmake-build\PuzGameEngine.exe
|
||||||
|
|||||||
1
src/build.ps1
Normal file
1
src/build.ps1
Normal file
@@ -0,0 +1 @@
|
|||||||
|
cmake --build cmake-build && start ./cmake-build/PuzGameEngine.exe
|
||||||
Submodule src/dependency/bgfx deleted from b92787168f
1
src/dependency/bgfx.cmake
Submodule
1
src/dependency/bgfx.cmake
Submodule
Submodule src/dependency/bgfx.cmake added at cf79284dad
Submodule src/dependency/bimg deleted from c5c7b6e187
Submodule src/dependency/bx deleted from 8e9a998357
@@ -1,11 +1,115 @@
|
|||||||
#include <bx/bx.h>
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <Windows.h>
|
||||||
|
#undef min
|
||||||
|
#undef max
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <libloaderapi.h>
|
||||||
|
#include <bx/string.h>
|
||||||
|
|
||||||
|
//#define VISUAL_STUDIO
|
||||||
|
|
||||||
|
typedef void (*Startup)(void*);
|
||||||
|
typedef void (*Update)();
|
||||||
|
|
||||||
|
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
|
||||||
|
{
|
||||||
|
LRESULT Res = 0;
|
||||||
|
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
Res = DefWindowProcW(hwnd, message, wparam, lparam);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Res;
|
||||||
|
}
|
||||||
|
|
||||||
|
HWND InitWindow()
|
||||||
|
{
|
||||||
|
uint32_t startWidth = 1920;
|
||||||
|
uint32_t startHeight = 1080;
|
||||||
|
HINSTANCE instance = (HINSTANCE)GetModuleHandle(NULL);
|
||||||
|
|
||||||
|
WNDCLASSEXW wnd;
|
||||||
|
bx::memSet(&wnd, 0, sizeof(wnd));
|
||||||
|
wnd.cbSize = sizeof(wnd);
|
||||||
|
wnd.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
|
wnd.lpfnWndProc = WndProc;
|
||||||
|
wnd.hInstance = instance;
|
||||||
|
wnd.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
wnd.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||||
|
wnd.lpszClassName = L"EngineWin";
|
||||||
|
wnd.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
|
||||||
|
RegisterClassExW(&wnd);
|
||||||
|
|
||||||
|
HWND window = CreateWindowExW(0, L"EngineWin", L"PuzGame", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, startWidth, startHeight, NULL, NULL, instance, 0);
|
||||||
|
if (window == NULL)
|
||||||
|
{
|
||||||
|
DWORD err = GetLastError();
|
||||||
|
printf("Failed to create window: %#x!\n", err);
|
||||||
|
}
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
while (true)
|
HWND window = InitWindow();
|
||||||
|
if (window == NULL) return 1;
|
||||||
|
|
||||||
|
char Buf[512];
|
||||||
|
GetCurrentDirectoryA(sizeof(Buf), Buf);
|
||||||
|
|
||||||
|
#ifdef VISUAL_STUDIO
|
||||||
|
const char* dllPath = "Debug/PuzGame.dll";
|
||||||
|
#else
|
||||||
|
const char* dllPath = "libPuzGame.dll";
|
||||||
|
#endif
|
||||||
|
HMODULE gameLibModule = LoadLibraryEx(dllPath, NULL, 0);
|
||||||
|
if (gameLibModule == NULL)
|
||||||
{
|
{
|
||||||
printf("a\n");
|
printf("Failed to load game DLL from %s!", dllPath);
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef VISUAL_STUDIO
|
||||||
|
Startup StartFunc = (Startup)GetProcAddress(gameLibModule, "?Setup@Game@@YAXPEAX@Z");
|
||||||
|
#else
|
||||||
|
Startup StartFunc = (Startup)GetProcAddress(gameLibModule, "_ZN4Game5SetupEPv");
|
||||||
|
#endif
|
||||||
|
if (StartFunc == NULL)
|
||||||
|
{
|
||||||
|
printf("Failed to load startup function from game DLL!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef VISUAL_STUDIO
|
||||||
|
Update UpdateFunc = (Update)GetProcAddress(gameLibModule, "?Update@Game@@YAXXZ");
|
||||||
|
#else
|
||||||
|
Update UpdateFunc = (Update)GetProcAddress(gameLibModule, "_ZN4Game6UpdateEv");
|
||||||
|
#endif
|
||||||
|
if (UpdateFunc == NULL)
|
||||||
|
{
|
||||||
|
printf("Failed to load update function from game DLL!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Loaded Game DLL successfully!\n");
|
||||||
|
|
||||||
|
StartFunc(window);
|
||||||
|
bool isRunning = true;
|
||||||
|
while (isRunning)
|
||||||
|
{
|
||||||
|
MSG Message;
|
||||||
|
BOOL MessageResult = GetMessage(&Message, 0, 0, 0);
|
||||||
|
if (MessageResult > 0)
|
||||||
|
{
|
||||||
|
TranslateMessage(&Message);
|
||||||
|
DispatchMessageW(&Message);
|
||||||
|
}
|
||||||
|
// UpdateFunc();
|
||||||
|
// Sleep(1000.0);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/game/Log.cpp
Normal file
10
src/game/Log.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include "Log.h"
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
void Log(const char* text)
|
||||||
|
{
|
||||||
|
printf("%s\n", text);
|
||||||
|
}
|
||||||
|
}
|
||||||
6
src/game/Log.h
Normal file
6
src/game/Log.h
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
void Log(const char* text);
|
||||||
|
}
|
||||||
25
src/game/Setup.cpp
Normal file
25
src/game/Setup.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#include "Setup.h"
|
||||||
|
#include "Log.h"
|
||||||
|
#include <bgfx/bgfx.h>
|
||||||
|
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
void Setup(void* window)
|
||||||
|
{
|
||||||
|
Log("Setup");
|
||||||
|
bgfx::Init init;
|
||||||
|
init.type = bgfx::RendererType::Direct3D12;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
Log("Update");
|
||||||
|
}
|
||||||
|
}
|
||||||
9
src/game/Setup.h
Normal file
9
src/game/Setup.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define DLLEXPORT __declspec(dllexport)
|
||||||
|
|
||||||
|
namespace Game
|
||||||
|
{
|
||||||
|
DLLEXPORT void Setup(void* window);
|
||||||
|
DLLEXPORT void Update();
|
||||||
|
}
|
||||||
4
src/setup-vs.bat
Normal file
4
src/setup-vs.bat
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
cd dependency/bgfx.cmake
|
||||||
|
cmake -G "Visual Studio 17 2022" -S . -B cmake-build-vs -DBGFX_BUILD_TOOLS=OFF -DBGFX_BUILD_EXAMPLES=OFF
|
||||||
|
cd ..\..
|
||||||
|
cmake -G "Visual Studio 17 2022" -S . -B cmake-build-vs -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
cd dependency\bgfx
|
cd dependency/bgfx.cmake
|
||||||
..\bx\tools\bin\windows\genie vs2022
|
cmake -G "Ninja" -S . -B cmake-build -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_COMPILER="clang++.exe" -DBGFX_BUILD_TOOLS=OFF -DBGFX_BUILD_EXAMPLES=OFF
|
||||||
cd ..\..
|
cd ..\..
|
||||||
cmake -G "Ninja" -S . -B cmake-build -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
cmake -G "Ninja" -S . -B cmake-build -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||||
|
|||||||
BIN
tools/remedy-session.rdbg
Normal file
BIN
tools/remedy-session.rdbg
Normal file
Binary file not shown.
Reference in New Issue
Block a user