//
// Created by sebastian on 08.02.26.
//

#ifndef MASTERRENDERER_H
#define MASTERRENDERER_H
#include <unordered_map>
#include <vector>

#include "Renderer.h"
#include "TerrainRenderer.h"
#include "../../game/hexWorld/HexTile.h"
#include "../layer/entities/Entity.h"
#include "model/TexturedModel.h"


class Camera;
class Light;

class MasterRenderer {
private:
    std::unordered_map<TexturedModel*, std::vector<Entity*>> entities;
    std::unordered_map<TexturedModel*, std::vector<HexRenderData*>> terrainTiles;
    glm::mat4 projectionMatrix;
    std::unique_ptr<Renderer> entityRenderer;
    std::unique_ptr<TerrainRenderer> terrainRenderer;
    constexpr static float FOV = 70.0f;
    constexpr static float NEAR_PLANE = 0.1f;
    constexpr static float FAR_PLANE = 1000.0f;

    static glm::mat4 createProjectionMatrix();

public:
    MasterRenderer() : projectionMatrix(createProjectionMatrix()), entityRenderer(std::make_unique<Renderer>(projectionMatrix)),
        terrainRenderer(std::make_unique<TerrainRenderer>(projectionMatrix))
    {
        glEnable(GL_CULL_FACE);
        glCullFace(GL_BACK);
    };
    void render(const Light &light, const Camera &camera);

    void submitEntity(Entity* entity);
    void submitTerrainTile(HexRenderData* tile);

    [[nodiscard]] glm::mat4 getProjectionMatrix() const {return projectionMatrix;}
};



#endif //MASTERRENDERER_H
