summaryrefslogtreecommitdiffstats
path: root/src/RenderConfigs.hpp
blob: 9b535ca118c25df8a98bc58cd5000a55191bdfb5 (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
43
44
45
46
47
48
49
50
51
52
#pragma once

#include "Gal.hpp"

class Gbuffer {
    std::shared_ptr<Gal::Framebuffer> lightFramebuffer;
    std::shared_ptr<Gal::Buffer> lightBuffer;
    std::shared_ptr<Gal::Pipeline> lightPipeline;
    std::shared_ptr<Gal::PipelineInstance> lightPipelineInstance;
    std::shared_ptr<Gal::Texture> color; //RGB - color
    std::shared_ptr<Gal::Texture> normal; //RGB - normal
    std::shared_ptr<Gal::Texture> addColor; //RGB - addColor
    std::shared_ptr<Gal::Texture> light; //R - faceLight, G - skyLight, B - unused
    std::shared_ptr<Gal::Texture> depthStencil;
    std::shared_ptr<Gal::Framebuffer> geomFramebuffer;

    std::shared_ptr<Gal::Texture> finalColor;

public:
    Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH);

    std::shared_ptr<Gal::Framebuffer> GetGeometryTarget() {
        return geomFramebuffer;
    }

    std::shared_ptr<Gal::Texture> GetFinalTexture() {
        return finalColor;
    }

    void Render() {
        lightPipeline->Activate();
        lightPipelineInstance->Activate();
        lightPipelineInstance->Render(0, 6);
    }

    void Clear() {
        geomFramebuffer->Clear();
        lightFramebuffer->Clear();
    }

    void SetDayTime(float dayTime) {
        lightPipeline->SetShaderParameter("dayTime", dayTime);
    }

    int GetMaxRenderBuffers() {
        return 5;
    }

    void SetRenderBuff(int renderBuff) {
        lightPipeline->SetShaderParameter("renderBuff", renderBuff);
    }
};