Sweep time fix

This commit is contained in:
Dan Paulat 2021-11-22 13:53:11 -06:00
parent 4e61f82c5d
commit adde167899

View file

@ -41,6 +41,7 @@ public:
vbo_ {GL_INVALID_INDEX}, vbo_ {GL_INVALID_INDEX},
vao_ {GL_INVALID_INDEX}, vao_ {GL_INVALID_INDEX},
texture_ {GL_INVALID_INDEX}, texture_ {GL_INVALID_INDEX},
sweepTimeString_ {},
sweepTimeNeedsUpdate_ {true} sweepTimeNeedsUpdate_ {true}
{ {
// TODO: Manage font at the global level, texture at the view level // TODO: Manage font at the global level, texture at the view level
@ -59,6 +60,7 @@ public:
GLuint vao_; GLuint vao_;
GLuint texture_; GLuint texture_;
std::string sweepTimeString_;
bool sweepTimeNeedsUpdate_; bool sweepTimeNeedsUpdate_;
}; };
@ -131,8 +133,6 @@ void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params)
{ {
gl::OpenGLFunctions& gl = p->gl_; gl::OpenGLFunctions& gl = p->gl_;
static std::string sweepTimeString;
if (p->sweepTimeNeedsUpdate_) if (p->sweepTimeNeedsUpdate_)
{ {
using namespace std::chrono; using namespace std::chrono;
@ -144,7 +144,7 @@ void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params)
zoned_time zt = {current_zone(), sweepTime}; zoned_time zt = {current_zone(), sweepTime};
std::ostringstream os; std::ostringstream os;
os << zt; os << zt;
sweepTimeString = os.str(); p->sweepTimeString_ = os.str();
} }
p->sweepTimeNeedsUpdate_ = false; p->sweepTimeNeedsUpdate_ = false;
@ -160,10 +160,11 @@ void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params)
gl.glUniformMatrix4fv( gl.glUniformMatrix4fv(
p->uMVPMatrixLocation_, 1, GL_FALSE, glm::value_ptr(projection)); p->uMVPMatrixLocation_, 1, GL_FALSE, glm::value_ptr(projection));
if (sweepTimeString.length() > 0) if (p->sweepTimeString_.length() > 0)
{ {
const float fontSize = 16.0f; const float fontSize = 16.0f;
const float textLength = p->font_->TextLength(sweepTimeString, fontSize); const float textLength =
p->font_->TextLength(p->sweepTimeString_, fontSize);
// Upper right panel vertices // Upper right panel vertices
const float vertexLX = const float vertexLX =
@ -186,7 +187,7 @@ void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params)
gl.glDrawArrays(GL_TRIANGLES, 0, 6); gl.glDrawArrays(GL_TRIANGLES, 0, 6);
// Render time // Render time
p->textShader_.RenderText(sweepTimeString, p->textShader_.RenderText(p->sweepTimeString_,
params.width - 7.0f, params.width - 7.0f,
static_cast<float>(params.height) - static_cast<float>(params.height) -
16.0f, // 7.0f, 16.0f, // 7.0f,