diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-02-25 14:42:53 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-02-25 15:25:40 +0100 |
commit | 5416872b744628341b92046cb57efd6dffb3a377 (patch) | |
tree | 1af752e2d586cc6c0731e2789c80aae749a1a881 /src | |
parent | e800f3754758489e09c55e38bebd00c2203e4886 (diff) | |
download | qtlocation-mapboxgl-5416872b744628341b92046cb57efd6dffb3a377.tar.gz |
[core] remove DrawMode from VertexVector/Buffer
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/gl/attribute.hpp | 7 | ||||
-rw-r--r-- | src/mbgl/gl/context.hpp | 10 | ||||
-rw-r--r-- | src/mbgl/gl/draw_mode.hpp | 7 | ||||
-rw-r--r-- | src/mbgl/gl/vertex_buffer.hpp | 7 |
4 files changed, 11 insertions, 20 deletions
diff --git a/src/mbgl/gl/attribute.hpp b/src/mbgl/gl/attribute.hpp index 8cdb03bfe7..9d8947e4e5 100644 --- a/src/mbgl/gl/attribute.hpp +++ b/src/mbgl/gl/attribute.hpp @@ -62,8 +62,8 @@ public: override the number of components available in the buffer for each vertex. Thus, a buffer with only one float for each vertex can be bound to a `vec2` attribute */ - template <class Vertex, class DrawMode> - static AttributeBinding binding(const VertexBuffer<Vertex, DrawMode>& buffer, + template <class Vertex> + static AttributeBinding binding(const VertexBuffer<Vertex>& buffer, std::size_t attributeIndex, std::size_t attributeSize = N) { static_assert(std::is_standard_layout<Vertex>::value, "vertex type must use standard layout"); @@ -262,8 +262,7 @@ public: return result; } - template <class DrawMode> - static Bindings bindings(const VertexBuffer<Vertex, DrawMode>& buffer) { + static Bindings bindings(const VertexBuffer<Vertex>& buffer) { return Bindings { As::Type::binding(buffer, TypeIndex<As, As...>::value)... }; } diff --git a/src/mbgl/gl/context.hpp b/src/mbgl/gl/context.hpp index 810fb41990..a10b49da48 100644 --- a/src/mbgl/gl/context.hpp +++ b/src/mbgl/gl/context.hpp @@ -63,16 +63,16 @@ public: #endif optional<std::pair<BinaryProgramFormat, std::string>> getBinaryProgram(ProgramID) const; - template <class Vertex, class DrawMode> - VertexBuffer<Vertex, DrawMode> createVertexBuffer(VertexVector<Vertex, DrawMode>&& v, const BufferUsage usage = BufferUsage::StaticDraw) { - return VertexBuffer<Vertex, DrawMode> { + template <class Vertex> + VertexBuffer<Vertex> createVertexBuffer(VertexVector<Vertex>&& v, const BufferUsage usage = BufferUsage::StaticDraw) { + return VertexBuffer<Vertex> { v.vertexSize(), createVertexBuffer(v.data(), v.byteSize(), usage) }; } - template <class Vertex, class DrawMode> - void updateVertexBuffer(VertexBuffer<Vertex, DrawMode>& buffer, VertexVector<Vertex, DrawMode>&& v) { + template <class Vertex> + void updateVertexBuffer(VertexBuffer<Vertex>& buffer, VertexVector<Vertex>&& v) { assert(v.vertexSize() == buffer.vertexCount); updateVertexBuffer(buffer.buffer, v.data(), v.byteSize()); } diff --git a/src/mbgl/gl/draw_mode.hpp b/src/mbgl/gl/draw_mode.hpp index 275eb25b89..6f0c5ea4a4 100644 --- a/src/mbgl/gl/draw_mode.hpp +++ b/src/mbgl/gl/draw_mode.hpp @@ -68,12 +68,5 @@ public: static constexpr PrimitiveType primitiveType = PrimitiveType::TriangleStrip; }; -// Special draw mode for use with VertexVector<Indexed, Vertex>, in which -// case the true draw mode is denoted by the IndexVector type. -class Indexed { -public: - static constexpr std::size_t bufferGroupSize = 1; -}; - } // namespace gl } // namespace mbgl diff --git a/src/mbgl/gl/vertex_buffer.hpp b/src/mbgl/gl/vertex_buffer.hpp index 9f8b156b25..29eba2e979 100644 --- a/src/mbgl/gl/vertex_buffer.hpp +++ b/src/mbgl/gl/vertex_buffer.hpp @@ -10,15 +10,14 @@ namespace mbgl { namespace gl { -template <class V, class DrawMode = Indexed> +template <class V> class VertexVector { public: using Vertex = V; - static constexpr std::size_t groupSize = DrawMode::bufferGroupSize; template <class... Args> void emplace_back(Args&&... args) { - static_assert(sizeof...(args) == groupSize, "wrong buffer element count"); + static_assert(sizeof...(args) == 1, "wrong buffer element count"); util::ignore({(v.emplace_back(std::forward<Args>(args)), 0)...}); } @@ -34,7 +33,7 @@ private: std::vector<Vertex> v; }; -template <class V, class DrawMode = Indexed> +template <class V> class VertexBuffer { public: using Vertex = V; |