diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 115322f..65ea73f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,23 +1,23 @@ add_library(fever_engine - main.cpp - Controller.cpp - Window.cpp - scene.cpp - framebuffer.cpp - log.cpp - image.cpp - mesh.cpp - glad.cpp - gltf_loader.cpp - material.cpp - camera.cpp - shader.cpp - transform.cpp - light.cpp - input.cpp + components/transform.cpp + core/graphics/framebuffer.cpp + core/graphics/image.cpp + core/graphics/material.cpp + core/graphics/mesh.cpp + core/camera.cpp + core/glad.cpp + core/light.cpp + core/render.cpp + core/shader.cpp + input/input.cpp + scene/gltf_loader.cpp + scene/scene.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_compile_definitions(fever_engine PRIVATE SPDLOG_FMT_EXTERNAL) target_link_libraries( @@ -33,7 +33,8 @@ target_link_libraries( ) add_executable(Fall-Fever - main.cpp + bin/main.cpp + bin/Controller.cpp ) target_link_libraries(Fall-Fever PRIVATE fever_engine) diff --git a/src/Controller.cpp b/src/bin/Controller.cpp similarity index 95% rename from src/Controller.cpp rename to src/bin/Controller.cpp index 03d1504..2b41608 100644 --- a/src/Controller.cpp +++ b/src/bin/Controller.cpp @@ -1,11 +1,11 @@ #include "Controller.h" -#include "Window.h" -#include "gltf_loader.h" -#include "input.h" -#include "light.h" -#include "render.h" -#include "shader.h" -#include "time.h" +#include "core/light.h" +#include "core/render.h" +#include "core/shader.h" +#include "core/time.h" +#include "input/input.h" +#include "scene/gltf_loader.h" +#include "window/Window.h" #include #include diff --git a/src/Controller.h b/src/bin/Controller.h similarity index 90% rename from src/Controller.h rename to src/bin/Controller.h index 5cf9479..67bf0fa 100644 --- a/src/Controller.h +++ b/src/bin/Controller.h @@ -1,9 +1,9 @@ #pragma once -#include "framebuffer.h" -#include "gltf_loader.h" -#include "scene.h" -#include "shader.h" +#include "core/graphics/framebuffer.h" +#include "core/shader.h" +#include "scene/gltf_loader.h" +#include "scene/scene.h" #include #include diff --git a/src/main.cpp b/src/bin/main.cpp similarity index 94% rename from src/main.cpp rename to src/bin/main.cpp index fa69b74..030d469 100644 --- a/src/main.cpp +++ b/src/bin/main.cpp @@ -1,5 +1,5 @@ #include "Controller.h" -#include "log.h" +#include "util/log.h" #include #include diff --git a/src/color.h b/src/components/color.h similarity index 100% rename from src/color.h rename to src/components/color.h diff --git a/src/name.h b/src/components/name.h similarity index 100% rename from src/name.h rename to src/components/name.h diff --git a/src/relationship.h b/src/components/relationship.h similarity index 100% rename from src/relationship.h rename to src/components/relationship.h diff --git a/src/transform.cpp b/src/components/transform.cpp similarity index 100% rename from src/transform.cpp rename to src/components/transform.cpp diff --git a/src/transform.h b/src/components/transform.h similarity index 100% rename from src/transform.h rename to src/components/transform.h diff --git a/src/camera.cpp b/src/core/camera.cpp similarity index 97% rename from src/camera.cpp rename to src/core/camera.cpp index bb31c27..13ff6f3 100644 --- a/src/camera.cpp +++ b/src/core/camera.cpp @@ -1,8 +1,9 @@ #include "camera.h" -#include "Window.h" -#include "input.h" -#include "time.h" +#include "core/time.h" +#include "input/input.h" +#include "window/Window.h" +#include #include #include diff --git a/src/camera.h b/src/core/camera.h similarity index 96% rename from src/camera.h rename to src/core/camera.h index 53e9611..440bdd0 100644 --- a/src/camera.h +++ b/src/core/camera.h @@ -1,8 +1,7 @@ #pragma once -#include "transform.h" +#include "components/transform.h" -#include #include #include #include diff --git a/src/glad.cpp b/src/core/glad.cpp similarity index 100% rename from src/glad.cpp rename to src/core/glad.cpp diff --git a/src/glad.h b/src/core/glad.h similarity index 100% rename from src/glad.h rename to src/core/glad.h diff --git a/src/framebuffer.cpp b/src/core/graphics/framebuffer.cpp similarity index 100% rename from src/framebuffer.cpp rename to src/core/graphics/framebuffer.cpp diff --git a/src/framebuffer.h b/src/core/graphics/framebuffer.h similarity index 96% rename from src/framebuffer.h rename to src/core/graphics/framebuffer.h index 15d4d42..0dc8437 100644 --- a/src/framebuffer.h +++ b/src/core/graphics/framebuffer.h @@ -1,6 +1,6 @@ #pragma once -#include "shader.h" +#include "core/shader.h" #include #include diff --git a/src/image.cpp b/src/core/graphics/image.cpp similarity index 100% rename from src/image.cpp rename to src/core/graphics/image.cpp diff --git a/src/image.h b/src/core/graphics/image.h similarity index 100% rename from src/image.h rename to src/core/graphics/image.h diff --git a/src/material.cpp b/src/core/graphics/material.cpp similarity index 88% rename from src/material.cpp rename to src/core/graphics/material.cpp index d481952..0748cca 100644 --- a/src/material.cpp +++ b/src/core/graphics/material.cpp @@ -1,7 +1,7 @@ #include "material.h" -#include "shader.h" +#include "core/shader.h" -GpuMaterial::GpuMaterial(Material const &material) : shader(material.shader) +GpuMaterial::GpuMaterial(Material const& material) : shader(material.shader) { int texture_unit_counter = 0; @@ -19,7 +19,7 @@ GpuMaterial::GpuMaterial(Material const &material) : shader(material.shader) } void GpuMaterial::bind() const { - auto bind_texture = [this](auto const &texture) { + auto bind_texture = [this](auto const& texture) { if (texture.has_value()) { shader->set_uniform(texture->second.uniform_name, texture->second.texture_unit); glActiveTexture(GL_TEXTURE0 + texture->second.texture_unit); diff --git a/src/material.h b/src/core/graphics/material.h similarity index 96% rename from src/material.h rename to src/core/graphics/material.h index f7464c5..87d9ae8 100644 --- a/src/material.h +++ b/src/core/graphics/material.h @@ -1,7 +1,7 @@ #pragma once #include "image.h" -#include "shader.h" +#include "core/shader.h" #include #include diff --git a/src/mesh.cpp b/src/core/graphics/mesh.cpp similarity index 100% rename from src/mesh.cpp rename to src/core/graphics/mesh.cpp diff --git a/src/mesh.h b/src/core/graphics/mesh.h similarity index 100% rename from src/mesh.h rename to src/core/graphics/mesh.h diff --git a/src/light.cpp b/src/core/light.cpp similarity index 98% rename from src/light.cpp rename to src/core/light.cpp index 872614d..c8a42f8 100644 --- a/src/light.cpp +++ b/src/core/light.cpp @@ -1,5 +1,5 @@ #include "light.h" -#include "transform.h" +#include "components/transform.h" static auto light_active(float illuminance) -> bool { diff --git a/src/light.h b/src/core/light.h similarity index 81% rename from src/light.h rename to src/core/light.h index 9f7c4e4..27c5fcb 100644 --- a/src/light.h +++ b/src/core/light.h @@ -1,7 +1,7 @@ #pragma once -#include "color.h" -#include "shader.h" +#include "components/color.h" +#include "core/shader.h" #include #include @@ -25,5 +25,5 @@ struct DirectionalLight }; namespace Light { -void update_lights(entt::registry ®istry, Shader &shader); +void update_lights(entt::registry& registry, Shader& shader); } diff --git a/src/render.h b/src/core/render.cpp similarity index 86% rename from src/render.h rename to src/core/render.cpp index fcf3ad2..ce3f781 100644 --- a/src/render.h +++ b/src/core/render.cpp @@ -1,14 +1,10 @@ -#pragma once +#include "render.h" +#include "core/camera.h" +#include "core/graphics/material.h" +#include "core/graphics/mesh.h" +#include "core/shader.h" -#include "camera.h" -#include "material.h" -#include "mesh.h" - -#include - -namespace Render { - -void render(entt::registry ®istry) +void Render::render(entt::registry& registry) { auto mesh_view = registry.view(); auto camera_view = registry.view(); @@ -39,5 +35,3 @@ void render(entt::registry ®istry) Shader::unbind(); } } - -} // namespace Render diff --git a/src/core/render.h b/src/core/render.h new file mode 100644 index 0000000..40452a2 --- /dev/null +++ b/src/core/render.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +namespace Render { + +void render(entt::registry& registry); + +} // namespace Render diff --git a/src/shader.cpp b/src/core/shader.cpp similarity index 100% rename from src/shader.cpp rename to src/core/shader.cpp diff --git a/src/shader.h b/src/core/shader.h similarity index 100% rename from src/shader.h rename to src/core/shader.h diff --git a/src/time.h b/src/core/time.h similarity index 100% rename from src/time.h rename to src/core/time.h diff --git a/src/input.cpp b/src/input/input.cpp similarity index 100% rename from src/input.cpp rename to src/input/input.cpp diff --git a/src/input.h b/src/input/input.h similarity index 100% rename from src/input.h rename to src/input/input.h diff --git a/src/gltf.h b/src/scene/gltf.h similarity index 90% rename from src/gltf.h rename to src/scene/gltf.h index 2f8d049..d7a491f 100644 --- a/src/gltf.h +++ b/src/scene/gltf.h @@ -1,8 +1,8 @@ #pragma once -#include "material.h" -#include "mesh.h" -#include "transform.h" +#include "components/transform.h" +#include "core/graphics/material.h" +#include "core/graphics/mesh.h" #include #include diff --git a/src/gltf_loader.cpp b/src/scene/gltf_loader.cpp similarity index 99% rename from src/gltf_loader.cpp rename to src/scene/gltf_loader.cpp index 65095f0..7a4b090 100644 --- a/src/gltf_loader.cpp +++ b/src/scene/gltf_loader.cpp @@ -1,7 +1,7 @@ #include "gltf_loader.h" -#include "camera.h" -#include "name.h" -#include "relationship.h" +#include "components/name.h" +#include "components/relationship.h" +#include "core/camera.h" #include "scene.h" #include diff --git a/src/gltf_loader.h b/src/scene/gltf_loader.h similarity index 95% rename from src/gltf_loader.h rename to src/scene/gltf_loader.h index 5c82bc6..23c663e 100644 --- a/src/gltf_loader.h +++ b/src/scene/gltf_loader.h @@ -1,7 +1,7 @@ #pragma once #include "gltf.h" -#include "transform.h" +#include "components/transform.h" #include #include diff --git a/src/scene.cpp b/src/scene/scene.cpp similarity index 92% rename from src/scene.cpp rename to src/scene/scene.cpp index 0340b36..48c8ffa 100644 --- a/src/scene.cpp +++ b/src/scene/scene.cpp @@ -1,12 +1,10 @@ #include "scene.h" -#include "camera.h" -#include "light.h" -#include "mesh.h" -#include "name.h" -#include "relationship.h" -#include "shader.h" -#include "transform.h" -#include "Window.h" +#include "components/name.h" +#include "components/transform.h" +#include "core/camera.h" +#include "core/graphics/mesh.h" +#include "core/light.h" +#include "window/Window.h" Scene::Scene(entt::registry registry) : m_registry(std::move(registry)) { diff --git a/src/scene.h b/src/scene/scene.h similarity index 100% rename from src/scene.h rename to src/scene/scene.h diff --git a/src/log.cpp b/src/util/log.cpp similarity index 100% rename from src/log.cpp rename to src/util/log.cpp diff --git a/src/log.h b/src/util/log.h similarity index 100% rename from src/log.h rename to src/util/log.h diff --git a/src/Window.cpp b/src/window/Window.cpp similarity index 99% rename from src/Window.cpp rename to src/window/Window.cpp index b89a3ef..47c4ce1 100644 --- a/src/Window.cpp +++ b/src/window/Window.cpp @@ -1,8 +1,8 @@ #include "Window.h" -#include "glad.h" +#include "core/glad.h" -#include #include +#include #include static constexpr unsigned INIT_WINDOW_WIDTH = 1280; diff --git a/src/Window.h b/src/window/Window.h similarity index 62% rename from src/Window.h rename to src/window/Window.h index 88b4ced..e1fff97 100644 --- a/src/Window.h +++ b/src/window/Window.h @@ -1,9 +1,8 @@ #pragma once -#include "input.h" +#include "input/input.h" #include - #include #include #include @@ -26,24 +25,24 @@ public: Window(); - [[nodiscard]] auto glfw_window() -> GLFWwindow & { return *m_glfw_window; } + [[nodiscard]] auto glfw_window() -> GLFWwindow& { return *m_glfw_window; } [[nodiscard]] auto physical_dimensions() const -> glm::u32vec2; [[nodiscard]] auto logical_dimensions() const -> glm::u32vec2; [[nodiscard]] auto dimensions_changed() -> bool; - [[nodiscard]] auto key_input() const -> auto const & { return m_key_input; } - [[nodiscard]] auto mouse_cursor_input() const -> auto const & { return m_mouse_cursor_input; } - [[nodiscard]] auto mouse_button_input() const -> auto const & { return m_mouse_button_input; } + [[nodiscard]] auto key_input() const -> auto const& { return m_key_input; } + [[nodiscard]] auto mouse_cursor_input() const -> auto const& { return m_mouse_cursor_input; } + [[nodiscard]] auto mouse_button_input() const -> auto const& { return m_mouse_button_input; } [[nodiscard]] auto cursor_catched() const -> auto { return m_mouse_catched; } void clear_mouse_cursor_input(); - void update_catched_mouse(entt::registry ®istry) const; - void update_descriptor(entt::registry ®istry) const; + void update_catched_mouse(entt::registry& registry) const; + void update_descriptor(entt::registry& registry) const; private: - static void key_callback(GLFWwindow *glfw_window, int key, int scancode, int action, int mods); - static void mouse_cursor_callback(GLFWwindow *glfw_window, double xpos, double ypos); - static void framebuffer_size_callback(GLFWwindow *glfw_window, int width, int height); - static void glfw_error_callback(int error, const char *description); + static void key_callback(GLFWwindow* glfw_window, int key, int scancode, int action, int mods); + static void mouse_cursor_callback(GLFWwindow* glfw_window, double xpos, double ypos); + static void framebuffer_size_callback(GLFWwindow* glfw_window, int width, int height); + static void glfw_error_callback(int error, char const* description); static constexpr float MOUSE_SENSITIVITY = 0.15F;