[core] remove DrawMode from VertexVector/Buffer
This commit is contained in:
@@ -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)... };
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user