port collision box debug rendering

This commit is contained in:
Ansis Brammanis
2015-04-01 13:22:16 -07:00
parent 8fd42f371f
commit dda1b770da
13 changed files with 245 additions and 1 deletions

View File

@@ -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;
}
}

View File

@@ -0,0 +1,23 @@
#ifndef MBGL_GEOMETRY_COLLISIONBOX_BUFFER
#define MBGL_GEOMETRY_COLLISIONBOX_BUFFER
#include <mbgl/geometry/buffer.hpp>
#include <array>
namespace mbgl {
class CollisionBoxVertexBuffer : public Buffer <
12,
GL_ARRAY_BUFFER,
32768
> {
public:
typedef int16_t vertex_type;
size_t add(int16_t x, int16_t y, float ex, float ey, float maxzoom, float placementZoom);
};
}
#endif