diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-02-27 12:47:34 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-03-01 09:33:37 +0100 |
commit | 55c7b86053816e74c3fd3c0595c1fa053970f959 (patch) | |
tree | c34be5d76008fad4f28d39e9c39cc85ad31b72fe /src/mbgl/gl | |
parent | 7f1428ed3b90b54f503760471869ac83def32a59 (diff) | |
download | qtlocation-mapboxgl-55c7b86053816e74c3fd3c0595c1fa053970f959.tar.gz |
[core] extract uniform type lists from gl namespace
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r-- | src/mbgl/gl/uniform.cpp | 4 | ||||
-rw-r--r-- | src/mbgl/gl/uniform.hpp | 46 |
2 files changed, 14 insertions, 36 deletions
diff --git a/src/mbgl/gl/uniform.cpp b/src/mbgl/gl/uniform.cpp index e6c77be50b..21017d6436 100644 --- a/src/mbgl/gl/uniform.cpp +++ b/src/mbgl/gl/uniform.cpp @@ -63,7 +63,7 @@ void bindUniform<bool>(UniformLocation location, const bool& t) { } template <> -void bindUniform<uint8_t>(UniformLocation location, const uint8_t& t) { +void bindUniform<uint32_t>(UniformLocation location, const uint32_t& t) { bindUniform(location, int32_t(t)); } @@ -153,7 +153,7 @@ bool verifyUniform<bool>(const ActiveUniform& uniform) { } template <> -bool verifyUniform<uint8_t>(const ActiveUniform& uniform) { +bool verifyUniform<uint32_t>(const ActiveUniform& uniform) { assert(uniform.size == 1 && (uniform.type == UniformDataType::Int || uniform.type == UniformDataType::Float || 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>>; |