diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-09-30 12:20:29 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-10-05 10:52:19 -0700 |
commit | 73334ac8fa330af05dd91906a4e5d1bbda7d5c34 (patch) | |
tree | aeba3681352926e5837d2d68b70a08f52d6ed026 /src/mbgl/gl/uniform.cpp | |
parent | 7a3bef091e7390fa57bf33f1a704c893768b5625 (diff) | |
download | qtlocation-mapboxgl-73334ac8fa330af05dd91906a4e5d1bbda7d5c34.tar.gz |
[core] Move shader and uniform to gl directory
Diffstat (limited to 'src/mbgl/gl/uniform.cpp')
-rw-r--r-- | src/mbgl/gl/uniform.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/mbgl/gl/uniform.cpp b/src/mbgl/gl/uniform.cpp new file mode 100644 index 0000000000..07a27963d9 --- /dev/null +++ b/src/mbgl/gl/uniform.cpp @@ -0,0 +1,57 @@ +#include <mbgl/gl/uniform.hpp> +#include <mbgl/gl/gl.hpp> +#include <mbgl/util/color.hpp> + +namespace mbgl { +namespace gl { + +template <> +void Uniform<float>::bind(const float& t) { + MBGL_CHECK_ERROR(glUniform1f(location, t)); +} + +template <> +void Uniform<int32_t>::bind(const int32_t& t) { + MBGL_CHECK_ERROR(glUniform1i(location, t)); +} + +template <> +void Uniform<std::array<float, 2>>::bind(const std::array<float, 2>& t) { + MBGL_CHECK_ERROR(glUniform2fv(location, 1, t.data())); +} + +template <> +void Uniform<std::array<float, 3>>::bind(const std::array<float, 3>& t) { + MBGL_CHECK_ERROR(glUniform3fv(location, 1, t.data())); +} + +template <> +void Uniform<std::array<float, 4>>::bind(const std::array<float, 4>& t) { + MBGL_CHECK_ERROR(glUniform4fv(location, 1, t.data())); +} + +template <> +void Uniform<Color>::bind(const Color& t) { + std::array<float, 4> a = {{ t.r, t.g, t.b, t.a }}; + MBGL_CHECK_ERROR(glUniform4fv(location, 1, a.data())); +} + +template <> +void UniformMatrix<2>::bind(const std::array<float, 4>& t) { + MBGL_CHECK_ERROR(glUniformMatrix2fv(location, 1, GL_FALSE, t.data())); +} + +template <> +void UniformMatrix<3>::bind(const std::array<float, 9>& t) { + MBGL_CHECK_ERROR(glUniformMatrix3fv(location, 1, GL_FALSE, t.data())); +} + +template <> +void UniformMatrix<4>::bind(const std::array<float, 16>& t) { + MBGL_CHECK_ERROR(glUniformMatrix4fv(location, 1, GL_FALSE, t.data())); +} + +// Add more as needed. + +} // namespace gl +} // namespace mbgl |