summaryrefslogtreecommitdiff
path: root/src/mbgl/shader/shader.hpp
blob: 977edebd7e94dc65f460605482ad4cb9f50f6aa5 (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
47
48
49
50
51
52
#pragma once

#include <mbgl/gl/types.hpp>
#include <mbgl/gl/object.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/optional.hpp>

namespace mbgl {

namespace gl {
class Context;
} // namespace gl

class Shader : private util::noncopyable {
public:
    ~Shader();
    const char* name;

    gl::ProgramID getID() const {
        return program.get();
    }

    gl::UniformLocation getUniformLocation(const char* uniform) const;

    enum Defines : bool {
        None = false,
        Overdraw = true,
    };

protected:
    Shader(const char* name_,
           const char* vertex,
           const char* fragment,
           gl::Context&,
           Defines defines = Defines::None);

public:
    static constexpr gl::AttributeLocation         a_pos = 0;
    static constexpr gl::AttributeLocation     a_extrude = 1;
    static constexpr gl::AttributeLocation      a_offset = 2;
    static constexpr gl::AttributeLocation        a_data = 3;
    static constexpr gl::AttributeLocation a_texture_pos = 4;

private:
    bool compileShader(gl::UniqueShader&, const char *source);

    gl::UniqueProgram program;
    gl::UniqueShader vertexShader;
    gl::UniqueShader fragmentShader;
};

} // namespace mbgl