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

#include <mbgl/gl/types.hpp>
#include <mbgl/gl/object.hpp>
#include <mbgl/gl/context.hpp>

#include <string>

namespace mbgl {
namespace gl {

template <class As, class Us>
class Program {
public:
    using Attributes = As;
    using Vertex = typename Attributes::Vertex;

    using Uniforms = Us;
    using UniformValues = typename Uniforms::Values;

    Program(Context& context, const std::string& vertexSource, const std::string& fragmentSource)
        : vertexShader(context.createShader(ShaderType::Vertex, vertexSource)),
          fragmentShader(context.createShader(ShaderType::Fragment, fragmentSource)),
          program(context.createProgram(vertexShader, fragmentShader)),
          attributesState(Attributes::state(program)),
          uniformsState(Uniforms::state(program)) {}

    UniqueShader vertexShader;
    UniqueShader fragmentShader;
    UniqueProgram program;

    typename Attributes::State attributesState;
    typename Uniforms::State uniformsState;
};

} // namespace gl
} // namespace mbgl