Fix first time display of location icon

This commit is contained in:
Dan Paulat 2023-11-23 22:17:43 -06:00
parent 7057f14b22
commit ad4ae80da8
2 changed files with 14 additions and 3 deletions

View file

@ -120,6 +120,7 @@ public:
bool visible_ {true}; bool visible_ {true};
bool dirty_ {false}; bool dirty_ {false};
bool thresholded_ {false}; bool thresholded_ {false};
bool lastTextureAtlasChanged_ {false};
std::chrono::system_clock::time_point selectedTime_ {}; std::chrono::system_clock::time_point selectedTime_ {};
@ -275,6 +276,11 @@ void GeoIcons::Render(const QMapLibreGL::CustomLayerRenderParameters& params,
{ {
if (!p->visible_) if (!p->visible_)
{ {
if (textureAtlasChanged)
{
p->lastTextureAtlasChanged_ = true;
}
return; return;
} }
@ -504,8 +510,8 @@ void GeoIcons::FinishIcons()
p->currentIntegerBuffer_.swap(p->newIntegerBuffer_); p->currentIntegerBuffer_.swap(p->newIntegerBuffer_);
p->currentHoverIcons_.swap(p->newHoverIcons_); p->currentHoverIcons_.swap(p->newHoverIcons_);
// Clear the new buffers // Clear the new buffers, except the full icon list (used to update buffers
p->newIconList_.clear(); // without re-adding icons)
p->newValidIconList_.clear(); p->newValidIconList_.clear();
p->newIconBuffer_.clear(); p->newIconBuffer_.clear();
p->newIntegerBuffer_.clear(); p->newIntegerBuffer_.clear();
@ -522,6 +528,8 @@ void GeoIcons::Impl::UpdateBuffers()
newIntegerBuffer_.clear(); newIntegerBuffer_.clear();
newIntegerBuffer_.reserve(newIconList_.size() * kVerticesPerRectangle * newIntegerBuffer_.reserve(newIconList_.size() * kVerticesPerRectangle *
kIntegersPerVertex_); kIntegersPerVertex_);
newValidIconList_.clear();
newHoverIcons_.clear();
for (auto& di : newIconList_) for (auto& di : newIconList_)
{ {
@ -737,7 +745,7 @@ void GeoIcons::Impl::Update(bool textureAtlasChanged)
gl::OpenGLFunctions& gl = context_->gl(); gl::OpenGLFunctions& gl = context_->gl();
// If the texture atlas has changed // If the texture atlas has changed
if (dirty_ || textureAtlasChanged) if (dirty_ || textureAtlasChanged || lastTextureAtlasChanged_)
{ {
// Update texture coordinates // Update texture coordinates
for (auto& iconSheet : currentIconSheets_) for (auto& iconSheet : currentIconSheets_)
@ -754,6 +762,8 @@ void GeoIcons::Impl::Update(bool textureAtlasChanged)
sizeof(float) * textureBuffer_.size(), sizeof(float) * textureBuffer_.size(),
textureBuffer_.data(), textureBuffer_.data(),
GL_DYNAMIC_DRAW); GL_DYNAMIC_DRAW);
lastTextureAtlasChanged_ = false;
} }
// If buffers need updating // If buffers need updating

View file

@ -123,6 +123,7 @@ void OverlayLayer::Initialize()
gl::draw::GeoIcons::SetIconLocation(p->locationIcon_, gl::draw::GeoIcons::SetIconLocation(p->locationIcon_,
coordinate.latitude(), coordinate.latitude(),
coordinate.longitude()); coordinate.longitude());
p->icons_->FinishIcons();
Q_EMIT NeedsRendering(); Q_EMIT NeedsRendering();
} }
p->currentPosition_ = position; p->currentPosition_ = position;