From 5416872b744628341b92046cb57efd6dffb3a377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 25 Feb 2019 14:42:53 +0100 Subject: [core] remove DrawMode from VertexVector/Buffer --- src/mbgl/gl/attribute.hpp | 7 +++---- src/mbgl/gl/context.hpp | 10 +++++----- src/mbgl/gl/draw_mode.hpp | 7 ------- 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 - static AttributeBinding binding(const VertexBuffer& buffer, + template + static AttributeBinding binding(const VertexBuffer& buffer, std::size_t attributeIndex, std::size_t attributeSize = N) { static_assert(std::is_standard_layout::value, "vertex type must use standard layout"); @@ -262,8 +262,7 @@ public: return result; } - template - static Bindings bindings(const VertexBuffer& buffer) { + static Bindings bindings(const VertexBuffer& buffer) { return Bindings { As::Type::binding(buffer, TypeIndex::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> getBinaryProgram(ProgramID) const; - template - VertexBuffer createVertexBuffer(VertexVector&& v, const BufferUsage usage = BufferUsage::StaticDraw) { - return VertexBuffer { + template + VertexBuffer createVertexBuffer(VertexVector&& v, const BufferUsage usage = BufferUsage::StaticDraw) { + return VertexBuffer { v.vertexSize(), createVertexBuffer(v.data(), v.byteSize(), usage) }; } - template - void updateVertexBuffer(VertexBuffer& buffer, VertexVector&& v) { + template + void updateVertexBuffer(VertexBuffer& buffer, VertexVector&& 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, 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 +template class VertexVector { public: using Vertex = V; - static constexpr std::size_t groupSize = DrawMode::bufferGroupSize; template 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)), 0)...}); } @@ -34,7 +33,7 @@ private: std::vector v; }; -template +template class VertexBuffer { public: using Vertex = V; -- cgit v1.2.1