Use map projection with geo line

This commit is contained in:
Dan Paulat 2022-10-03 00:39:59 -05:00
parent ca9331cf7c
commit 4aad9fd3d4
3 changed files with 58 additions and 1 deletions

View file

@ -36,6 +36,7 @@ public:
modulateColor_ {std::nullopt},
shaderProgram_ {nullptr},
uMVPMatrixLocation_(GL_INVALID_INDEX),
uMapScreenCoordLocation_(GL_INVALID_INDEX),
vao_ {GL_INVALID_INDEX},
vbo_ {GL_INVALID_INDEX}
{
@ -57,6 +58,7 @@ public:
std::shared_ptr<ShaderProgram> shaderProgram_;
GLint uMVPMatrixLocation_;
GLint uMapScreenCoordLocation_;
GLuint vao_;
GLuint vbo_;
@ -88,6 +90,13 @@ void GeoLine::Initialize()
logger_->warn("Could not find uMVPMatrix");
}
p->uMapScreenCoordLocation_ =
gl.glGetUniformLocation(p->shaderProgram_->id(), "uMapScreenCoord");
if (p->uMapScreenCoordLocation_ == -1)
{
logger_->warn("Could not find uMapScreenCoord");
}
gl.glGenVertexArrays(1, &p->vao_);
gl.glGenBuffers(1, &p->vbo_);
@ -146,7 +155,8 @@ void GeoLine::Render(const QMapbox::CustomLayerRenderParameters& params)
p->Update();
p->shaderProgram_->Use();
UseDefaultProjection(params, p->uMVPMatrixLocation_);
UseMapProjection(
params, p->uMVPMatrixLocation_, p->uMapScreenCoordLocation_);
// Draw line
gl.glDrawArrays(GL_TRIANGLES, 0, 6);