summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-09-30 12:20:29 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-10-05 10:52:19 -0700
commit73334ac8fa330af05dd91906a4e5d1bbda7d5c34 (patch)
treeaeba3681352926e5837d2d68b70a08f52d6ed026 /src
parent7a3bef091e7390fa57bf33f1a704c893768b5625 (diff)
downloadqtlocation-mapboxgl-73334ac8fa330af05dd91906a4e5d1bbda7d5c34.tar.gz
[core] Move shader and uniform to gl directory
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/gl/shader.cpp (renamed from src/mbgl/shader/shader.cpp)10
-rw-r--r--src/mbgl/gl/shader.hpp51
-rw-r--r--src/mbgl/gl/uniform.cpp (renamed from src/mbgl/shader/uniform.cpp)6
-rw-r--r--src/mbgl/gl/uniform.hpp (renamed from src/mbgl/shader/uniform.hpp)8
-rw-r--r--src/mbgl/gl/vao.cpp4
-rw-r--r--src/mbgl/gl/vao.hpp6
-rw-r--r--src/mbgl/renderer/painter.cpp2
-rw-r--r--src/mbgl/shader/circle_shader.hpp22
-rw-r--r--src/mbgl/shader/circle_vertex.cpp2
-rw-r--r--src/mbgl/shader/collision_box_shader.hpp14
-rw-r--r--src/mbgl/shader/collision_box_vertex.cpp2
-rw-r--r--src/mbgl/shader/icon_shader.hpp22
-rw-r--r--src/mbgl/shader/line_shader.hpp28
-rw-r--r--src/mbgl/shader/line_vertex.cpp2
-rw-r--r--src/mbgl/shader/linepattern_shader.hpp44
-rw-r--r--src/mbgl/shader/linesdf_shader.hpp42
-rw-r--r--src/mbgl/shader/outline_shader.hpp14
-rw-r--r--src/mbgl/shader/outlinepattern_shader.hpp38
-rw-r--r--src/mbgl/shader/pattern_shader.hpp36
-rw-r--r--src/mbgl/shader/plain_shader.hpp12
-rw-r--r--src/mbgl/shader/plain_vertex.cpp2
-rw-r--r--src/mbgl/shader/raster_shader.hpp32
-rw-r--r--src/mbgl/shader/raster_vertex.cpp2
-rw-r--r--src/mbgl/shader/sdf_shader.hpp36
-rw-r--r--src/mbgl/shader/shader.hpp52
-rw-r--r--src/mbgl/shader/shaders.hpp2
-rw-r--r--src/mbgl/shader/texture_rect_vertex.cpp2
27 files changed, 249 insertions, 244 deletions
diff --git a/src/mbgl/shader/shader.cpp b/src/mbgl/gl/shader.cpp
index 1198300cec..5b3712e80d 100644
--- a/src/mbgl/shader/shader.cpp
+++ b/src/mbgl/gl/shader.cpp
@@ -1,4 +1,4 @@
-#include <mbgl/shader/shader.hpp>
+#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/util/stopwatch.hpp>
@@ -15,11 +15,12 @@
#include <cassert>
namespace mbgl {
+namespace gl {
Shader::Shader(const char* name_,
const char* vertexSource,
const char* fragmentSource,
- gl::Context& context,
+ Context& context,
Defines defines)
: name(name_),
program(context.createProgram()),
@@ -71,7 +72,7 @@ Shader::Shader(const char* name_,
}
}
-bool Shader::compileShader(gl::UniqueShader& shader, const GLchar *source) {
+bool Shader::compileShader(UniqueShader& shader, const GLchar *source) {
GLint status = 0;
const GLsizei lengths = static_cast<GLsizei>(std::strlen(source));
@@ -107,8 +108,9 @@ Shader::~Shader() {
}
}
-gl::UniformLocation Shader::getUniformLocation(const char* uniform) const {
+UniformLocation Shader::getUniformLocation(const char* uniform) const {
return MBGL_CHECK_ERROR(glGetUniformLocation(program.get(), uniform));
}
+} // namespace gl
} // namespace mbgl
diff --git a/src/mbgl/gl/shader.hpp b/src/mbgl/gl/shader.hpp
new file mode 100644
index 0000000000..f73400bc15
--- /dev/null
+++ b/src/mbgl/gl/shader.hpp
@@ -0,0 +1,51 @@
+#pragma once
+
+#include <mbgl/gl/types.hpp>
+#include <mbgl/gl/object.hpp>
+#include <mbgl/util/noncopyable.hpp>
+
+namespace mbgl {
+namespace gl {
+
+class Context;
+
+class Shader : private util::noncopyable {
+public:
+ ~Shader();
+ const char* name;
+
+ ProgramID getID() const {
+ return program.get();
+ }
+
+ UniformLocation getUniformLocation(const char* uniform) const;
+
+ enum Defines : bool {
+ None = false,
+ Overdraw = true,
+ };
+
+protected:
+ Shader(const char* name_,
+ const char* vertex,
+ const char* fragment,
+ Context&,
+ Defines defines = Defines::None);
+
+public:
+ static constexpr AttributeLocation a_pos = 0;
+ static constexpr AttributeLocation a_extrude = 1;
+ static constexpr AttributeLocation a_offset = 2;
+ static constexpr AttributeLocation a_data = 3;
+ static constexpr AttributeLocation a_texture_pos = 4;
+
+private:
+ bool compileShader(UniqueShader&, const char *source);
+
+ UniqueProgram program;
+ UniqueShader vertexShader;
+ UniqueShader fragmentShader;
+};
+
+} // namespace gl
+} // namespace mbgl
diff --git a/src/mbgl/shader/uniform.cpp b/src/mbgl/gl/uniform.cpp
index bd4c13eee1..07a27963d9 100644
--- a/src/mbgl/shader/uniform.cpp
+++ b/src/mbgl/gl/uniform.cpp
@@ -1,8 +1,9 @@
-#include <mbgl/shader/uniform.hpp>
-#include <mbgl/util/color.hpp>
+#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) {
@@ -52,4 +53,5 @@ void UniformMatrix<4>::bind(const std::array<float, 16>& t) {
// Add more as needed.
+} // namespace gl
} // namespace mbgl
diff --git a/src/mbgl/shader/uniform.hpp b/src/mbgl/gl/uniform.hpp
index 5df6942ff6..5af781043d 100644
--- a/src/mbgl/shader/uniform.hpp
+++ b/src/mbgl/gl/uniform.hpp
@@ -1,10 +1,11 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
+#include <mbgl/gl/shader.hpp>
#include <array>
namespace mbgl {
+namespace gl {
template <typename T>
class Uniform {
@@ -24,7 +25,7 @@ private:
void bind(const T&);
T current;
- gl::UniformLocation location;
+ UniformLocation location;
};
template <size_t C, size_t R = C>
@@ -53,7 +54,8 @@ private:
void bind(const T&);
T current;
- gl::UniformLocation location;
+ UniformLocation location;
};
+} // namespace gl
} // namespace mbgl
diff --git a/src/mbgl/gl/vao.cpp b/src/mbgl/gl/vao.cpp
index 527dd214fb..26a03a8a16 100644
--- a/src/mbgl/gl/vao.cpp
+++ b/src/mbgl/gl/vao.cpp
@@ -30,7 +30,7 @@ void VertexArrayObject::bindVertexArrayObject(gl::Context& context) {
context.vertexArrayObject = *vertexArray;
}
-void VertexArrayObject::verifyBinding(Shader& shader,
+void VertexArrayObject::verifyBinding(gl::Shader& shader,
gl::BufferID vertexBuffer,
gl::BufferID elementsBuffer,
int8_t* offset) {
@@ -47,7 +47,7 @@ void VertexArrayObject::verifyBinding(Shader& shader,
}
}
-void VertexArrayObject::storeBinding(Shader& shader,
+void VertexArrayObject::storeBinding(gl::Shader& shader,
gl::BufferID vertexBuffer,
gl::BufferID elementsBuffer,
int8_t* offset) {
diff --git a/src/mbgl/gl/vao.hpp b/src/mbgl/gl/vao.hpp
index c2e3470367..bedc3abbc7 100644
--- a/src/mbgl/gl/vao.hpp
+++ b/src/mbgl/gl/vao.hpp
@@ -1,6 +1,6 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
+#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/context.hpp>
#include <mbgl/gl/vertex_buffer.hpp>
#include <mbgl/util/noncopyable.hpp>
@@ -57,11 +57,11 @@ public:
private:
void bindVertexArrayObject(gl::Context&);
- void storeBinding(Shader& shader,
+ void storeBinding(gl::Shader& shader,
gl::BufferID vertexBuffer,
gl::BufferID elementsBuffer,
int8_t* offset);
- void verifyBinding(Shader& shader,
+ void verifyBinding(gl::Shader& shader,
gl::BufferID vertexBuffer,
gl::BufferID elementsBuffer,
int8_t* offset);
diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp
index 825ac053f1..a129e6c085 100644
--- a/src/mbgl/renderer/painter.cpp
+++ b/src/mbgl/renderer/painter.cpp
@@ -67,7 +67,7 @@ Painter::Painter(const TransformState& state_)
shaders = std::make_unique<Shaders>(context);
#ifndef NDEBUG
- overdrawShaders = std::make_unique<Shaders>(context, Shader::Overdraw);
+ overdrawShaders = std::make_unique<Shaders>(context, gl::Shader::Overdraw);
#endif
// Reset GL values
diff --git a/src/mbgl/shader/circle_shader.hpp b/src/mbgl/shader/circle_shader.hpp
index 8ea13c7e00..99f099800d 100644
--- a/src/mbgl/shader/circle_shader.hpp
+++ b/src/mbgl/shader/circle_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,21 +12,21 @@ template <class> class VertexBuffer;
class CircleVertex;
-class CircleShader : public Shader {
+class CircleShader : public gl::Shader {
public:
CircleShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<CircleVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
- Uniform<float> u_devicepixelratio = {"u_devicepixelratio", *this};
- Uniform<Color> u_color = {"u_color", *this};
- Uniform<float> u_radius = {"u_radius", *this};
- Uniform<float> u_blur = {"u_blur", *this};
- Uniform<float> u_opacity = {"u_opacity", *this};
- Uniform<int32_t> u_scale_with_map = {"u_scale_with_map", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
+ gl::Uniform<float> u_devicepixelratio = {"u_devicepixelratio", *this};
+ gl::Uniform<Color> u_color = {"u_color", *this};
+ gl::Uniform<float> u_radius = {"u_radius", *this};
+ gl::Uniform<float> u_blur = {"u_blur", *this};
+ gl::Uniform<float> u_opacity = {"u_opacity", *this};
+ gl::Uniform<int32_t> u_scale_with_map = {"u_scale_with_map", *this};
};
} // namespace mbgl
diff --git a/src/mbgl/shader/circle_vertex.cpp b/src/mbgl/shader/circle_vertex.cpp
index 3f14fc5747..e449734ca4 100644
--- a/src/mbgl/shader/circle_vertex.cpp
+++ b/src/mbgl/shader/circle_vertex.cpp
@@ -1,5 +1,5 @@
#include <mbgl/shader/circle_vertex.hpp>
-#include <mbgl/shader/shader.hpp>
+#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {
diff --git a/src/mbgl/shader/collision_box_shader.hpp b/src/mbgl/shader/collision_box_shader.hpp
index fe99ef274e..7248193a21 100644
--- a/src/mbgl/shader/collision_box_shader.hpp
+++ b/src/mbgl/shader/collision_box_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,17 +11,17 @@ template <class> class VertexBuffer;
class CollisionBoxVertex;
-class CollisionBoxShader : public Shader {
+class CollisionBoxShader : public gl::Shader {
public:
CollisionBoxShader(gl::Context&);
void bind(const gl::VertexBuffer<CollisionBoxVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<float> u_scale = {"u_scale", *this};
- Uniform<float> u_zoom = {"u_zoom", *this};
- Uniform<float> u_maxzoom = {"u_maxzoom", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<float> u_scale = {"u_scale", *this};
+ gl::Uniform<float> u_zoom = {"u_zoom", *this};
+ gl::Uniform<float> u_maxzoom = {"u_maxzoom", *this};
};
} // namespace mbgl
diff --git a/src/mbgl/shader/collision_box_vertex.cpp b/src/mbgl/shader/collision_box_vertex.cpp
index d12433ee7d..0295a78b55 100644
--- a/src/mbgl/shader/collision_box_vertex.cpp
+++ b/src/mbgl/shader/collision_box_vertex.cpp
@@ -1,5 +1,5 @@
#include <mbgl/shader/collision_box_vertex.hpp>
-#include <mbgl/shader/shader.hpp>
+#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {
diff --git a/src/mbgl/shader/icon_shader.hpp b/src/mbgl/shader/icon_shader.hpp
index b7d724e05d..9c7d073683 100644
--- a/src/mbgl/shader/icon_shader.hpp
+++ b/src/mbgl/shader/icon_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,21 +11,21 @@ template <class> class VertexBuffer;
class TextureRectVertex;
-class IconShader : public Shader {
+class IconShader : public gl::Shader {
public:
IconShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<TextureRectVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
- Uniform<float> u_zoom = {"u_zoom", *this};
- Uniform<float> u_opacity = {"u_opacity", *this};
- Uniform<std::array<float, 2>> u_texsize = {"u_texsize", *this};
- Uniform<int32_t> u_rotate_with_map = {"u_rotate_with_map", *this};
- Uniform<int32_t> u_texture = {"u_texture", *this};
- Uniform<int32_t> u_fadetexture = {"u_fadetexture", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
+ gl::Uniform<float> u_zoom = {"u_zoom", *this};
+ gl::Uniform<float> u_opacity = {"u_opacity", *this};
+ gl::Uniform<std::array<float, 2>> u_texsize = {"u_texsize", *this};
+ gl::Uniform<int32_t> u_rotate_with_map = {"u_rotate_with_map", *this};
+ gl::Uniform<int32_t> u_texture = {"u_texture", *this};
+ gl::Uniform<int32_t> u_fadetexture = {"u_fadetexture", *this};
};
} // namespace mbgl
diff --git a/src/mbgl/shader/line_shader.hpp b/src/mbgl/shader/line_shader.hpp
index 4c1f395dfc..74ca7f16df 100644
--- a/src/mbgl/shader/line_shader.hpp
+++ b/src/mbgl/shader/line_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,24 +12,24 @@ template <class> class VertexBuffer;
class LineVertex;
-class LineShader : public Shader {
+class LineShader : public gl::Shader {
public:
LineShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<LineVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<Color> u_color = {"u_color", *this};
- Uniform<float> u_opacity = {"u_opacity", *this};
- Uniform<float> u_ratio = {"u_ratio", *this};
- Uniform<float> u_linewidth = {"u_linewidth", *this};
- Uniform<float> u_gapwidth = {"u_gapwidth", *this};
- Uniform<float> u_antialiasing = {"u_antialiasing", *this};
- Uniform<float> u_blur = {"u_blur", *this};
- Uniform<float> u_extra = {"u_extra", *this};
- Uniform<float> u_offset = {"u_offset", *this};
- UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<Color> u_color = {"u_color", *this};
+ gl::Uniform<float> u_opacity = {"u_opacity", *this};
+ gl::Uniform<float> u_ratio = {"u_ratio", *this};
+ gl::Uniform<float> u_linewidth = {"u_linewidth", *this};
+ gl::Uniform<float> u_gapwidth = {"u_gapwidth", *this};
+ gl::Uniform<float> u_antialiasing = {"u_antialiasing", *this};
+ gl::Uniform<float> u_blur = {"u_blur", *this};
+ gl::Uniform<float> u_extra = {"u_extra", *this};
+ gl::Uniform<float> u_offset = {"u_offset", *this};
+ gl::UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
};
diff --git a/src/mbgl/shader/line_vertex.cpp b/src/mbgl/shader/line_vertex.cpp
index a7a51d9fd7..c40c60e9f6 100644
--- a/src/mbgl/shader/line_vertex.cpp
+++ b/src/mbgl/shader/line_vertex.cpp
@@ -1,5 +1,5 @@
#include <mbgl/shader/line_vertex.hpp>
-#include <mbgl/shader/shader.hpp>
+#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {
diff --git a/src/mbgl/shader/linepattern_shader.hpp b/src/mbgl/shader/linepattern_shader.hpp
index c6a30b6c47..94b4916f25 100644
--- a/src/mbgl/shader/linepattern_shader.hpp
+++ b/src/mbgl/shader/linepattern_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,32 +11,32 @@ template <class> class VertexBuffer;
class LineVertex;
-class LinepatternShader : public Shader {
+class LinepatternShader : public gl::Shader {
public:
LinepatternShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<LineVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<float> u_linewidth = {"u_linewidth", *this};
- Uniform<float> u_gapwidth = {"u_gapwidth", *this};
- Uniform<float> u_antialiasing = {"u_antialiasing", *this};
- Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
- Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
- Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
- Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
- Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
- Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
- Uniform<float> u_ratio = {"u_ratio", *this};
- Uniform<float> u_point = {"u_point", *this};
- Uniform<float> u_blur = {"u_blur", *this};
- Uniform<float> u_fade = {"u_fade", *this};
- Uniform<float> u_opacity = {"u_opacity", *this};
- Uniform<float> u_extra = {"u_extra", *this};
- Uniform<float> u_offset = {"u_offset", *this};
- Uniform<int32_t> u_image = {"u_image", *this};
- UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<float> u_linewidth = {"u_linewidth", *this};
+ gl::Uniform<float> u_gapwidth = {"u_gapwidth", *this};
+ gl::Uniform<float> u_antialiasing = {"u_antialiasing", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
+ gl::Uniform<float> u_ratio = {"u_ratio", *this};
+ gl::Uniform<float> u_point = {"u_point", *this};
+ gl::Uniform<float> u_blur = {"u_blur", *this};
+ gl::Uniform<float> u_fade = {"u_fade", *this};
+ gl::Uniform<float> u_opacity = {"u_opacity", *this};
+ gl::Uniform<float> u_extra = {"u_extra", *this};
+ gl::Uniform<float> u_offset = {"u_offset", *this};
+ gl::Uniform<int32_t> u_image = {"u_image", *this};
+ gl::UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
};
} // namespace mbgl
diff --git a/src/mbgl/shader/linesdf_shader.hpp b/src/mbgl/shader/linesdf_shader.hpp
index def4a2a983..41ad8dc22a 100644
--- a/src/mbgl/shader/linesdf_shader.hpp
+++ b/src/mbgl/shader/linesdf_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,31 +12,31 @@ template <class> class VertexBuffer;
class LineVertex;
-class LineSDFShader : public Shader {
+class LineSDFShader : public gl::Shader {
public:
LineSDFShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<LineVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<Color> u_color = {"u_color", *this};
- Uniform<float> u_opacity = {"u_opacity", *this};
- Uniform<float> u_linewidth = {"u_linewidth", *this};
- Uniform<float> u_gapwidth = {"u_gapwidth", *this};
- Uniform<float> u_antialiasing = {"u_antialiasing", *this};
- Uniform<float> u_ratio = {"u_ratio", *this};
- Uniform<float> u_blur = {"u_blur", *this};
- Uniform<std::array<float, 2>> u_patternscale_a = { "u_patternscale_a", *this};
- Uniform<float> u_tex_y_a = {"u_tex_y_a", *this};
- Uniform<std::array<float, 2>> u_patternscale_b = { "u_patternscale_b", *this};
- Uniform<float> u_tex_y_b = {"u_tex_y_b", *this};
- Uniform<int32_t> u_image = {"u_image", *this};
- Uniform<float> u_sdfgamma = {"u_sdfgamma", *this};
- Uniform<float> u_mix = {"u_mix", *this};
- Uniform<float> u_extra = {"u_extra", *this};
- Uniform<float> u_offset = {"u_offset", *this};
- UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<Color> u_color = {"u_color", *this};
+ gl::Uniform<float> u_opacity = {"u_opacity", *this};
+ gl::Uniform<float> u_linewidth = {"u_linewidth", *this};
+ gl::Uniform<float> u_gapwidth = {"u_gapwidth", *this};
+ gl::Uniform<float> u_antialiasing = {"u_antialiasing", *this};
+ gl::Uniform<float> u_ratio = {"u_ratio", *this};
+ gl::Uniform<float> u_blur = {"u_blur", *this};
+ gl::Uniform<std::array<float, 2>> u_patternscale_a = { "u_patternscale_a", *this};
+ gl::Uniform<float> u_tex_y_a = {"u_tex_y_a", *this};
+ gl::Uniform<std::array<float, 2>> u_patternscale_b = { "u_patternscale_b", *this};
+ gl::Uniform<float> u_tex_y_b = {"u_tex_y_b", *this};
+ gl::Uniform<int32_t> u_image = {"u_image", *this};
+ gl::Uniform<float> u_sdfgamma = {"u_sdfgamma", *this};
+ gl::Uniform<float> u_mix = {"u_mix", *this};
+ gl::Uniform<float> u_extra = {"u_extra", *this};
+ gl::Uniform<float> u_offset = {"u_offset", *this};
+ gl::UniformMatrix<2> u_antialiasingmatrix = {"u_antialiasingmatrix", *this};
};
diff --git a/src/mbgl/shader/outline_shader.hpp b/src/mbgl/shader/outline_shader.hpp
index 09fa9431c9..50e7a2dfc2 100644
--- a/src/mbgl/shader/outline_shader.hpp
+++ b/src/mbgl/shader/outline_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,17 +12,17 @@ template <class> class VertexBuffer;
class PlainVertex;
-class OutlineShader : public Shader {
+class OutlineShader : public gl::Shader {
public:
OutlineShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<PlainVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<Color> u_outline_color = {"u_outline_color", *this};
- Uniform<float> u_opacity = {"u_opacity", *this};
- Uniform<std::array<float, 2>> u_world = {"u_world", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<Color> u_outline_color = {"u_outline_color", *this};
+ gl::Uniform<float> u_opacity = {"u_opacity", *this};
+ gl::Uniform<std::array<float, 2>> u_world = {"u_world", *this};
};
} // namespace mbgl
diff --git a/src/mbgl/shader/outlinepattern_shader.hpp b/src/mbgl/shader/outlinepattern_shader.hpp
index b6b1cda422..cb47f8731b 100644
--- a/src/mbgl/shader/outlinepattern_shader.hpp
+++ b/src/mbgl/shader/outlinepattern_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,29 +11,29 @@ template <class> class VertexBuffer;
class PlainVertex;
-class OutlinePatternShader : public Shader {
+class OutlinePatternShader : public gl::Shader {
public:
OutlinePatternShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<PlainVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
- Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
- Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
- Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
- Uniform<float> u_opacity = {"u_opacity", *this};
- Uniform<float> u_mix = {"u_mix", *this};
- Uniform<float> u_scale_a = {"u_scale_a", *this};
- Uniform<float> u_scale_b = {"u_scale_b", *this};
- Uniform<float> u_tile_units_to_pixels = {"u_tile_units_to_pixels", *this};
- Uniform<int32_t> u_image = {"u_image", *this};
- Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
- Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
- Uniform<std::array<float, 2>> u_pixel_coord_upper = {"u_pixel_coord_upper", *this};
- Uniform<std::array<float, 2>> u_pixel_coord_lower = {"u_pixel_coord_lower", *this};
- Uniform<std::array<float, 2>> u_world = {"u_world", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
+ gl::Uniform<float> u_opacity = {"u_opacity", *this};
+ gl::Uniform<float> u_mix = {"u_mix", *this};
+ gl::Uniform<float> u_scale_a = {"u_scale_a", *this};
+ gl::Uniform<float> u_scale_b = {"u_scale_b", *this};
+ gl::Uniform<float> u_tile_units_to_pixels = {"u_tile_units_to_pixels", *this};
+ gl::Uniform<int32_t> u_image = {"u_image", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
+ gl::Uniform<std::array<float, 2>> u_pixel_coord_upper = {"u_pixel_coord_upper", *this};
+ gl::Uniform<std::array<float, 2>> u_pixel_coord_lower = {"u_pixel_coord_lower", *this};
+ gl::Uniform<std::array<float, 2>> u_world = {"u_world", *this};
};
} // namespace mbgl
diff --git a/src/mbgl/shader/pattern_shader.hpp b/src/mbgl/shader/pattern_shader.hpp
index 2b8590814c..f036a4849d 100644
--- a/src/mbgl/shader/pattern_shader.hpp
+++ b/src/mbgl/shader/pattern_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,28 +11,28 @@ template <class> class VertexBuffer;
class PlainVertex;
-class PatternShader : public Shader {
+class PatternShader : public gl::Shader {
public:
PatternShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<PlainVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
- Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
- Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
- Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
- Uniform<float> u_opacity = {"u_opacity", *this};
- Uniform<float> u_mix = {"u_mix", *this};
- Uniform<float> u_scale_a = {"u_scale_a", *this};
- Uniform<float> u_scale_b = {"u_scale_b", *this};
- Uniform<float> u_tile_units_to_pixels = {"u_tile_units_to_pixels", *this};
- Uniform<int32_t> u_image = {"u_image", *this};
- Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
- Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
- Uniform<std::array<float, 2>> u_pixel_coord_upper = {"u_pixel_coord_upper", *this};
- Uniform<std::array<float, 2>> u_pixel_coord_lower = {"u_pixel_coord_lower", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_tl_a = {"u_pattern_tl_a", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_br_a = {"u_pattern_br_a", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_tl_b = {"u_pattern_tl_b", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_br_b = {"u_pattern_br_b", *this};
+ gl::Uniform<float> u_opacity = {"u_opacity", *this};
+ gl::Uniform<float> u_mix = {"u_mix", *this};
+ gl::Uniform<float> u_scale_a = {"u_scale_a", *this};
+ gl::Uniform<float> u_scale_b = {"u_scale_b", *this};
+ gl::Uniform<float> u_tile_units_to_pixels = {"u_tile_units_to_pixels", *this};
+ gl::Uniform<int32_t> u_image = {"u_image", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_size_a = {"u_pattern_size_a", *this};
+ gl::Uniform<std::array<float, 2>> u_pattern_size_b = {"u_pattern_size_b", *this};
+ gl::Uniform<std::array<float, 2>> u_pixel_coord_upper = {"u_pixel_coord_upper", *this};
+ gl::Uniform<std::array<float, 2>> u_pixel_coord_lower = {"u_pixel_coord_lower", *this};
};
} // namespace mbgl
diff --git a/src/mbgl/shader/plain_shader.hpp b/src/mbgl/shader/plain_shader.hpp
index 7dbb212e1b..64cca095d8 100644
--- a/src/mbgl/shader/plain_shader.hpp
+++ b/src/mbgl/shader/plain_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,16 +12,16 @@ template <class> class VertexBuffer;
class PlainVertex;
-class PlainShader : public Shader {
+class PlainShader : public gl::Shader {
public:
PlainShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<PlainVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<Color> u_color = {"u_color", *this};
- Uniform<float> u_opacity = {"u_opacity", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<Color> u_color = {"u_color", *this};
+ gl::Uniform<float> u_opacity = {"u_opacity", *this};
};
} // namespace mbgl
diff --git a/src/mbgl/shader/plain_vertex.cpp b/src/mbgl/shader/plain_vertex.cpp
index 679ef05c39..85a97a9827 100644
--- a/src/mbgl/shader/plain_vertex.cpp
+++ b/src/mbgl/shader/plain_vertex.cpp
@@ -1,5 +1,5 @@
#include <mbgl/shader/plain_vertex.hpp>
-#include <mbgl/shader/shader.hpp>
+#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {
diff --git a/src/mbgl/shader/raster_shader.hpp b/src/mbgl/shader/raster_shader.hpp
index ca474ede15..063bf78fd7 100644
--- a/src/mbgl/shader/raster_shader.hpp
+++ b/src/mbgl/shader/raster_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
namespace mbgl {
@@ -11,26 +11,26 @@ template <class> class VertexBuffer;
class RasterVertex;
-class RasterShader : public Shader {
+class RasterShader : public gl::Shader {
public:
RasterShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<RasterVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<int32_t> u_image0 = {"u_image0", *this};
- Uniform<int32_t> u_image1 = {"u_image1", *this};
- Uniform<float> u_opacity0 = {"u_opacity0", *this};
- Uniform<float> u_opacity1 = {"u_opacity1", *this};
- Uniform<float> u_buffer_scale = {"u_buffer_scale", *this};
- Uniform<float> u_brightness_low = {"u_brightness_low", *this};
- Uniform<float> u_brightness_high = {"u_brightness_high", *this};
- Uniform<float> u_saturation_factor = {"u_saturation_factor", *this};
- Uniform<float> u_contrast_factor = {"u_contrast_factor", *this};
- Uniform<std::array<float, 3>> u_spin_weights = {"u_spin_weights", *this};
- Uniform<std::array<float, 2>> u_tl_parent = {"u_tl_parent", *this};
- Uniform<float> u_scale_parent = {"u_scale_parent", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<int32_t> u_image0 = {"u_image0", *this};
+ gl::Uniform<int32_t> u_image1 = {"u_image1", *this};
+ gl::Uniform<float> u_opacity0 = {"u_opacity0", *this};
+ gl::Uniform<float> u_opacity1 = {"u_opacity1", *this};
+ gl::Uniform<float> u_buffer_scale = {"u_buffer_scale", *this};
+ gl::Uniform<float> u_brightness_low = {"u_brightness_low", *this};
+ gl::Uniform<float> u_brightness_high = {"u_brightness_high", *this};
+ gl::Uniform<float> u_saturation_factor = {"u_saturation_factor", *this};
+ gl::Uniform<float> u_contrast_factor = {"u_contrast_factor", *this};
+ gl::Uniform<std::array<float, 3>> u_spin_weights = {"u_spin_weights", *this};
+ gl::Uniform<std::array<float, 2>> u_tl_parent = {"u_tl_parent", *this};
+ gl::Uniform<float> u_scale_parent = {"u_scale_parent", *this};
};
} // namespace mbgl
diff --git a/src/mbgl/shader/raster_vertex.cpp b/src/mbgl/shader/raster_vertex.cpp
index c77cacef88..47f267ea0e 100644
--- a/src/mbgl/shader/raster_vertex.cpp
+++ b/src/mbgl/shader/raster_vertex.cpp
@@ -1,5 +1,5 @@
#include <mbgl/shader/raster_vertex.hpp>
-#include <mbgl/shader/shader.hpp>
+#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {
diff --git a/src/mbgl/shader/sdf_shader.hpp b/src/mbgl/shader/sdf_shader.hpp
index 2e7f6d6795..5c10e2c52c 100644
--- a/src/mbgl/shader/sdf_shader.hpp
+++ b/src/mbgl/shader/sdf_shader.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <mbgl/shader/shader.hpp>
-#include <mbgl/shader/uniform.hpp>
+#include <mbgl/gl/shader.hpp>
+#include <mbgl/gl/uniform.hpp>
#include <mbgl/util/color.hpp>
namespace mbgl {
@@ -12,28 +12,28 @@ template <class> class VertexBuffer;
class TextureRectVertex;
-class SDFShader : public Shader {
+class SDFShader : public gl::Shader {
public:
SDFShader(gl::Context&, Defines defines = None);
void bind(const gl::VertexBuffer<TextureRectVertex>&,
const int8_t* offset);
- UniformMatrix<4> u_matrix = {"u_matrix", *this};
- Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
- Uniform<Color> u_color = {"u_color", *this};
- Uniform<float> u_opacity = {"u_opacity", *this};
- Uniform<std::array<float, 2>> u_texsize = {"u_texsize", *this};
- Uniform<float> u_buffer = {"u_buffer", *this};
- Uniform<float> u_gamma = {"u_gamma", *this};
- Uniform<float> u_zoom = {"u_zoom", *this};
- Uniform<float> u_pitch = {"u_pitch", *this};
- Uniform<float> u_bearing = {"u_bearing", *this};
- Uniform<float> u_aspect_ratio = {"u_aspect_ratio", *this};
- Uniform<int32_t> u_rotate_with_map = {"u_rotate_with_map", *this};
- Uniform<int32_t> u_pitch_with_map = {"u_pitch_with_map", *this};
- Uniform<int32_t> u_texture = {"u_texture", *this};
- Uniform<int32_t> u_fadetexture = {"u_fadetexture", *this};
+ gl::UniformMatrix<4> u_matrix = {"u_matrix", *this};
+ gl::Uniform<std::array<float, 2>> u_extrude_scale = {"u_extrude_scale", *this};
+ gl::Uniform<Color> u_color = {"u_color", *this};
+ gl::Uniform<float> u_opacity = {"u_opacity", *this};
+ gl::Uniform<std::array<float, 2>> u_texsize = {"u_texsize", *this};
+ gl::Uniform<float> u_buffer = {"u_buffer", *this};
+ gl::Uniform<float> u_gamma = {"u_gamma", *this};
+ gl::Uniform<float> u_zoom = {"u_zoom", *this};
+ gl::Uniform<float> u_pitch = {"u_pitch", *this};
+ gl::Uniform<float> u_bearing = {"u_bearing", *this};
+ gl::Uniform<float> u_aspect_ratio = {"u_aspect_ratio", *this};
+ gl::Uniform<int32_t> u_rotate_with_map = {"u_rotate_with_map", *this};
+ gl::Uniform<int32_t> u_pitch_with_map = {"u_pitch_with_map", *this};
+ gl::Uniform<int32_t> u_texture = {"u_texture", *this};
+ gl::Uniform<int32_t> u_fadetexture = {"u_fadetexture", *this};
};
} // namespace mbgl
diff --git a/src/mbgl/shader/shader.hpp b/src/mbgl/shader/shader.hpp
deleted file mode 100644
index 977edebd7e..0000000000
--- a/src/mbgl/shader/shader.hpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#pragma once
-
-#include <mbgl/gl/types.hpp>
-#include <mbgl/gl/object.hpp>
-#include <mbgl/util/noncopyable.hpp>
-#include <mbgl/util/optional.hpp>
-
-namespace mbgl {
-
-namespace gl {
-class Context;
-} // namespace gl
-
-class Shader : private util::noncopyable {
-public:
- ~Shader();
- const char* name;
-
- gl::ProgramID getID() const {
- return program.get();
- }
-
- gl::UniformLocation getUniformLocation(const char* uniform) const;
-
- enum Defines : bool {
- None = false,
- Overdraw = true,
- };
-
-protected:
- Shader(const char* name_,
- const char* vertex,
- const char* fragment,
- gl::Context&,
- Defines defines = Defines::None);
-
-public:
- static constexpr gl::AttributeLocation a_pos = 0;
- static constexpr gl::AttributeLocation a_extrude = 1;
- static constexpr gl::AttributeLocation a_offset = 2;
- static constexpr gl::AttributeLocation a_data = 3;
- static constexpr gl::AttributeLocation a_texture_pos = 4;
-
-private:
- bool compileShader(gl::UniqueShader&, const char *source);
-
- gl::UniqueProgram program;
- gl::UniqueShader vertexShader;
- gl::UniqueShader fragmentShader;
-};
-
-} // namespace mbgl
diff --git a/src/mbgl/shader/shaders.hpp b/src/mbgl/shader/shaders.hpp
index cf80a00d97..0c54631dd1 100644
--- a/src/mbgl/shader/shaders.hpp
+++ b/src/mbgl/shader/shaders.hpp
@@ -17,7 +17,7 @@ namespace mbgl {
class Shaders {
public:
- Shaders(gl::Context& context, Shader::Defines defines = Shader::None)
+ Shaders(gl::Context& context, gl::Shader::Defines defines = gl::Shader::None)
: plain(context, defines),
outline(context, defines),
outlinePattern(context, defines),
diff --git a/src/mbgl/shader/texture_rect_vertex.cpp b/src/mbgl/shader/texture_rect_vertex.cpp
index 4693ada9e7..cbb186ffb4 100644
--- a/src/mbgl/shader/texture_rect_vertex.cpp
+++ b/src/mbgl/shader/texture_rect_vertex.cpp
@@ -1,5 +1,5 @@
#include <mbgl/shader/texture_rect_vertex.hpp>
-#include <mbgl/shader/shader.hpp>
+#include <mbgl/gl/shader.hpp>
#include <mbgl/gl/gl.hpp>
namespace mbgl {