summaryrefslogtreecommitdiff
path: root/src/mbgl/geometry/collision_box_buffer.cpp
diff options
context:
space:
mode:
authorAnsis Brammanis <brammanis@gmail.com>2015-04-01 13:22:16 -0700
committerAnsis Brammanis <brammanis@gmail.com>2015-04-01 16:11:48 -0700
commitdda1b770daa2c009abdaaa48d40917abc1571ca3 (patch)
treeccc6abcc0852b6ac8b59bd2fd799223d62cbd9a2 /src/mbgl/geometry/collision_box_buffer.cpp
parent8fd42f371fd5e5581d3ce8307873664deb40a371 (diff)
downloadqtlocation-mapboxgl-dda1b770daa2c009abdaaa48d40917abc1571ca3.tar.gz
port collision box debug rendering
Diffstat (limited to 'src/mbgl/geometry/collision_box_buffer.cpp')
-rw-r--r--src/mbgl/geometry/collision_box_buffer.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/mbgl/geometry/collision_box_buffer.cpp b/src/mbgl/geometry/collision_box_buffer.cpp
new file mode 100644
index 0000000000..050a999db8
--- /dev/null
+++ b/src/mbgl/geometry/collision_box_buffer.cpp
@@ -0,0 +1,27 @@
+#include <mbgl/geometry/collision_box_buffer.hpp>
+#include <mbgl/platform/gl.hpp>
+#include <mbgl/util/math.hpp>
+
+#include <cmath>
+
+namespace mbgl {
+
+size_t CollisionBoxVertexBuffer::add(int16_t x, int16_t y, float ox, float oy, float maxzoom, float placementZoom) {
+ const size_t idx = index();
+ void *data = addElement();
+
+ int16_t *shorts = static_cast<int16_t *>(data);
+ shorts[0] /* pos */ = x;
+ shorts[1] /* pos */ = y;
+ shorts[2] /* offset */ = std::round(ox); // use 1/64 pixels for placement
+ shorts[3] /* offset */ = std::round(oy);
+
+ uint8_t *ubytes = static_cast<uint8_t *>(data);
+ // a_data1
+ ubytes[8] = maxzoom * 10;
+ ubytes[9] = placementZoom * 10;
+
+ return idx;
+}
+
+}