Compare commits
6 Commits
1d1d23a148
...
8f21c8d141
Author | SHA1 | Date | |
---|---|---|---|
8f21c8d141 | |||
9b18f8a902 | |||
9dbd600c57 | |||
618bfceddb | |||
624186e4fb | |||
91c0e7b2a6 |
@ -1,29 +1,55 @@
|
|||||||
cmake_minimum_required(VERSION 3.11)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
project(CodingGame LANGUAGES C CXX)
|
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(
|
# --- exe ---
|
||||||
glm
|
add_executable(CodingGame
|
||||||
GIT_REPOSITORY https://github.com/g-truc/glm.git
|
src/prelude.cpp
|
||||||
GIT_TAG bf71a834948186f4097caa076cd2663c69a10e1e #refs/tags/1.0.1
|
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)
|
file(COPY ${CMAKE_SOURCE_DIR}/src/shaders DESTINATION ${CMAKE_BINARY_DIR}/)
|
||||||
find_package(OpenGL REQUIRED)
|
|
||||||
find_package(GLEW REQUIRED)
|
|
||||||
|
|
||||||
# Add -ggdb to debug builds
|
target_include_directories(CodingGame PRIVATE
|
||||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb")
|
${CMAKE_SOURCE_DIR}/include
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb")
|
${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 $<$<CONFIG:Debug>:/Zi>)
|
||||||
|
target_link_options(CodingGame PRIVATE $<$<CONFIG:Debug>:/DEBUG:FULL>)
|
||||||
|
else()
|
||||||
|
target_compile_options(CodingGame PRIVATE $<$<CONFIG:Debug>:-ggdb>)
|
||||||
|
endif()
|
||||||
|
|
||||||
file(COPY src/shaders DESTINATION ${CMAKE_BINARY_DIR}/)
|
# --- copy runtime DLLs next to the exe on Windows ---
|
||||||
|
# (CMake 3.21+)
|
||||||
target_include_directories(CodingGame PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/contrib)
|
if (WIN32)
|
||||||
target_link_libraries(CodingGame PRIVATE SDL3::SDL3 OpenGL::GL GLEW::GLEW glm::glm)
|
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
Normal file
25
WINDOWS.md
Normal file
@ -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
|
||||||
|
```
|
@ -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,4 +1,6 @@
|
|||||||
#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);
|
obj.LoadMaterials(mtlPath.u8string());
|
||||||
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