#ifndef ENGINE_H
#define ENGINE_H

#include "client/rendering/Shaders.h"
#include "client/rendering/Framebuffers.h"
#include "client/rendering/RenderSettings.h"
#include "client/Game.h"
#include "gaming-core/math/Frustum.h"
#include "client/rendering/FontRenderer.h"
#include "client/rendering/NoiseTexture.h"
#include "client/rendering/Mesh.h"

class Engine final {
public:
    Engine(Shaders& shaders, Framebuffers& fb, const Size& size, RenderSettings& renderSettings);
    void renderTick(float lag, const Game& game);

private:
    void renderShadow(float lag, const Game& game);
    void renderWorld(float lag, const Game& game);
    void renderSSAO();
    void renderPostWorld();
    void renderTextOverlay(float lag, const Game& game);
    void updateWorldProjection();
    void updateWorldView();

    Shaders& shaders;
    Framebuffers& framebuffers;
    const Size& size;
    RenderSettings& renderSettings;

    Frustum frustum;
    MatrixStack<16> model;
    FontRenderer fontRenderer;
    NoiseTexture ssaoNoise;
    Mesh rectangle;

    Matrix worldProj;
    Matrix worldView;
    Matrix worldShadowProj;
    Matrix worldShadowView;
    Matrix worldShadowProjView;
};

#endif