Files
MapLibreParticleLab/src/mbgl/shader/uniform.cpp
Young Hahn 24b66bc8cd Color class (#5361)
* Color class

* Switch to list initialization
2016-06-15 11:38:22 -04:00

55 lines
1.4 KiB
C++

#include <mbgl/shader/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
template <>
void Uniform<GLfloat>::bind(const GLfloat& t) {
MBGL_CHECK_ERROR(glUniform1f(location, t));
}
template <>
void Uniform<GLint>::bind(const GLint& t) {
MBGL_CHECK_ERROR(glUniform1i(location, t));
}
template <>
void Uniform<std::array<GLfloat, 2>>::bind(const std::array<GLfloat, 2>& t) {
MBGL_CHECK_ERROR(glUniform2fv(location, 1, t.data()));
}
template <>
void Uniform<std::array<GLfloat, 3>>::bind(const std::array<GLfloat, 3>& t) {
MBGL_CHECK_ERROR(glUniform3fv(location, 1, t.data()));
}
template <>
void Uniform<std::array<GLfloat, 4>>::bind(const std::array<GLfloat, 4>& t) {
MBGL_CHECK_ERROR(glUniform4fv(location, 1, t.data()));
}
template <>
void Uniform<Color>::bind(const Color& t) {
std::array<GLfloat, 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<GLfloat, 4>& t) {
MBGL_CHECK_ERROR(glUniformMatrix2fv(location, 1, GL_FALSE, t.data()));
}
template <>
void UniformMatrix<3>::bind(const std::array<GLfloat, 9>& t) {
MBGL_CHECK_ERROR(glUniformMatrix3fv(location, 1, GL_FALSE, t.data()));
}
template <>
void UniformMatrix<4>::bind(const std::array<GLfloat, 16>& t) {
MBGL_CHECK_ERROR(glUniformMatrix4fv(location, 1, GL_FALSE, t.data()));
}
// Add more as needed.
} // namespace mbgl