blob: 2058ecd4953a0e5cbdabbce572f3717b60974be4 (
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/gfx/texture.hpp>
#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/ignore.hpp>
#include <vector>
#include <string>
namespace mbgl {
namespace gl {
class Context;
void bindTexture(gl::Context&, uint8_t unit, const gfx::TextureBinding&);
template <class>
class TextureStates;
template <class... Ts>
class TextureStates<TypeList<Ts...>> {
private:
using State =
IndexedTuple<TypeList<Ts...>, TypeList<ExpandToType<Ts, gl::UniformState<uint8_t>>...>>;
State state;
public:
void queryLocations(const ProgramID& id) {
state = State{ gl::uniformLocation(id, Ts::uniformName())... };
}
template <class BinaryProgram>
void loadNamedLocations(const BinaryProgram& program) {
state = State{ program.textureLocation(Ts::uniformName())... };
}
NamedUniformLocations getNamedLocations() const {
return NamedUniformLocations{ { Ts::uniformName(), state.template get<Ts>().location }... };
}
void bind(gl::Context& context, const gfx::TextureBindings<TypeList<Ts...>>& bindings) {
util::ignore(
{ (state.template get<Ts>() = TypeIndex<Ts, Ts...>::value,
gl::bindTexture(context, TypeIndex<Ts, Ts...>::value, bindings.template get<Ts>()),
0)... });
}
};
} // namespace gl
} // namespace mbgl
|