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,32 @@
#include <mbgl/shader/box_shader.hpp>
#include <mbgl/shader/shaders.hpp>
#include <mbgl/platform/gl.hpp>
#include <cstdio>
using namespace mbgl;
CollisionBoxShader::CollisionBoxShader()
: Shader(
"collisionbox",
shaders[BOX_SHADER].vertex,
shaders[BOX_SHADER].fragment
) {
a_pos = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_pos"));
a_extrude = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_extrude"));
a_data = MBGL_CHECK_ERROR(glGetAttribLocation(program, "a_data"));
}
void CollisionBoxShader::bind(char *offset) {
const int stride = 12;
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_pos));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_pos, 2, GL_SHORT, false, stride, offset + 0));
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_extrude));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_extrude, 2, GL_SHORT, false, stride, offset + 4));
MBGL_CHECK_ERROR(glEnableVertexAttribArray(a_data));
MBGL_CHECK_ERROR(glVertexAttribPointer(a_data, 2, GL_UNSIGNED_BYTE, false, stride, offset + 8));
}