summaryrefslogtreecommitdiff
path: root/src/mbgl/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/shader')
-rw-r--r--src/mbgl/shader/circle_shader.hpp3
-rw-r--r--src/mbgl/shader/line_shader.hpp3
-rw-r--r--src/mbgl/shader/linesdf_shader.hpp3
-rw-r--r--src/mbgl/shader/outline_shader.hpp3
-rw-r--r--src/mbgl/shader/plain_shader.hpp3
-rw-r--r--src/mbgl/shader/sdf_shader.hpp3
-rw-r--r--src/mbgl/shader/uniform.cpp7
7 files changed, 19 insertions, 6 deletions
diff --git a/src/mbgl/shader/circle_shader.hpp b/src/mbgl/shader/circle_shader.hpp
index cd22d4c9b1..70faad9b78 100644
--- a/src/mbgl/shader/circle_shader.hpp
+++ b/src/mbgl/shader/circle_shader.hpp
@@ -2,6 +2,7 @@
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
+#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -14,7 +15,7 @@ public:
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<std::array<GLfloat, 2>> u_extrude_scale = {"u_extrude_scale", *this};
Uniform<GLfloat> u_devicepixelratio = {"u_devicepixelratio", *this};
- Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
+ Uniform<Color> u_color = {"u_color", *this};
Uniform<GLfloat> u_radius = {"u_radius", *this};
Uniform<GLfloat> u_blur = {"u_blur", *this};
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
diff --git a/src/mbgl/shader/line_shader.hpp b/src/mbgl/shader/line_shader.hpp
index e0d14094a6..1265e768f2 100644
--- a/src/mbgl/shader/line_shader.hpp
+++ b/src/mbgl/shader/line_shader.hpp
@@ -2,6 +2,7 @@
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
+#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,7 +13,7 @@ public:
void bind(GLbyte *offset) final;
UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
+ Uniform<Color> u_color = {"u_color", *this};
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
Uniform<GLfloat> u_ratio = {"u_ratio", *this};
Uniform<GLfloat> u_linewidth = {"u_linewidth", *this};
diff --git a/src/mbgl/shader/linesdf_shader.hpp b/src/mbgl/shader/linesdf_shader.hpp
index 8791f243c0..98bbc2b8f8 100644
--- a/src/mbgl/shader/linesdf_shader.hpp
+++ b/src/mbgl/shader/linesdf_shader.hpp
@@ -2,6 +2,7 @@
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
+#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,7 +13,7 @@ public:
void bind(GLbyte *offset) final;
UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
+ Uniform<Color> u_color = {"u_color", *this};
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
Uniform<GLfloat> u_linewidth = {"u_linewidth", *this};
Uniform<GLfloat> u_gapwidth = {"u_gapwidth", *this};
diff --git a/src/mbgl/shader/outline_shader.hpp b/src/mbgl/shader/outline_shader.hpp
index 25c873b4fe..5ec2c68e7f 100644
--- a/src/mbgl/shader/outline_shader.hpp
+++ b/src/mbgl/shader/outline_shader.hpp
@@ -2,6 +2,7 @@
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
+#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,7 +13,7 @@ public:
void bind(GLbyte *offset) final;
UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<std::array<GLfloat, 4>> u_outline_color = {"u_outline_color", *this};
+ Uniform<Color> u_outline_color = {"u_outline_color", *this};
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
Uniform<std::array<GLfloat, 2>> u_world = {"u_world", *this};
};
diff --git a/src/mbgl/shader/plain_shader.hpp b/src/mbgl/shader/plain_shader.hpp
index 7edf4b4b19..8eec69147e 100644
--- a/src/mbgl/shader/plain_shader.hpp
+++ b/src/mbgl/shader/plain_shader.hpp
@@ -2,6 +2,7 @@
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
+#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,7 +13,7 @@ public:
void bind(GLbyte *offset) final;
UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
+ Uniform<Color> u_color = {"u_color", *this};
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
};
diff --git a/src/mbgl/shader/sdf_shader.hpp b/src/mbgl/shader/sdf_shader.hpp
index 6889288c28..88f671b543 100644
--- a/src/mbgl/shader/sdf_shader.hpp
+++ b/src/mbgl/shader/sdf_shader.hpp
@@ -2,6 +2,7 @@
#include <mbgl/shader/shader.hpp>
#include <mbgl/shader/uniform.hpp>
+#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -11,7 +12,7 @@ public:
UniformMatrix<4> u_matrix = {"u_matrix", *this};
Uniform<std::array<GLfloat, 2>> u_extrude_scale = {"u_extrude_scale", *this};
- Uniform<std::array<GLfloat, 4>> u_color = {"u_color", *this};
+ Uniform<Color> u_color = {"u_color", *this};
Uniform<GLfloat> u_opacity = {"u_opacity", *this};
Uniform<std::array<GLfloat, 2>> u_texsize = {"u_texsize", *this};
Uniform<GLfloat> u_buffer = {"u_buffer", *this};
diff --git a/src/mbgl/shader/uniform.cpp b/src/mbgl/shader/uniform.cpp
index d43dd20016..4c7646119a 100644
--- a/src/mbgl/shader/uniform.cpp
+++ b/src/mbgl/shader/uniform.cpp
@@ -1,4 +1,5 @@
#include <mbgl/shader/uniform.hpp>
+#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -28,6 +29,12 @@ void Uniform<std::array<GLfloat, 4>>::bind(const std::array<GLfloat, 4>& t) {
}
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()));
}