summaryrefslogtreecommitdiff
path: root/src/mbgl/gl/uniform.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/gl/uniform.hpp')
-rw-r--r--src/mbgl/gl/uniform.hpp46
1 files changed, 12 insertions, 34 deletions
diff --git a/src/mbgl/gl/uniform.hpp b/src/mbgl/gl/uniform.hpp
index 9e841c3c15..38a0a759b3 100644
--- a/src/mbgl/gl/uniform.hpp
+++ b/src/mbgl/gl/uniform.hpp
@@ -32,52 +32,30 @@ ActiveUniforms activeUniforms(ProgramID);
#endif
-template <class T>
-class Uniform {
+template <class Value>
+class UniformState {
public:
- using Value = T;
-
- class State {
- public:
- State(UniformLocation location_) : location(std::move(location_)) {}
+ UniformState(UniformLocation location_) : location(std::move(location_)) {
+ }
- void operator=(const Value& value) {
- if (location >= 0 && (!current || *current != value)) {
- current = value;
- bindUniform(location, value);
- }
+ void operator=(const Value& value) {
+ if (location >= 0 && (!current || *current != value)) {
+ current = value;
+ bindUniform(location, value);
}
+ }
- UniformLocation location;
- optional<T> current = {};
- };
+ UniformLocation location;
+ optional<Value> current = {};
};
-template <class T>
-using UniformScalar = Uniform<T>;
-
-template <class T, size_t N>
-using UniformVector = Uniform<std::array<T, N>>;
-
-template <class T, size_t N>
-using UniformMatrix = Uniform<std::array<T, N*N>>;
-
-#define MBGL_DEFINE_UNIFORM_SCALAR(type_, name_) \
- struct name_ : ::mbgl::gl::UniformScalar<type_> { static auto name() { return #name_; } }
-
-#define MBGL_DEFINE_UNIFORM_VECTOR(type_, n_, name_) \
- struct name_ : ::mbgl::gl::UniformVector<type_, n_> { static auto name() { return #name_; } }
-
-#define MBGL_DEFINE_UNIFORM_MATRIX(type_, n_, name_) \
- struct name_ : ::mbgl::gl::UniformMatrix<type_, n_> { static auto name() { return #name_; } }
-
UniformLocation uniformLocation(ProgramID, const char * name);
template <class... Us>
class Uniforms {
public:
using Types = TypeList<Us...>;
- using State = IndexedTuple<TypeList<Us...>, TypeList<typename Us::State...>>;
+ using State = IndexedTuple<TypeList<Us...>, TypeList<UniformState<typename Us::Value>...>>;
using Values = IndexedTuple<TypeList<Us...>, TypeList<typename Us::Value...>>;
using NamedLocations = std::vector<std::pair<const std::string, UniformLocation>>;