Compare commits
1 Commits
windows
...
67ba331ba5
Author | SHA1 | Date | |
---|---|---|---|
67ba331ba5 |
@ -1,55 +1,29 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.11)
|
||||||
project(CodingGame LANGUAGES C CXX)
|
project(CodingGame LANGUAGES C CXX)
|
||||||
|
|
||||||
# --- deps via vcpkg ---
|
include(FetchContent)
|
||||||
# (vcpkg installs decide static vs shared; no "SDL3-shared" component needed)
|
|
||||||
find_package(SDL3 CONFIG REQUIRED)
|
FetchContent_Declare(
|
||||||
|
glm
|
||||||
|
GIT_REPOSITORY https://github.com/g-truc/glm.git
|
||||||
|
GIT_TAG bf71a834948186f4097caa076cd2663c69a10e1e #refs/tags/1.0.1
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(glm)
|
||||||
|
|
||||||
|
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3-shared)
|
||||||
find_package(OpenGL REQUIRED)
|
find_package(OpenGL REQUIRED)
|
||||||
find_package(GLEW CONFIG REQUIRED)
|
find_package(GLEW REQUIRED)
|
||||||
find_package(glm CONFIG REQUIRED)
|
|
||||||
|
|
||||||
# --- exe ---
|
# Add -ggdb to debug builds
|
||||||
add_executable(CodingGame
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb")
|
||||||
src/prelude.cpp
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb")
|
||||||
src/file_manager.cpp
|
|
||||||
src/shader.cpp
|
|
||||||
src/block.cpp
|
|
||||||
src/vertex.cpp
|
|
||||||
src/texture.cpp
|
|
||||||
src/model.cpp
|
|
||||||
src/main.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
set_property(TARGET CodingGame PROPERTY CXX_STANDARD 17)
|
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)
|
||||||
set_property(TARGET CodingGame PROPERTY CXX_STANDARD_REQUIRED ON)
|
|
||||||
|
|
||||||
file(COPY ${CMAKE_SOURCE_DIR}/src/shaders DESTINATION ${CMAKE_BINARY_DIR}/)
|
set_property(TARGET CodingGame PROPERTY CXX_STANDARD_REQUIRED 17)
|
||||||
|
|
||||||
target_include_directories(CodingGame PRIVATE
|
file(COPY src/shaders DESTINATION ${CMAKE_BINARY_DIR}/)
|
||||||
${CMAKE_SOURCE_DIR}/include
|
|
||||||
${CMAKE_SOURCE_DIR}/contrib
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(CodingGame PRIVATE
|
target_include_directories(CodingGame PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/contrib)
|
||||||
glm::glm
|
target_link_libraries(CodingGame PRIVATE SDL3::SDL3 OpenGL::GL GLEW::GLEW glm::glm)
|
||||||
OpenGL::GL
|
|
||||||
SDL3::SDL3 # vcpkg’s SDL3 target
|
|
||||||
GLEW::GLEW
|
|
||||||
)
|
|
||||||
|
|
||||||
# Debug flags per toolchain
|
|
||||||
if (MSVC)
|
|
||||||
target_compile_options(CodingGame PRIVATE $<$<CONFIG:Debug>:/Zi>)
|
|
||||||
target_link_options(CodingGame PRIVATE $<$<CONFIG:Debug>:/DEBUG:FULL>)
|
|
||||||
else()
|
|
||||||
target_compile_options(CodingGame PRIVATE $<$<CONFIG:Debug>:-ggdb>)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# --- 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
|
|
||||||
$<TARGET_RUNTIME_DLLS:CodingGame> $<TARGET_FILE_DIR:CodingGame>
|
|
||||||
COMMAND_EXPAND_LISTS)
|
|
||||||
endif()
|
|
25
WINDOWS.md
25
WINDOWS.md
@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
# 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
|
|
||||||
```
|
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef PRELUDE_H_
|
#ifndef PRELUDE_H_
|
||||||
#define PRELUDE_H_
|
#define PRELUDE_H_
|
||||||
// #define GLEW_STATIC
|
#define GLEW_STATIC
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#include "SDL3/SDL.h"
|
#include "SDL3/SDL.h"
|
||||||
|
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#define _USE_MATH_DEFINES
|
|
||||||
#include <cmath>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/ext/quaternion_geometric.hpp>
|
#include <glm/ext/quaternion_geometric.hpp>
|
||||||
|
@ -215,7 +215,7 @@ Object Object::LoadFile(const std::string& filename) {
|
|||||||
iss >> mtlFile;
|
iss >> mtlFile;
|
||||||
std::filesystem::path fullPath = filename;
|
std::filesystem::path fullPath = filename;
|
||||||
std::filesystem::path mtlPath = fullPath.replace_filename(mtlFile);
|
std::filesystem::path mtlPath = fullPath.replace_filename(mtlFile);
|
||||||
obj.LoadMaterials(mtlPath.u8string());
|
obj.LoadMaterials(mtlPath);
|
||||||
std::cout << "loaded mtl at '" << mtlPath << "' with "
|
std::cout << "loaded mtl at '" << mtlPath << "' with "
|
||||||
<< obj.m_materials.size() << " materials" << std::endl;
|
<< obj.m_materials.size() << " materials" << std::endl;
|
||||||
break;
|
break;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "prelude.h"
|
#include "prelude.h"
|
||||||
|
|
||||||
// #define GLEW_STATIC
|
#define GLEW_STATIC
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
#define SCREEN_WIDTH 1024
|
#define SCREEN_WIDTH 1024
|
||||||
|
Reference in New Issue
Block a user