feat: refactor and move out the renderer with entt registry + better event system

This commit is contained in:
2025-10-22 11:02:37 +02:00
parent ce0904ebec
commit 66e2531eb7
15 changed files with 175 additions and 104 deletions

View File

@ -3,8 +3,6 @@
#include <glm/glm.hpp>
#include "engine/renderer/mesh.h"
class Vertex {
friend class Mesh;
private:
@ -14,8 +12,6 @@ private:
public:
Vertex(glm::vec3 position, glm::vec3 normal, glm::vec2 texCoord)
: m_position(position), m_normal(normal), m_texCoord(texCoord) {}
public:
static void DefineAttrib();
};
#endif // RENDERER_BASICS_H

View File

@ -7,6 +7,9 @@
#include "engine/window/window.h"
#include "engine/window/events/window.h"
#include "engine/renderer/renderer.h"
#include "engine/scene/scene.h"
#include "engine/app/app.h"
#include "engine/export.h"
@ -16,6 +19,8 @@ public:
private:
static std::unique_ptr<IApplication> s_app;
static std::shared_ptr<Window> s_window;
static std::unique_ptr<Renderer> s_renderer;
static std::shared_ptr<Scene> s_scene;
static bool s_running;
};

View File

@ -2,8 +2,8 @@
#define RENDERER_H_
#include <glm/glm.hpp>
#include <entt/entity/registry.hpp>
#include "engine/scene/scene.h"
#include "engine/renderer/shader.h"
#include "engine/export.h"
#include "engine/components/light.h"
@ -11,23 +11,23 @@
// TODO: make static or singleton
class ENGINE_API Renderer {
public:
Renderer(entt::registry& registry);
Renderer(std::shared_ptr<Scene> scene);
void Render();
void Init();
void GenerateShadowMaps();
void OnWindowResized(int w, int h);
private:
void ApplyLights(Shader &shader);
void UpdateView();
void RenderScene(Shader &shader);
void GenerateShadowMaps();
void EnsureShadowResources(light& l);
private:
Shader m_shader;
Shader m_depthShader;
entt::registry& m_registry;
std::shared_ptr<Scene> m_scene;
// unsigned int m_depth_fbo;
// unsigned int m_depthMap;