Refactor project structure

This commit is contained in:
2023-06-09 14:45:44 +02:00
parent ae61cccb70
commit cf7d2ee7bf
39 changed files with 85 additions and 84 deletions

View File

@@ -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)

View File

@@ -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 <GLFW/glfw3.h>
#include <array>

View File

@@ -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 <entt/entt.hpp>
#include <glm/glm.hpp>

View File

@@ -1,5 +1,5 @@
#include "Controller.h"
#include "log.h"
#include "util/log.h"
#include <GLFW/glfw3.h>
#include <iostream>

View File

@@ -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 <GLFW/glfw3.h>
#include <algorithm>
#include <glm/gtc/matrix_transform.hpp>

View File

@@ -1,8 +1,7 @@
#pragma once
#include "transform.h"
#include "components/transform.h"
#include <GLFW/glfw3.h>
#include <chrono>
#include <entt/entt.hpp>
#include <glm/glm.hpp>

View File

@@ -1,6 +1,6 @@
#pragma once
#include "shader.h"
#include "core/shader.h"
#include <entt/entt.hpp>
#include <glad/gl.h>

View File

@@ -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);

View File

@@ -1,7 +1,7 @@
#pragma once
#include "image.h"
#include "shader.h"
#include "core/shader.h"
#include <entt/entt.hpp>
#include <optional>

View File

@@ -1,5 +1,5 @@
#include "light.h"
#include "transform.h"
#include "components/transform.h"
static auto light_active(float illuminance) -> bool
{

View File

@@ -1,7 +1,7 @@
#pragma once
#include "color.h"
#include "shader.h"
#include "components/color.h"
#include "core/shader.h"
#include <entt/entt.hpp>
#include <glm/glm.hpp>
@@ -25,5 +25,5 @@ struct DirectionalLight
};
namespace Light {
void update_lights(entt::registry &registry, Shader &shader);
void update_lights(entt::registry& registry, Shader& shader);
}

View File

@@ -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 <entt/entt.hpp>
namespace Render {
void render(entt::registry &registry)
void Render::render(entt::registry& registry)
{
auto mesh_view = registry.view<GpuMesh const, GpuMaterial const, GlobalTransform const>();
auto camera_view = registry.view<Camera const, GlobalTransform const>();
@@ -39,5 +35,3 @@ void render(entt::registry &registry)
Shader::unbind();
}
}
} // namespace Render

9
src/core/render.h Normal file
View File

@@ -0,0 +1,9 @@
#pragma once
#include <entt/entt.hpp>
namespace Render {
void render(entt::registry& registry);
} // namespace Render

View File

@@ -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 <entt/entt.hpp>
#include <fx/gltf.h>

View File

@@ -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 <iterator>

View File

@@ -1,7 +1,7 @@
#pragma once
#include "gltf.h"
#include "transform.h"
#include "components/transform.h"
#include <entt/entt.hpp>
#include <filesystem>

View File

@@ -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))
{

View File

@@ -1,8 +1,8 @@
#include "Window.h"
#include "glad.h"
#include "core/glad.h"
#include <GLFW/glfw3.h>
#include <glad/gl.h>
#include <GLFW/glfw3.h>
#include <spdlog/spdlog.h>
static constexpr unsigned INIT_WINDOW_WIDTH = 1280;

View File

@@ -1,9 +1,8 @@
#pragma once
#include "input.h"
#include "input/input.h"
#include <glm/glm.hpp>
#include <memory>
#include <unordered_map>
#include <utility>
@@ -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 &registry) const;
void update_descriptor(entt::registry &registry) 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;