From 9ebdb74e22a171bed72c00814e38ca6c8d3fb026 Mon Sep 17 00:00:00 2001 From: Derek Christ Date: Tue, 11 Oct 2022 13:31:46 +0200 Subject: [PATCH] Add GLFW as submodule --- .gitmodules | 3 +++ CMakeLists.txt | 3 +-- CMakePresets.json | 1 - lib/CMakeLists.txt | 12 ++++++++---- lib/glfw | 1 + src/Controller.cpp | 2 +- src/Window.cpp | 14 ++++++++++---- 7 files changed, 24 insertions(+), 12 deletions(-) create mode 160000 lib/glfw diff --git a/.gitmodules b/.gitmodules index 1da9628..7a38a30 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "lib/tinygltf"] path = lib/tinygltf url = https://github.com/syoyo/tinygltf.git +[submodule "lib/glfw"] + path = lib/glfw + url = https://github.com/glfw/glfw.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 50c9d30..36ad72a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14) +cmake_minimum_required(VERSION 3.20) project( Fall-Fever @@ -9,7 +9,6 @@ project( set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -find_package(glfw3 REQUIRED) find_package(glm REQUIRED) find_package(spdlog REQUIRED) diff --git a/CMakePresets.json b/CMakePresets.json index 61b597b..525d427 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -12,7 +12,6 @@ "warnings": { "dev": true, "deprecated": true, - "uninitialized": true, "unusedCli": true, "systemVars": false }, diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index ef50766..08c2f2a 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,9 +1,13 @@ option(SPDLOG_NO_EXCEPTIONS "" ON) -set(TINYGLTF_HEADER_ONLY OFF CACHE INTERNAL "" FORCE) -set(TINYGLTF_INSTALL OFF CACHE INTERNAL "" FORCE) -set(TINYGLTF_NOEXCEPTION OFF CACHE INTERNAL "" FORCE) - add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glad) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/entt) + +option(TINYGLTF_HEADER_ONLY "" OFF) +option(TINYGLTF_INSTALL "" OFF) +option(TINYGLTF_NOEXCEPTION "" ON) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tinygltf) + +option(GLFW_BUILD_DOCS "" OFF) +option(GLFW_INSTALL "" OFF) +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glfw) diff --git a/lib/glfw b/lib/glfw new file mode 160000 index 0000000..dd8a678 --- /dev/null +++ b/lib/glfw @@ -0,0 +1 @@ +Subproject commit dd8a678a66f1967372e5a5e3deac41ebf65ee127 diff --git a/src/Controller.cpp b/src/Controller.cpp index b6ce73d..f443f45 100644 --- a/src/Controller.cpp +++ b/src/Controller.cpp @@ -25,7 +25,7 @@ Controller::Controller() std::string err; std::string warn; - bool ret = loader.LoadASCIIFromFile(&m_model, &err, &warn, "glTF/ABeautifulGame.gltf"); + bool ret = loader.LoadASCIIFromFile(&m_model, &err, &warn, "glTF/DamagedHelmet.gltf"); // bool ret = loader.LoadASCIIFromFile(&m_model, &err, &warn, "minimal.gltf"); if (!warn.empty()) { diff --git a/src/Window.cpp b/src/Window.cpp index 241200d..d9cdcb8 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -8,6 +8,9 @@ Window::Window() { + // Hint Wayland preference to GLFW + glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND); + // Initialize GLFW if (glfwInit() == 0) { std::terminate(); @@ -31,6 +34,7 @@ Window::Window() m_glfw_window = std::shared_ptr( glfwCreateWindow(static_cast(m_width), static_cast(m_height), "OpenGL", nullptr, nullptr), [](GLFWwindow *window) { glfwDestroyWindow(window); }); + if (!m_glfw_window) { Log::logger().critical("Failed to create window"); } @@ -56,7 +60,7 @@ Window::Window() } #ifndef NDEBUG - Log::logger().debug("OpenGL version: {}", reinterpret_cast(glGetString(GL_VERSION))); + Log::logger().debug("OpenGL version: {}", reinterpret_cast(glGetString(GL_VERSION))); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); glDebugMessageCallback(Helper::gl_debug_callback, nullptr); @@ -138,8 +142,9 @@ void Window::framebuffer_size_callback(GLFWwindow *window, int width, int height glViewport(0, 0, width, height); } -void Window::key_callback(GLFWwindow *glfw_window, int key, int scancode, int action, - int mods) // NOLINT(bugprone-easily-swappable-parameters) +// NOLINTBEGIN(bugprone-easily-swappable-parameters) +void Window::key_callback(GLFWwindow *glfw_window, int key, int scancode, int action, int mods) +// NOLINTEND(bugprone-easily-swappable-parameters) { (void)mods; (void)scancode; @@ -157,9 +162,10 @@ void Window::key_callback(GLFWwindow *glfw_window, int key, int scancode, int ac window.m_key_input[key] = (action == GLFW_PRESS); } } - +// NOLINTBEGIN(bugprone-easily-swappable-parameters) void Window::mouse_button_callback(GLFWwindow *glfw_window, int button, int action, int mods) // NOLINT(bugprone-easily-swappable-parameters) +// NOLINTEND(bugprone-easily-swappable-parameters) { (void)mods; (void)button;