aboutsummaryrefslogtreecommitdiff
path: root/include/RenderBackend/OpenGL/ShaderProgram.hpp
blob: c8740f8916a23e7a0e416f27c8711891b425e3eb (plain)
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
#pragma once

#include "../../Result.hpp"
#include "../../types.hpp"
#include "../../utils.hpp"
#include "ShaderVec.hpp"
#include <vector>
#include <stdexcept>

namespace amalgine
{
    class CompiledVertexShader;
    class CompiledPixelShader;
    
    class ShaderProgramUsedBeforeBuilt : public std::runtime_error
    {
    public:
        // TODO: Add name to ShaderProgram so we know which shader has issue when
        // an exception is thrown?
        ShaderProgramUsedBeforeBuilt();
    };
    
    class ShaderProgramNonExistingGlobalVariable : public std::runtime_error
    {
    public:
        ShaderProgramNonExistingGlobalVariable(const char *variableName);
    };
    
    class ShaderProgram
    {
        DISABLE_COPY(ShaderProgram)
    public:
        ShaderProgram();
        ~ShaderProgram();
        
        bool setVertexShader(CompiledVertexShader *vertexShader);
        bool setPixelShader(CompiledPixelShader *pixelShader);
        
        Result<bool> build();
        void use();
        ShaderProgramGlobalVec3 getGlobalVec3(const char *name);
    private:
        u32 shaderProgramId;
        bool built;
    };
}