-
-
Notifications
You must be signed in to change notification settings - Fork 318
/
uniform.hpp
49 lines (39 loc) · 1.51 KB
/
uniform.hpp
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
#pragma once
#include <mbgl/util/type_list.hpp>
#include <mbgl/util/indexed_tuple.hpp>
#include <array>
#define MBGL_DEFINE_UNIFORM_SCALAR(type_, name_) \
struct name_ { \
using Value = type_; \
static constexpr auto name() { \
return #name_; \
} \
}
#define MBGL_DEFINE_UNIFORM_VECTOR(type_, n_, name_) \
struct name_ { \
using Value = std::array<type_, n_>; \
static constexpr auto name() { \
return #name_; \
} \
}
#define MBGL_DEFINE_UNIFORM_MATRIX(type_, n_, name_) \
struct name_ { \
using Value = std::array<type_, n_ * n_>; \
static constexpr auto name() { \
return #name_; \
} \
}
namespace mbgl {
namespace gfx {
template <class>
class UniformValues;
template <class... Us>
class UniformValues<TypeList<Us...>> final : public IndexedTuple<TypeList<Us...>, TypeList<typename Us::Value...>> {
using Base = IndexedTuple<TypeList<Us...>, TypeList<typename Us::Value...>>;
public:
template <class... Args>
UniformValues(Args&&... args)
: Base(std::forward<Args>(args)...) {}
};
} // namespace gfx
} // namespace mbgl