From 91c0e7b2a6feff663d6d1e04c4c0fb8d1172acc1 Mon Sep 17 00:00:00 2001 From: LandaMm Date: Wed, 1 Oct 2025 09:12:04 +0200 Subject: [PATCH 1/6] feat: avoid use of glew_static --- include/prelude.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/prelude.h b/include/prelude.h index 8912e37..42ab296 100644 --- a/include/prelude.h +++ b/include/prelude.h @@ -1,6 +1,6 @@ #ifndef PRELUDE_H_ #define PRELUDE_H_ -#define GLEW_STATIC +// #define GLEW_STATIC #include #include "SDL3/SDL.h" From 624186e4fb0622246dae7c88d1083c4913d4619f Mon Sep 17 00:00:00 2001 From: LandaMm Date: Wed, 1 Oct 2025 09:12:13 +0200 Subject: [PATCH 2/6] feat: use math defines (windows) --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index efbbf09..2578ad3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,6 @@ #include +#define _USE_MATH_DEFINES +#include #include #include #include From 618bfceddbf7169805e81c807c5bef621bae2098 Mon Sep 17 00:00:00 2001 From: LandaMm Date: Wed, 1 Oct 2025 09:12:23 +0200 Subject: [PATCH 3/6] feat: explicit conversion to string --- src/model.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model.cpp b/src/model.cpp index 05b4ea3..50e5d3d 100644 --- a/src/model.cpp +++ b/src/model.cpp @@ -215,7 +215,7 @@ Object Object::LoadFile(const std::string& filename) { iss >> mtlFile; std::filesystem::path fullPath = filename; std::filesystem::path mtlPath = fullPath.replace_filename(mtlFile); - obj.LoadMaterials(mtlPath); + obj.LoadMaterials(mtlPath.u8string()); std::cout << "loaded mtl at '" << mtlPath << "' with " << obj.m_materials.size() << " materials" << std::endl; break; From 9dbd600c572b7584228ee51935b99063f812fa55 Mon Sep 17 00:00:00 2001 From: LandaMm Date: Wed, 1 Oct 2025 09:12:33 +0200 Subject: [PATCH 4/6] feat: avoid use of glew_static (windows) --- src/prelude.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/prelude.cpp b/src/prelude.cpp index 251dc7c..867e650 100644 --- a/src/prelude.cpp +++ b/src/prelude.cpp @@ -6,7 +6,7 @@ #include #include "prelude.h" -#define GLEW_STATIC +// #define GLEW_STATIC #include #define SCREEN_WIDTH 1024 From 9b18f8a90231dd82a232f78c8a11530534558af7 Mon Sep 17 00:00:00 2001 From: LandaMm Date: Wed, 1 Oct 2025 09:12:57 +0200 Subject: [PATCH 5/6] feat: cmake config (windows) --- CMakeLists.txt | 64 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 488a5aa..cb4c017 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,29 +1,55 @@ -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.16) project(CodingGame LANGUAGES C CXX) -include(FetchContent) +# --- deps via vcpkg --- +# (vcpkg installs decide static vs shared; no "SDL3-shared" component needed) +find_package(SDL3 CONFIG REQUIRED) +find_package(OpenGL REQUIRED) +find_package(GLEW CONFIG REQUIRED) +find_package(glm CONFIG REQUIRED) -FetchContent_Declare( - glm - GIT_REPOSITORY https://github.com/g-truc/glm.git - GIT_TAG bf71a834948186f4097caa076cd2663c69a10e1e #refs/tags/1.0.1 +# --- exe --- +add_executable(CodingGame + src/prelude.cpp + src/file_manager.cpp + src/shader.cpp + src/block.cpp + src/vertex.cpp + src/texture.cpp + src/model.cpp + src/main.cpp ) -FetchContent_MakeAvailable(glm) +set_property(TARGET CodingGame PROPERTY CXX_STANDARD 17) +set_property(TARGET CodingGame PROPERTY CXX_STANDARD_REQUIRED ON) -find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3-shared) -find_package(OpenGL REQUIRED) -find_package(GLEW REQUIRED) +file(COPY ${CMAKE_SOURCE_DIR}/src/shaders DESTINATION ${CMAKE_BINARY_DIR}/) -# Add -ggdb to debug builds -set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb") -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb") +target_include_directories(CodingGame PRIVATE + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/contrib +) -add_executable(CodingGame src/prelude.cpp src/file_manager.cpp src/shader.cpp src/block.cpp src/vertex.cpp src/texture.cpp src/model.cpp src/main.cpp) +target_link_libraries(CodingGame PRIVATE + glm::glm + OpenGL::GL + SDL3::SDL3 # vcpkg’s SDL3 target + GLEW::GLEW +) -set_property(TARGET CodingGame PROPERTY CXX_STANDARD_REQUIRED 17) +# Debug flags per toolchain +if (MSVC) + target_compile_options(CodingGame PRIVATE $<$:/Zi>) + target_link_options(CodingGame PRIVATE $<$:/DEBUG:FULL>) +else() + target_compile_options(CodingGame PRIVATE $<$:-ggdb>) +endif() -file(COPY src/shaders DESTINATION ${CMAKE_BINARY_DIR}/) - -target_include_directories(CodingGame PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/contrib) -target_link_libraries(CodingGame PRIVATE SDL3::SDL3 OpenGL::GL GLEW::GLEW glm::glm) \ No newline at end of file +# --- copy runtime DLLs next to the exe on Windows --- +# (CMake 3.21+) +if (WIN32) + add_custom_command(TARGET CodingGame POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ $ + COMMAND_EXPAND_LISTS) +endif() From 8f21c8d141bf99c474b61979bf60f65b4dcc135f Mon Sep 17 00:00:00 2001 From: LandaMm Date: Wed, 1 Oct 2025 09:13:02 +0200 Subject: [PATCH 6/6] feat: windows build instructions --- WINDOWS.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 WINDOWS.md diff --git a/WINDOWS.md b/WINDOWS.md new file mode 100644 index 0000000..7d86ab3 --- /dev/null +++ b/WINDOWS.md @@ -0,0 +1,25 @@ + +# Setup VCPKG + +```console +git clone https://github.com/microsoft/vcpkg C:\vcpkg +C:\vcpkg\bootstrap-vcpkg.bat +# install deps for 64-bit Windows +C:\vcpkg\vcpkg install sdl3 glew glm --triplet x64-windows +``` + +# Configure + +```console +cmake -S . -B build ` + -G "Visual Studio 17 2022" -A x64 ` + -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake ` + -DVCPKG_TARGET_TRIPLET=x64-windows ` + -DCMAKE_BUILD_TYPE=Debug +``` + +# Build + +```console +cmake --build build --config Debug +```