summaryrefslogtreecommitdiff
path: root/src/mbgl/shader/shader.hpp
blob: b122bda280ff27530f3c54e3800f9e517e42ea1c (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
#pragma once

#include <mbgl/gl/gl.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();
    }

    virtual void bind(GLbyte *offset) = 0;

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

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

    static constexpr GLint         a_pos = 0;
    static constexpr GLint     a_extrude = 1;
    static constexpr GLint      a_offset = 2;
    static constexpr GLint        a_data = 3;
    static constexpr GLint a_texture_pos = 4;

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

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

} // namespace mbgl