summaryrefslogtreecommitdiff
path: root/src/mbgl/programs
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2016-11-07 12:26:05 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-11-08 08:09:29 -0800
commit1db2ffbc1b69069eca39f786cacc45dbb02c3052 (patch)
tree9d6ed2a7302492f41c52ea3fdeadabf6466b0d8d /src/mbgl/programs
parent66bdbc3b969083b9d647abdf72784be64a125949 (diff)
downloadqtlocation-mapboxgl-1db2ffbc1b69069eca39f786cacc45dbb02c3052.tar.gz
[core] Use gl::Program to resolve some rough edges in the GL binding types
* Extract `ignore` util to separate header. * `Segment` now tracks offset and length of indices, rather than primitives. This is more natural. * Introduce `VertexVector` and `IndexVector` types. These types carry information about the intended draw mode (`Triangles`, `LineStrip`, etc.), and ensure that elements are always appended in a group size appropriate for that draw mode, for both indexed and unindexed rendering. * `Program`, rather than `Drawable`, is now the unifying object for draw calls. `Program` is the best place to type check the draw call, because it is typed to carry information about the intended primitive, vertex type, attributes, and uniforms. * Use the debug shaders for debug tile rendering, like gl-js. * Fix the draw mode for background. It was drawing triangle strips with a triangles array. Surprised this didn’t cause issues. Now it’s type checked.
Diffstat (limited to 'src/mbgl/programs')
-rw-r--r--src/mbgl/programs/circle_program.hpp1
-rw-r--r--src/mbgl/programs/collision_box_program.hpp1
-rw-r--r--src/mbgl/programs/debug_program.hpp23
-rw-r--r--src/mbgl/programs/fill_program.hpp4
-rw-r--r--src/mbgl/programs/line_program.hpp3
-rw-r--r--src/mbgl/programs/program.hpp8
-rw-r--r--src/mbgl/programs/programs.hpp3
-rw-r--r--src/mbgl/programs/raster_program.hpp1
-rw-r--r--src/mbgl/programs/symbol_program.hpp2
9 files changed, 43 insertions, 3 deletions
diff --git a/src/mbgl/programs/circle_program.hpp b/src/mbgl/programs/circle_program.hpp
index 690608a438..75c030b1c8 100644
--- a/src/mbgl/programs/circle_program.hpp
+++ b/src/mbgl/programs/circle_program.hpp
@@ -16,6 +16,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(float, u_devicepixelratio);
class CircleProgram : public Program<
shaders::circle,
+ gl::Triangle,
gl::Attributes<
attributes::a_pos>,
gl::Uniforms<
diff --git a/src/mbgl/programs/collision_box_program.hpp b/src/mbgl/programs/collision_box_program.hpp
index 66b1284621..5eda3fefb0 100644
--- a/src/mbgl/programs/collision_box_program.hpp
+++ b/src/mbgl/programs/collision_box_program.hpp
@@ -17,6 +17,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(float, u_maxzoom);
class CollisionBoxProgram : public Program<
shaders::collision_box,
+ gl::Line,
gl::Attributes<
attributes::a_pos,
attributes::a_extrude,
diff --git a/src/mbgl/programs/debug_program.hpp b/src/mbgl/programs/debug_program.hpp
new file mode 100644
index 0000000000..3596dc1f7e
--- /dev/null
+++ b/src/mbgl/programs/debug_program.hpp
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <mbgl/programs/program.hpp>
+#include <mbgl/programs/attributes.hpp>
+#include <mbgl/programs/uniforms.hpp>
+#include <mbgl/shader/debug.hpp>
+
+namespace mbgl {
+
+class DebugProgram : public Program<
+ shaders::debug,
+ gl::Line,
+ gl::Attributes<
+ attributes::a_pos>,
+ gl::Uniforms<
+ uniforms::u_matrix,
+ uniforms::u_color>>
+{
+public:
+ using Program::Program;
+};
+
+} // namespace mbgl
diff --git a/src/mbgl/programs/fill_program.hpp b/src/mbgl/programs/fill_program.hpp
index 3f738527c8..d885215c59 100644
--- a/src/mbgl/programs/fill_program.hpp
+++ b/src/mbgl/programs/fill_program.hpp
@@ -86,6 +86,7 @@ struct FillPatternUniforms : gl::Uniforms<
class FillProgram : public Program<
shaders::fill,
+ gl::Triangle,
FillAttributes,
FillUniforms>
{
@@ -94,6 +95,7 @@ class FillProgram : public Program<
class FillPatternProgram : public Program<
shaders::fill_pattern,
+ gl::Triangle,
FillAttributes,
FillPatternUniforms>
{
@@ -102,6 +104,7 @@ class FillPatternProgram : public Program<
class FillOutlineProgram : public Program<
shaders::fill_outline,
+ gl::Line,
FillAttributes,
FillUniforms>
{
@@ -110,6 +113,7 @@ class FillOutlineProgram : public Program<
class FillOutlinePatternProgram : public Program<
shaders::fill_outline_pattern,
+ gl::Line,
FillAttributes,
FillPatternUniforms>
{
diff --git a/src/mbgl/programs/line_program.hpp b/src/mbgl/programs/line_program.hpp
index 960438f4cd..07ae35b8ed 100644
--- a/src/mbgl/programs/line_program.hpp
+++ b/src/mbgl/programs/line_program.hpp
@@ -88,6 +88,7 @@ using LineVertex = LineAttributes::Vertex;
class LineProgram : public Program<
shaders::line,
+ gl::Triangle,
LineAttributes,
gl::Uniforms<
uniforms::u_matrix,
@@ -113,6 +114,7 @@ public:
class LinePatternProgram : public Program<
shaders::line_pattern,
+ gl::Triangle,
LineAttributes,
gl::Uniforms<
uniforms::u_matrix,
@@ -147,6 +149,7 @@ public:
class LineSDFProgram : public Program<
shaders::line_sdf,
+ gl::Triangle,
LineAttributes,
gl::Uniforms<
uniforms::u_matrix,
diff --git a/src/mbgl/programs/program.hpp b/src/mbgl/programs/program.hpp
index 9f154b051a..fa41d43e5c 100644
--- a/src/mbgl/programs/program.hpp
+++ b/src/mbgl/programs/program.hpp
@@ -11,11 +11,13 @@ enum class ProgramDefines : bool {
Overdraw = true,
};
-template <class Shaders, class As, class Us>
-class Program : public gl::Program<As, Us> {
+template <class Shaders, class Primitive, class Attributes, class Uniforms>
+class Program : public gl::Program<Primitive, Attributes, Uniforms> {
public:
+ using ParentType = gl::Program<Primitive, Attributes, Uniforms>;
+
Program(gl::Context& context, ProgramDefines defines)
- : gl::Program<As, Us>(context, Shaders::vertexSource, fragmentSource(defines))
+ : ParentType(context, Shaders::vertexSource, fragmentSource(defines))
{}
static std::string fragmentSource(ProgramDefines defines) {
diff --git a/src/mbgl/programs/programs.hpp b/src/mbgl/programs/programs.hpp
index aebafaec62..53ed26e969 100644
--- a/src/mbgl/programs/programs.hpp
+++ b/src/mbgl/programs/programs.hpp
@@ -5,6 +5,7 @@
#include <mbgl/programs/line_program.hpp>
#include <mbgl/programs/raster_program.hpp>
#include <mbgl/programs/symbol_program.hpp>
+#include <mbgl/programs/debug_program.hpp>
#include <mbgl/programs/collision_box_program.hpp>
namespace mbgl {
@@ -24,6 +25,7 @@ public:
symbolIcon(context, defines),
symbolIconSDF(context, defines),
symbolGlyph(context, defines),
+ debug(context, ProgramDefines::None),
collisionBox(context, ProgramDefines::None) {
}
@@ -40,6 +42,7 @@ public:
SymbolSDFProgram symbolIconSDF;
SymbolSDFProgram symbolGlyph;
+ DebugProgram debug;
CollisionBoxProgram collisionBox;
};
diff --git a/src/mbgl/programs/raster_program.hpp b/src/mbgl/programs/raster_program.hpp
index 1e9a0cdb6a..1bab2d5765 100644
--- a/src/mbgl/programs/raster_program.hpp
+++ b/src/mbgl/programs/raster_program.hpp
@@ -25,6 +25,7 @@ MBGL_DEFINE_UNIFORM_VECTOR(float, 2, u_tl_parent);
class RasterProgram : public Program<
shaders::raster,
+ gl::Triangle,
gl::Attributes<
attributes::a_pos,
attributes::a_texture_pos>,
diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp
index eb8c56b326..be987551c0 100644
--- a/src/mbgl/programs/symbol_program.hpp
+++ b/src/mbgl/programs/symbol_program.hpp
@@ -72,6 +72,7 @@ using SymbolVertex = SymbolAttributes::Vertex;
class SymbolIconProgram : public Program<
shaders::symbol_icon,
+ gl::Triangle,
SymbolAttributes,
gl::Uniforms<
uniforms::u_matrix,
@@ -95,6 +96,7 @@ public:
class SymbolSDFProgram : public Program<
shaders::symbol_sdf,
+ gl::Triangle,
SymbolAttributes,
gl::Uniforms<
uniforms::u_matrix,