diff --git a/CMakeLists.txt b/CMakeLists.txt index 087a442..ee47078 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,8 @@ include(FetchContent) # EnTT FetchContent_Declare( entt - URL https://github.com/skypjack/entt/archive/refs/tags/v3.12.0.tar.gz + SYSTEM + URL https://github.com/skypjack/entt/releases/download/v3.13.2/entt-v3.13.2.tar.gz ) FetchContent_MakeAvailable(entt) @@ -27,38 +28,42 @@ FetchContent_MakeAvailable(entt) # GLFW FetchContent_Declare( glfw - URL https://github.com/glfw/glfw/releases/download/3.3.8/glfw-3.3.8.zip + SYSTEM + URL https://github.com/glfw/glfw/releases/download/3.4/glfw-3.4.zip ) # nlohmann-json FetchContent_Declare( - json - URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz + json + SYSTEM + URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz ) FetchContent_MakeAvailable(json) -option(GLFW_BUILD_DOCS "" OFF) -option(GLFW_BUILD_EXAMPLES "" OFF) -option(GLFW_BUILD_TESTS "" OFF) -option(GLFW_INSTALL "" OFF) +set(GLFW_BUILD_DOCS OFF) +set(GLFW_BUILD_EXAMPLES OFF) +set(GLFW_BUILD_TESTS OFF) +set(GLFW_INSTALL OFF) FetchContent_MakeAvailable(glfw) # fx-gltf FetchContent_Declare( fx-gltf + SYSTEM URL https://github.com/jessey-git/fx-gltf/archive/refs/tags/v2.0.0.tar.gz ) -option(FX_GLTF_BUILD_TESTS "" OFF) -option(FX_GLTF_INSTALL "" OFF) +set(FX_GLTF_BUILD_TESTS OFF) +set(FX_GLTF_INSTALL OFF) FetchContent_MakeAvailable(fx-gltf) # glm FetchContent_Declare( glm - URL https://github.com/g-truc/glm/archive/refs/tags/0.9.9.8.tar.gz + SYSTEM + URL https://github.com/g-truc/glm/archive/refs/tags/1.0.1.tar.gz ) FetchContent_MakeAvailable(glm) @@ -66,7 +71,8 @@ FetchContent_MakeAvailable(glm) # glm FetchContent_Declare( spdlog - URL https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz + SYSTEM + URL https://github.com/gabime/spdlog/archive/refs/tags/v1.14.1.tar.gz ) FetchContent_MakeAvailable(spdlog) diff --git a/CMakePresets.json b/CMakePresets.json index 4eb2a56..d29c50e 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -35,7 +35,7 @@ ], "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic" + "CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -fdiagnostics-color=always" } } ] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70e4964..1d235e1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,42 +1,2 @@ -add_library(fever_engine - components/transform.cpp - core/graphics/framebuffer.cpp - core/graphics/image.cpp - core/graphics/material.cpp - core/graphics/mesh.cpp - core/camera.cpp - core/game_loop.cpp - core/glad.cpp - core/light.cpp - core/render.cpp - core/shader.cpp - core/time.cpp - input/input.cpp - scene/gltf.cpp - scene/gltf_loader.cpp - util/log.cpp - window/window.cpp -) - -target_compile_features(fever_engine PUBLIC cxx_std_20) -target_include_directories(fever_engine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - -target_link_libraries( - fever_engine PUBLIC - glad - glfw - EnTT::EnTT - pthread - spdlog - glm - fx-gltf::fx-gltf - nlohmann_json::nlohmann_json - stb -) - -add_executable(Fall-Fever - bin/main.cpp - bin/controller.cpp -) - -target_link_libraries(Fall-Fever PRIVATE fever_engine) +add_subdirectory(lib) +add_subdirectory(bin) diff --git a/src/bin/CMakeLists.txt b/src/bin/CMakeLists.txt new file mode 100644 index 0000000..fc0d1e4 --- /dev/null +++ b/src/bin/CMakeLists.txt @@ -0,0 +1,6 @@ +add_executable(Fall-Fever + main.cpp + controller.cpp +) + +target_link_libraries(Fall-Fever PRIVATE fever_core) diff --git a/src/bin/controller.cpp b/src/bin/controller.cpp index 1453e82..438555d 100644 --- a/src/bin/controller.cpp +++ b/src/bin/controller.cpp @@ -3,14 +3,15 @@ #include "components/transform.h" #include "core/camera.h" #include "core/light.h" +#include "spdlog/spdlog.h" #include "window/window.h" using namespace entt::literals; -Controller::Controller() +Controller::Controller(std::string_view path) { - std::filesystem::path document_path("ABeautifulGame.glb"); - // std::filesystem::path document_path("WaterBottle/glTF-Binary/WaterBottle.glb"); + spdlog::info("Open {}", path); + std::filesystem::path document_path(path); entt::hashed_string document_hash(document_path.string().c_str()); entt::resource gltf_document = diff --git a/src/bin/controller.h b/src/bin/controller.h index 96fc0b4..2c7d77c 100644 --- a/src/bin/controller.h +++ b/src/bin/controller.h @@ -4,13 +4,10 @@ #include #include -#include -#include -#include class Controller : public GameLoop { public: - Controller(); + Controller(std::string_view path); void update() override; }; diff --git a/src/bin/main.cpp b/src/bin/main.cpp index 66cbd73..677d907 100644 --- a/src/bin/main.cpp +++ b/src/bin/main.cpp @@ -2,11 +2,12 @@ #include "util/log.h" #include -#include #include -auto main() -> int +auto main(int argc, char *argv[]) -> int { + auto arguments = std::span(argv, argc); + Log::initialize(); // Initialize GLFW @@ -17,7 +18,7 @@ auto main() -> int { // Create controller - Controller controller; + Controller controller(arguments[1]); controller.run(); } diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt new file mode 100644 index 0000000..7271147 --- /dev/null +++ b/src/lib/CMakeLists.txt @@ -0,0 +1,35 @@ +add_library(fever_core + components/transform.cpp + core/graphics/framebuffer.cpp + core/graphics/image.cpp + core/graphics/material.cpp + core/graphics/mesh.cpp + core/camera.cpp + core/game_loop.cpp + core/glad.cpp + core/light.cpp + core/render.cpp + core/shader.cpp + core/time.cpp + input/input.cpp + scene/gltf.cpp + scene/gltf_loader.cpp + util/log.cpp + window/window.cpp +) + +target_compile_features(fever_core PUBLIC cxx_std_20) +target_include_directories(fever_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +target_link_libraries( + fever_core PUBLIC + glad + glfw + EnTT::EnTT + pthread + spdlog + glm::glm + fx-gltf::fx-gltf + nlohmann_json::nlohmann_json + stb +) diff --git a/src/components/color.h b/src/lib/components/color.h similarity index 100% rename from src/components/color.h rename to src/lib/components/color.h diff --git a/src/components/name.h b/src/lib/components/name.h similarity index 100% rename from src/components/name.h rename to src/lib/components/name.h diff --git a/src/components/relationship.h b/src/lib/components/relationship.h similarity index 100% rename from src/components/relationship.h rename to src/lib/components/relationship.h diff --git a/src/components/transform.cpp b/src/lib/components/transform.cpp similarity index 100% rename from src/components/transform.cpp rename to src/lib/components/transform.cpp diff --git a/src/components/transform.h b/src/lib/components/transform.h similarity index 96% rename from src/components/transform.h rename to src/lib/components/transform.h index 1eb7028..2a93eeb 100644 --- a/src/components/transform.h +++ b/src/lib/components/transform.h @@ -2,6 +2,8 @@ #include #include + +#define GLM_ENABLE_EXPERIMENTAL #include struct Transform diff --git a/src/core/camera.cpp b/src/lib/core/camera.cpp similarity index 100% rename from src/core/camera.cpp rename to src/lib/core/camera.cpp diff --git a/src/core/camera.h b/src/lib/core/camera.h similarity index 100% rename from src/core/camera.h rename to src/lib/core/camera.h diff --git a/src/core/game_loop.cpp b/src/lib/core/game_loop.cpp similarity index 100% rename from src/core/game_loop.cpp rename to src/lib/core/game_loop.cpp diff --git a/src/core/game_loop.h b/src/lib/core/game_loop.h similarity index 100% rename from src/core/game_loop.h rename to src/lib/core/game_loop.h diff --git a/src/core/glad.cpp b/src/lib/core/glad.cpp similarity index 100% rename from src/core/glad.cpp rename to src/lib/core/glad.cpp diff --git a/src/core/glad.h b/src/lib/core/glad.h similarity index 100% rename from src/core/glad.h rename to src/lib/core/glad.h diff --git a/src/core/graphics/framebuffer.cpp b/src/lib/core/graphics/framebuffer.cpp similarity index 100% rename from src/core/graphics/framebuffer.cpp rename to src/lib/core/graphics/framebuffer.cpp diff --git a/src/core/graphics/framebuffer.h b/src/lib/core/graphics/framebuffer.h similarity index 100% rename from src/core/graphics/framebuffer.h rename to src/lib/core/graphics/framebuffer.h diff --git a/src/core/graphics/image.cpp b/src/lib/core/graphics/image.cpp similarity index 100% rename from src/core/graphics/image.cpp rename to src/lib/core/graphics/image.cpp diff --git a/src/core/graphics/image.h b/src/lib/core/graphics/image.h similarity index 100% rename from src/core/graphics/image.h rename to src/lib/core/graphics/image.h diff --git a/src/core/graphics/material.cpp b/src/lib/core/graphics/material.cpp similarity index 100% rename from src/core/graphics/material.cpp rename to src/lib/core/graphics/material.cpp diff --git a/src/core/graphics/material.h b/src/lib/core/graphics/material.h similarity index 100% rename from src/core/graphics/material.h rename to src/lib/core/graphics/material.h diff --git a/src/core/graphics/mesh.cpp b/src/lib/core/graphics/mesh.cpp similarity index 100% rename from src/core/graphics/mesh.cpp rename to src/lib/core/graphics/mesh.cpp diff --git a/src/core/graphics/mesh.h b/src/lib/core/graphics/mesh.h similarity index 100% rename from src/core/graphics/mesh.h rename to src/lib/core/graphics/mesh.h diff --git a/src/core/light.cpp b/src/lib/core/light.cpp similarity index 100% rename from src/core/light.cpp rename to src/lib/core/light.cpp diff --git a/src/core/light.h b/src/lib/core/light.h similarity index 100% rename from src/core/light.h rename to src/lib/core/light.h diff --git a/src/core/render.cpp b/src/lib/core/render.cpp similarity index 100% rename from src/core/render.cpp rename to src/lib/core/render.cpp diff --git a/src/core/render.h b/src/lib/core/render.h similarity index 100% rename from src/core/render.h rename to src/lib/core/render.h diff --git a/src/core/shader.cpp b/src/lib/core/shader.cpp similarity index 100% rename from src/core/shader.cpp rename to src/lib/core/shader.cpp diff --git a/src/core/shader.h b/src/lib/core/shader.h similarity index 100% rename from src/core/shader.h rename to src/lib/core/shader.h diff --git a/src/core/time.cpp b/src/lib/core/time.cpp similarity index 100% rename from src/core/time.cpp rename to src/lib/core/time.cpp diff --git a/src/core/time.h b/src/lib/core/time.h similarity index 100% rename from src/core/time.h rename to src/lib/core/time.h diff --git a/src/input/input.cpp b/src/lib/input/input.cpp similarity index 100% rename from src/input/input.cpp rename to src/lib/input/input.cpp diff --git a/src/input/input.h b/src/lib/input/input.h similarity index 100% rename from src/input/input.h rename to src/lib/input/input.h diff --git a/src/post_processing/post_processing.cpp b/src/lib/post_processing/post_processing.cpp similarity index 100% rename from src/post_processing/post_processing.cpp rename to src/lib/post_processing/post_processing.cpp diff --git a/src/post_processing/post_processing.h b/src/lib/post_processing/post_processing.h similarity index 100% rename from src/post_processing/post_processing.h rename to src/lib/post_processing/post_processing.h diff --git a/src/scene/gltf.cpp b/src/lib/scene/gltf.cpp similarity index 100% rename from src/scene/gltf.cpp rename to src/lib/scene/gltf.cpp diff --git a/src/scene/gltf.h b/src/lib/scene/gltf.h similarity index 100% rename from src/scene/gltf.h rename to src/lib/scene/gltf.h diff --git a/src/scene/gltf_loader.cpp b/src/lib/scene/gltf_loader.cpp similarity index 100% rename from src/scene/gltf_loader.cpp rename to src/lib/scene/gltf_loader.cpp diff --git a/src/scene/gltf_loader.h b/src/lib/scene/gltf_loader.h similarity index 100% rename from src/scene/gltf_loader.h rename to src/lib/scene/gltf_loader.h diff --git a/src/scene/scene.cpp b/src/lib/scene/scene.cpp similarity index 100% rename from src/scene/scene.cpp rename to src/lib/scene/scene.cpp diff --git a/src/scene/scene.h b/src/lib/scene/scene.h similarity index 100% rename from src/scene/scene.h rename to src/lib/scene/scene.h diff --git a/src/util/log.cpp b/src/lib/util/log.cpp similarity index 100% rename from src/util/log.cpp rename to src/lib/util/log.cpp diff --git a/src/util/log.h b/src/lib/util/log.h similarity index 100% rename from src/util/log.h rename to src/lib/util/log.h diff --git a/src/window/window.cpp b/src/lib/window/window.cpp similarity index 96% rename from src/window/window.cpp rename to src/lib/window/window.cpp index be1b13a..8991a05 100644 --- a/src/window/window.cpp +++ b/src/lib/window/window.cpp @@ -42,6 +42,12 @@ Window::Window(entt::dispatcher& event_dispatcher) : event_dispatcher(event_disp glfwSetFramebufferSizeCallback(glfw_window.get(), framebuffer_size_callback); init_glad(); + + { + int width, height; + glfwGetFramebufferSize(glfw_window.get(), &width, &height); + glViewport(0, 0, width, height); + } } void Window::glfw_error_callback(int error, char const* description) diff --git a/src/window/window.h b/src/lib/window/window.h similarity index 100% rename from src/window/window.h rename to src/lib/window/window.h