Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Added StaticRasterVertexBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoabinader committed Jun 19, 2016
1 parent 87a09c5 commit 5a79ee4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
14 changes: 12 additions & 2 deletions src/mbgl/geometry/static_vertex_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@

namespace mbgl {

StaticVertexBuffer::StaticVertexBuffer(std::initializer_list<std::pair<int16_t, int16_t>> init) {
StaticVertexBuffer::StaticVertexBuffer(std::initializer_list<std::pair<VertexType, VertexType>> init) {
for (const auto& vertex : init) {
vertex_type *vertices = static_cast<vertex_type *>(addElement());
VertexType* vertices = static_cast<VertexType*>(addElement());
vertices[0] = vertex.first;
vertices[1] = vertex.second;
}
}

StaticRasterVertexBuffer::StaticRasterVertexBuffer(std::initializer_list<std::tuple<VertexType, VertexType, VertexType, VertexType>> init) {
for (const auto& vertex : init) {
VertexType* vertices = static_cast<VertexType*>(addElement());
vertices[0] = std::get<0>(vertex);
vertices[1] = std::get<1>(vertex);
vertices[2] = std::get<2>(vertex);
vertices[3] = std::get<3>(vertex);
}
}

} // namespace mbgl
13 changes: 11 additions & 2 deletions src/mbgl/geometry/static_vertex_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@ class StaticVertexBuffer : public Buffer<
32 // default length
> {
public:
typedef int16_t vertex_type;
using VertexType = int16_t;
StaticVertexBuffer(std::initializer_list<std::pair<VertexType, VertexType>>);
};

StaticVertexBuffer(std::initializer_list<std::pair<int16_t, int16_t>> init);
class StaticRasterVertexBuffer : public Buffer<
8, // bytes per vertex (4 * signed short == 8 bytes)
GL_ARRAY_BUFFER,
32 // default length
> {
public:
using VertexType = int16_t;
StaticRasterVertexBuffer(std::initializer_list<std::tuple<VertexType, VertexType, VertexType, VertexType>>);
};

} // namespace mbgl
2 changes: 1 addition & 1 deletion src/mbgl/renderer/raster_bucket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace mbgl {

class RasterShader;
class StaticVertexBuffer;
class StaticRasterVertexBuffer;
class VertexArrayObject;

class RasterBucket : public Bucket {
Expand Down

0 comments on commit 5a79ee4

Please sign in to comment.