2022-08-19 02:40:34 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-08-30 23:39:24 +00:00
|
|
|
#include "../ecs/entity.h"
|
|
|
|
#include "material.h"
|
2022-08-19 02:40:34 +00:00
|
|
|
#include "texture.h"
|
|
|
|
#include "shader.h"
|
|
|
|
//#include "renderable.h"
|
|
|
|
#include "model.h"
|
|
|
|
|
2022-08-30 23:39:24 +00:00
|
|
|
#include <unordered_map>
|
2022-08-19 02:40:34 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace simpleengine::gfx {
|
|
|
|
class Renderer : public simpleengine::Renderable {
|
|
|
|
private:
|
|
|
|
GLFWwindow* window;
|
|
|
|
public:
|
2022-08-30 23:39:24 +00:00
|
|
|
|
2022-08-19 02:40:34 +00:00
|
|
|
class RenderingModel {
|
|
|
|
public:
|
2022-08-30 23:39:24 +00:00
|
|
|
std::shared_ptr<simpleengine::Entity> entity;
|
2022-09-10 22:39:39 +00:00
|
|
|
std::unordered_map<uint32_t, gfx::Model&> component_models;
|
2022-08-30 23:39:24 +00:00
|
|
|
|
|
|
|
RenderingModel(std::shared_ptr<simpleengine::Entity> entity) : entity(entity) {
|
2022-08-19 02:40:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-08-30 23:39:24 +00:00
|
|
|
/**
|
|
|
|
* @brief Create and delete buffers for new and old components in entity.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void update_buffers();
|
2022-08-19 02:40:34 +00:00
|
|
|
|
2022-08-30 23:39:24 +00:00
|
|
|
/**
|
|
|
|
* @brief Destroy the buffers
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void destroy_buffers();
|
2022-08-19 02:40:34 +00:00
|
|
|
};
|
|
|
|
|
2022-08-30 23:39:24 +00:00
|
|
|
std::unordered_map<uint32_t, RenderingModel> rendering_models;
|
2022-09-10 22:39:39 +00:00
|
|
|
gfx::Shader shader;
|
2022-08-19 02:40:34 +00:00
|
|
|
|
|
|
|
Renderer(GLFWwindow* window, gfx::Shader shader);
|
|
|
|
Renderer(GLFWwindow* window, GLuint shader_program);
|
2022-09-10 22:39:39 +00:00
|
|
|
|
|
|
|
void enable_debug();
|
|
|
|
|
2022-08-30 23:39:24 +00:00
|
|
|
virtual void submit_entity(std::shared_ptr<simpleengine::Entity> entity);
|
|
|
|
virtual bool withdraw_entity(std::shared_ptr<simpleengine::Entity> entity);
|
2022-08-19 02:40:34 +00:00
|
|
|
|
|
|
|
virtual void initialize();
|
2022-09-10 22:39:39 +00:00
|
|
|
virtual void destroy() override;
|
2022-08-19 02:40:34 +00:00
|
|
|
|
2022-08-30 23:39:24 +00:00
|
|
|
virtual void update(const float& delta_time) override;
|
2022-08-19 02:40:34 +00:00
|
|
|
|
|
|
|
virtual void render(GLFWwindow* target) override;
|
|
|
|
};
|
|
|
|
}
|