summaryrefslogtreecommitdiff
path: root/include/mbgl/shader
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/shader')
-rw-r--r--include/mbgl/shader/composite_shader.hpp29
-rw-r--r--include/mbgl/shader/dot_shader.hpp33
-rw-r--r--include/mbgl/shader/gaussian_shader.hpp29
-rw-r--r--include/mbgl/shader/icon_shader.hpp42
-rw-r--r--include/mbgl/shader/line_shader.hpp45
-rw-r--r--include/mbgl/shader/linejoin_shader.hpp37
-rw-r--r--include/mbgl/shader/outline_shader.hpp29
-rw-r--r--include/mbgl/shader/pattern_shader.hpp45
-rw-r--r--include/mbgl/shader/plain_shader.hpp26
-rw-r--r--include/mbgl/shader/raster_shader.hpp33
-rw-r--r--include/mbgl/shader/shader.hpp29
-rw-r--r--include/mbgl/shader/text_shader.hpp72
12 files changed, 449 insertions, 0 deletions
diff --git a/include/mbgl/shader/composite_shader.hpp b/include/mbgl/shader/composite_shader.hpp
new file mode 100644
index 0000000000..c0c1704f3d
--- /dev/null
+++ b/include/mbgl/shader/composite_shader.hpp
@@ -0,0 +1,29 @@
+#ifndef MBGL_SHADER_COMPOSITE_SHADER
+#define MBGL_SHADER_COMPOSITE_SHADER
+
+#include <mbgl/shader/shader.hpp>
+
+namespace mbgl {
+
+class CompositeShader : public Shader {
+public:
+ CompositeShader();
+
+ void bind(char *offset);
+
+ void setImage(int32_t image);
+ void setOpacity(float opacity);
+
+private:
+ int32_t a_pos = -1;
+
+ int32_t image = 0;
+ int32_t u_image = -1;
+
+ float opacity = 0;
+ int32_t u_opacity = -1;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/shader/dot_shader.hpp b/include/mbgl/shader/dot_shader.hpp
new file mode 100644
index 0000000000..d8d649db9c
--- /dev/null
+++ b/include/mbgl/shader/dot_shader.hpp
@@ -0,0 +1,33 @@
+#ifndef MBGL_SHADER_SHADER_DOT
+#define MBGL_SHADER_SHADER_DOT
+
+#include <mbgl/shader/shader.hpp>
+
+namespace mbgl {
+
+ class DotShader : public Shader {
+ public:
+ DotShader();
+
+ void bind(char *offset);
+
+ void setColor(const std::array<float, 4>& color);
+ void setSize(float size);
+ void setBlur(float blur);
+
+ private:
+ int32_t a_pos = -1;
+
+ std::array<float, 4> color = {{}};
+ int32_t u_color = -1;
+
+ float size = 0;
+ int32_t u_size = -1;
+
+ float blur = 0;
+ int32_t u_blur = -1;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/shader/gaussian_shader.hpp b/include/mbgl/shader/gaussian_shader.hpp
new file mode 100644
index 0000000000..a4b9d09f3a
--- /dev/null
+++ b/include/mbgl/shader/gaussian_shader.hpp
@@ -0,0 +1,29 @@
+#ifndef MBGL_RENDERER_SHADER_GAUSSIAN
+#define MBGL_RENDERER_SHADER_GAUSSIAN
+
+#include <mbgl/shader/shader.hpp>
+
+namespace mbgl {
+
+class GaussianShader : public Shader {
+public:
+ GaussianShader();
+
+ void bind(char *offset);
+
+ void setImage(int32_t image);
+ void setOffset(const std::array<float, 2>& offset);
+
+private:
+ int32_t a_pos = -1;
+
+ int32_t image = 0;
+ int32_t u_image = -1;
+
+ std::array<float, 2> offset = {{}};
+ int32_t u_offset = -1;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/shader/icon_shader.hpp b/include/mbgl/shader/icon_shader.hpp
new file mode 100644
index 0000000000..b97b3c2be3
--- /dev/null
+++ b/include/mbgl/shader/icon_shader.hpp
@@ -0,0 +1,42 @@
+#ifndef MBGL_SHADER_SHADER_ICON
+#define MBGL_SHADER_SHADER_ICON
+
+#include <mbgl/shader/shader.hpp>
+
+namespace mbgl {
+
+class IconShader : public Shader {
+public:
+ IconShader();
+
+ void bind(char *offset);
+
+ void setImage(int32_t image);
+ void setColor(const std::array<float, 4>& color);
+ void setDimension(const std::array<float, 2>& dimension);
+ void setSize(float size);
+ void setRatio(float ratio);
+
+private:
+ int32_t a_pos = -1;
+ int32_t a_tex = -1;
+
+ int32_t image = -1;
+ int32_t u_image = -1;
+
+ std::array<float, 4> color = {{}};
+ int32_t u_color = -1;
+
+ std::array<float, 2> dimension = {{}};
+ int32_t u_dimension = -1;
+
+ float size = 0;
+ int32_t u_size = -1;
+
+ float ratio = 0;
+ int32_t u_ratio = -1;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/shader/line_shader.hpp b/include/mbgl/shader/line_shader.hpp
new file mode 100644
index 0000000000..38efe0b71f
--- /dev/null
+++ b/include/mbgl/shader/line_shader.hpp
@@ -0,0 +1,45 @@
+#ifndef MBGL_SHADER_SHADER_LINE
+#define MBGL_SHADER_SHADER_LINE
+
+#include <mbgl/shader/shader.hpp>
+
+namespace mbgl {
+
+class LineShader : public Shader {
+public:
+ LineShader();
+
+ void bind(char *offset);
+
+ void setExtrudeMatrix(const std::array<float, 16>& exmatrix);
+ void setColor(const std::array<float, 4>& color);
+ void setLineWidth(const std::array<float, 2>& linewidth);
+ void setRatio(float ratio);
+ void setDashArray(const std::array<float, 2>& dasharray);
+ void setDebug(float debug);
+
+private:
+ int32_t a_pos = -1;
+ int32_t a_extrude = -1;
+ int32_t a_linesofar = -1;
+
+ std::array<float, 16> exmatrix = {{}};
+ int32_t u_exmatrix = -1;
+
+ std::array<float, 4> color = {{}};
+ int32_t u_color = -1;
+
+ std::array<float, 2> linewidth = {{}};
+ int32_t u_linewidth = -1;
+
+ float ratio = 0;
+ int32_t u_ratio = -1;
+
+ std::array<float, 2> dasharray = {{}};
+ int32_t u_dasharray = -1;
+};
+
+
+}
+
+#endif
diff --git a/include/mbgl/shader/linejoin_shader.hpp b/include/mbgl/shader/linejoin_shader.hpp
new file mode 100644
index 0000000000..5a5c97e921
--- /dev/null
+++ b/include/mbgl/shader/linejoin_shader.hpp
@@ -0,0 +1,37 @@
+#ifndef MBGL_SHADER_SHADER_LINEJOIN
+#define MBGL_SHADER_SHADER_LINEJOIN
+
+#include <mbgl/shader/shader.hpp>
+
+namespace mbgl {
+
+class LinejoinShader : public Shader {
+public:
+ LinejoinShader();
+
+ void bind(char *offset);
+
+ void setColor(const std::array<float, 4>& color);
+ void setWorld(const std::array<float, 2>& world);
+ void setLineWidth(const std::array<float, 2>& linewidth);
+ void setSize(float size);
+
+private:
+ int32_t a_pos = -1;
+
+ std::array<float, 4> color = {{}};
+ int32_t u_color = -1;
+
+ std::array<float, 2> world = {{}};
+ int32_t u_world = -1;
+
+ std::array<float, 2> linewidth = {{}};
+ int32_t u_linewidth = -1;
+
+ float size = 0;
+ int32_t u_size = -1;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/shader/outline_shader.hpp b/include/mbgl/shader/outline_shader.hpp
new file mode 100644
index 0000000000..551e31ca57
--- /dev/null
+++ b/include/mbgl/shader/outline_shader.hpp
@@ -0,0 +1,29 @@
+#ifndef MBGL_SHADER_SHADER_OUTLINE
+#define MBGL_SHADER_SHADER_OUTLINE
+
+#include <mbgl/shader/shader.hpp>
+
+namespace mbgl {
+
+class OutlineShader : public Shader {
+public:
+ OutlineShader();
+
+ void bind(char *offset);
+
+ void setColor(const std::array<float, 4>& color);
+ void setWorld(const std::array<float, 2>& world);
+
+private:
+ int32_t a_pos = -1;
+
+ std::array<float, 4> color = {{}};
+ int32_t u_color = -1;
+
+ std::array<float, 2> world = {{}};
+ int32_t u_world = -1;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/shader/pattern_shader.hpp b/include/mbgl/shader/pattern_shader.hpp
new file mode 100644
index 0000000000..b1b49b54df
--- /dev/null
+++ b/include/mbgl/shader/pattern_shader.hpp
@@ -0,0 +1,45 @@
+#ifndef MBGL_SHADER_SHADER_PATTERN
+#define MBGL_SHADER_SHADER_PATTERN
+
+#include <mbgl/shader/shader.hpp>
+
+namespace mbgl {
+
+class PatternShader : public Shader {
+public:
+ PatternShader();
+
+ void bind(char *offset);
+
+ void setColor(const std::array<float, 4>& color);
+ void setOffset(const std::array<float, 2>& offset);
+ void setPatternSize(const std::array<float, 2>& pattern_size);
+ void setPatternTopLeft(const std::array<float, 2>& pattern_tl);
+ void setPatternBottomRight(const std::array<float, 2>& pattern_br);
+ void setMix(float mix);
+
+private:
+ int32_t a_pos = -1;
+
+ std::array<float, 4> color = {{}};
+ int32_t u_color = -1;
+
+ std::array<float, 2> offset = {{}};
+ int32_t u_offset = -1;
+
+ std::array<float, 2> pattern_size = {{}};
+ int32_t u_pattern_size = -1;
+
+ std::array<float, 2> pattern_tl = {{}};
+ int32_t u_pattern_tl = -1;
+
+ std::array<float, 2> pattern_br = {{}};
+ int32_t u_pattern_br = -1;
+
+ float mix = 0;
+ int32_t u_mix = -1;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/shader/plain_shader.hpp b/include/mbgl/shader/plain_shader.hpp
new file mode 100644
index 0000000000..277788431f
--- /dev/null
+++ b/include/mbgl/shader/plain_shader.hpp
@@ -0,0 +1,26 @@
+#ifndef MBGL_SHADER_SHADER_PLAIN
+#define MBGL_SHADER_SHADER_PLAIN
+
+#include <mbgl/shader/shader.hpp>
+
+namespace mbgl {
+
+class PlainShader : public Shader {
+public:
+ PlainShader();
+
+ void bind(char *offset);
+
+ void setColor(float r, float g, float b, float a);
+ void setColor(const std::array<float, 4>& color);
+
+private:
+ int32_t a_pos = -1;
+
+ std::array<float, 4> color = {{}};
+ int32_t u_color = -1;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/shader/raster_shader.hpp b/include/mbgl/shader/raster_shader.hpp
new file mode 100644
index 0000000000..ec69fa7238
--- /dev/null
+++ b/include/mbgl/shader/raster_shader.hpp
@@ -0,0 +1,33 @@
+#ifndef MBGL_RENDERER_SHADER_RASTER
+#define MBGL_RENDERER_SHADER_RASTER
+
+#include <mbgl/shader/shader.hpp>
+
+namespace mbgl {
+
+class RasterShader : public Shader {
+public:
+ RasterShader();
+
+ void bind(char *offset);
+
+ void setImage(int32_t image);
+ void setOpacity(float opacity);
+ void setBuffer(float buffer);
+
+private:
+ int32_t a_pos = -1;
+
+ int32_t image = 0;
+ int32_t u_image = -1;
+
+ float opacity = 0;
+ int32_t u_opacity = -1;
+
+ float buffer = 0;
+ int32_t u_buffer = -1;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/shader/shader.hpp b/include/mbgl/shader/shader.hpp
new file mode 100644
index 0000000000..2398cb12e3
--- /dev/null
+++ b/include/mbgl/shader/shader.hpp
@@ -0,0 +1,29 @@
+#ifndef MBGL_RENDERER_SHADER
+#define MBGL_RENDERER_SHADER
+
+#include <cstdint>
+#include <array>
+#include <mbgl/util/noncopyable.hpp>
+
+namespace mbgl {
+
+class Shader : private util::noncopyable {
+public:
+ Shader(const char *vertex, const char *fragment);
+ ~Shader();
+ bool valid;
+ uint32_t program;
+
+ void setMatrix(const std::array<float, 16>& matrix);
+
+private:
+ bool compileShader(uint32_t *shader, uint32_t type, const char *source);
+
+protected:
+ std::array<float, 16> matrix = {{}};
+ int32_t u_matrix = -1;
+};
+
+}
+
+#endif
diff --git a/include/mbgl/shader/text_shader.hpp b/include/mbgl/shader/text_shader.hpp
new file mode 100644
index 0000000000..554b890fb0
--- /dev/null
+++ b/include/mbgl/shader/text_shader.hpp
@@ -0,0 +1,72 @@
+#ifndef MBGL_SHADER_TEXT_SHADER
+#define MBGL_SHADER_TEXT_SHADER
+
+#include "shader.hpp"
+
+namespace mbgl {
+
+class TextShader : public Shader {
+public:
+ TextShader();
+
+ void bind(char *offset);
+
+ void setColor(float r, float g, float b, float a);
+ void setColor(const std::array<float, 4> &color);
+ void setBuffer(float buffer);
+ void setGamma(float gamma);
+ void setExtrudeMatrix(const std::array<float, 16> &exmatrix);
+ void setAngle(float angle);
+ void setZoom(float zoom);
+ void setFlip(float flip);
+ void setFadeDist(float fadedist);
+ void setMinFadeZoom(float minfadezoom);
+ void setMaxFadeZoom(float maxfadezoom);
+ void setFadeZoom(float fadezoom);
+ void setTextureSize(const std::array<float, 2> &texsize);
+
+private:
+ int32_t a_pos = -1;
+ int32_t a_offset = -1;
+ int32_t a_data1 = -1;
+ int32_t a_data2 = -1;
+
+ std::array<float, 4> color = {{}};
+ int32_t u_color = -1;
+
+ float buffer = 0.0f;
+ int32_t u_buffer = -1;
+
+ float gamma = 0.0f;
+ int32_t u_gamma = -1;
+
+ std::array<float, 16> exmatrix = {{}};
+ int32_t u_exmatrix = -1;
+
+ float angle = 0.0f;
+ int32_t u_angle = -1;
+
+ float zoom = 0.0f;
+ int32_t u_zoom = -1;
+
+ float flip = 0.0f;
+ int32_t u_flip = -1;
+
+ float fadedist = 0.0f;
+ int32_t u_fadedist = -1;
+
+ float minfadezoom = 0.0f;
+ int32_t u_minfadezoom = -1;
+
+ float maxfadezoom = 0.0f;
+ int32_t u_maxfadezoom = -1;
+
+ float fadezoom = 0.0f;
+ int32_t u_fadezoom = -1;
+
+ std::array<float, 2> texsize = {{}};
+ int32_t u_texsize = -1;
+};
+}
+
+#endif