summaryrefslogtreecommitdiffstats
path: root/src/RendererWorld.hpp
blob: d339706869baf2b9d055fa7b10eace8761021051 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once

#include "RendererSection.hpp"
#include "RendererEntity.hpp"
#include "GameState.hpp"
#include "Shader.hpp"

#include <glm/gtc/type_ptr.hpp>

class RendererWorld: public Renderer {
    //General
    GameState *gs;
    EventListener listener;
    std::thread resourceLoader;
    void LoadedSectionController();
    bool isRunning = true;
    //Blocks
    
    std::mutex sectionsMutex;
    std::map<Vector, RendererSection> sections;
    Shader *blockShader;
    void RenderBlocks(RenderState& renderState);
    //Entities
    Shader *entityShader;
    std::vector<RendererEntity> entities;
    void RenderEntities(RenderState& renderState);
public:
	RendererWorld(GameState* ptr);
	~RendererWorld();

    void Render(RenderState& renderState) override;
    void PrepareResources() override;
    void PrepareRender() override;
    bool IsNeedResourcesPrepare() override;

    double MaxRenderingDistance;

    void Update();

    std::mutex renderDataMutex;
    std::queue<RendererSectionData> renderData;
};