diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-14 11:57:02 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-11-15 13:55:08 -0800 |
commit | 377d0fb0d20fa4129d867f0e8762ce208ccee14d (patch) | |
tree | 408e883f6ca97ee62cb3aebd2ff243d4df45fa76 /src/mbgl/gl | |
parent | 58877d1b3ddf0e4521d680b85e31b7a4c6287302 (diff) | |
download | qtlocation-mapboxgl-377d0fb0d20fa4129d867f0e8762ce208ccee14d.tar.gz |
[core] Introduce SegmentVector
Diffstat (limited to 'src/mbgl/gl')
-rw-r--r-- | src/mbgl/gl/program.hpp | 7 | ||||
-rw-r--r-- | src/mbgl/gl/segment.hpp | 13 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/mbgl/gl/program.hpp b/src/mbgl/gl/program.hpp index 44c16ae671..01fa51e788 100644 --- a/src/mbgl/gl/program.hpp +++ b/src/mbgl/gl/program.hpp @@ -42,7 +42,7 @@ public: UniformValues&& uniformValues, const VertexBuffer<Vertex>& vertexBuffer, const IndexBuffer<DrawMode>& indexBuffer, - const std::vector<Segment>& segments) { + const SegmentVector<Attributes>& segments) { static_assert(std::is_same<Primitive, typename DrawMode::Primitive>::value, "incompatible draw mode"); context.draw({ std::move(drawMode), @@ -66,7 +66,8 @@ public: StencilMode stencilMode, ColorMode colorMode, UniformValues&& uniformValues, - const VertexBuffer<Vertex, DrawMode>& vertexBuffer) { + const VertexBuffer<Vertex, DrawMode>& vertexBuffer, + const SegmentVector<Attributes>& segments) { static_assert(std::is_same<Primitive, typename DrawMode::Primitive>::value, "incompatible draw mode"); context.draw({ std::move(drawMode), @@ -76,7 +77,7 @@ public: program, vertexBuffer.buffer, 0, - {{ 0, 0, vertexBuffer.vertexCount, 0 }}, + segments, Uniforms::binder(uniformsState, std::move(uniformValues)), Attributes::binder(attributesState) }); diff --git a/src/mbgl/gl/segment.hpp b/src/mbgl/gl/segment.hpp index f65f2a5f7e..283b4f572a 100644 --- a/src/mbgl/gl/segment.hpp +++ b/src/mbgl/gl/segment.hpp @@ -23,5 +23,18 @@ public: std::size_t indexLength; }; +template <class Attributes> +class SegmentVector : public std::vector<Segment> { +public: + SegmentVector() = default; + + // This constructor is for unindexed rendering. It creates a SegmentVector with a + // single segment having 0 indexes. + template <class DrawMode> + SegmentVector(const VertexBuffer<typename Attributes::Vertex, DrawMode>& buffer) { + emplace_back(0, 0, buffer.vertexCount, 0); + } +}; + } // namespace gl } // namespace mbgl |