summaryrefslogtreecommitdiff
path: root/src/mbgl/geometry
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-06-19 19:25:33 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-07-02 17:21:59 +0300
commit3bf85cc55d662c218e371a03040c4cd5c3cca771 (patch)
treebc14ad9a75826aa68eceb0cf0f64d4b9104f02f2 /src/mbgl/geometry
parentd8a10ac509d5f56120eb878b5e330dcb4c7abf1b (diff)
downloadqtlocation-mapboxgl-3bf85cc55d662c218e371a03040c4cd5c3cca771.tar.gz
[core] Added StaticRasterVertexBuffer
Diffstat (limited to 'src/mbgl/geometry')
-rw-r--r--src/mbgl/geometry/static_vertex_buffer.cpp18
-rw-r--r--src/mbgl/geometry/static_vertex_buffer.hpp17
2 files changed, 26 insertions, 9 deletions
diff --git a/src/mbgl/geometry/static_vertex_buffer.cpp b/src/mbgl/geometry/static_vertex_buffer.cpp
index 254b01b6b6..c66b194748 100644
--- a/src/mbgl/geometry/static_vertex_buffer.cpp
+++ b/src/mbgl/geometry/static_vertex_buffer.cpp
@@ -3,11 +3,21 @@
namespace mbgl {
-StaticVertexBuffer::StaticVertexBuffer(std::initializer_list<std::pair<int16_t, int16_t>> init) {
+StaticVertexBuffer::StaticVertexBuffer(std::initializer_list<std::array<VertexType, 2>> init) {
for (const auto& vertex : init) {
- vertex_type *vertices = static_cast<vertex_type *>(addElement());
- vertices[0] = vertex.first;
- vertices[1] = vertex.second;
+ VertexType* vertices = static_cast<VertexType*>(addElement());
+ vertices[0] = std::get<0>(vertex);
+ vertices[1] = std::get<1>(vertex);
+ }
+}
+
+StaticRasterVertexBuffer::StaticRasterVertexBuffer(std::initializer_list<std::array<VertexType, 4>> 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);
}
}
diff --git a/src/mbgl/geometry/static_vertex_buffer.hpp b/src/mbgl/geometry/static_vertex_buffer.hpp
index 79f6117cbc..2e738afc98 100644
--- a/src/mbgl/geometry/static_vertex_buffer.hpp
+++ b/src/mbgl/geometry/static_vertex_buffer.hpp
@@ -2,10 +2,8 @@
#include <mbgl/geometry/buffer.hpp>
-#include <vector>
-#include <cstddef>
+#include <array>
#include <cstdint>
-#include <cmath>
namespace mbgl {
@@ -15,9 +13,18 @@ class StaticVertexBuffer : public Buffer<
32 // default length
> {
public:
- typedef int16_t vertex_type;
+ using VertexType = int16_t;
+ StaticVertexBuffer(std::initializer_list<std::array<VertexType, 2>>);
+};
- 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::array<VertexType, 4>>);
};
} // namespace mbgl