mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 15:50:05 +00:00
Move ImGuiCheckFonts back to only being called in map_widget (lock makes this safe)
This commit is contained in:
parent
9bd5af03f9
commit
c6596b3e7d
2 changed files with 6 additions and 27 deletions
|
|
@ -25,8 +25,7 @@ public:
|
|||
explicit DrawLayerImpl(std::shared_ptr<MapContext> context) :
|
||||
context_ {context},
|
||||
drawList_ {},
|
||||
textureAtlas_ {GL_INVALID_INDEX},
|
||||
imGuiRendererInitialized_ {false}
|
||||
textureAtlas_ {GL_INVALID_INDEX}
|
||||
{
|
||||
static size_t currentMapId_ {0u};
|
||||
imGuiContextName_ = fmt::format("Layer {}", ++currentMapId_);
|
||||
|
|
@ -52,36 +51,17 @@ public:
|
|||
model::ImGuiContextModel::Instance().DestroyContext(imGuiContextName_);
|
||||
}
|
||||
|
||||
void ImGuiCheckFonts();
|
||||
|
||||
std::shared_ptr<MapContext> context_;
|
||||
std::vector<std::shared_ptr<gl::draw::DrawItem>> drawList_;
|
||||
GLuint textureAtlas_;
|
||||
|
||||
std::uint64_t textureAtlasBuildCount_ {};
|
||||
|
||||
std::string imGuiContextName_;
|
||||
std::string imGuiContextName_;
|
||||
ImGuiContext* imGuiContext_;
|
||||
bool imGuiRendererInitialized_;
|
||||
std::uint64_t imGuiFontsBuildCount_ {};
|
||||
bool imGuiRendererInitialized_{};
|
||||
};
|
||||
|
||||
void DrawLayerImpl::ImGuiCheckFonts()
|
||||
{
|
||||
// Update ImGui Fonts if required
|
||||
std::uint64_t currentImGuiFontsBuildCount =
|
||||
manager::FontManager::Instance().imgui_fonts_build_count();
|
||||
|
||||
if (imGuiFontsBuildCount_ != currentImGuiFontsBuildCount ||
|
||||
!model::ImGuiContextModel::Instance().font_atlas()->IsBuilt())
|
||||
{
|
||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||
ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||
}
|
||||
|
||||
imGuiFontsBuildCount_ = currentImGuiFontsBuildCount;
|
||||
}
|
||||
|
||||
DrawLayer::DrawLayer(const std::shared_ptr<MapContext>& context) :
|
||||
GenericLayer(context), p(std::make_unique<DrawLayerImpl>(context))
|
||||
{
|
||||
|
|
@ -111,7 +91,6 @@ void DrawLayer::StartImGuiFrame()
|
|||
// Start ImGui Frame
|
||||
ImGui_ImplQt_NewFrame(p->context_->widget());
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
p->ImGuiCheckFonts();
|
||||
ImGui::NewFrame();
|
||||
ImGui::PushFont(defaultFont->font());
|
||||
}
|
||||
|
|
@ -131,8 +110,6 @@ void DrawLayer::ImGuiInitialize()
|
|||
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||
ImGui_ImplQt_RegisterWidget(p->context_->widget());
|
||||
ImGui_ImplOpenGL3_Init();
|
||||
p->imGuiFontsBuildCount_ =
|
||||
manager::FontManager::Instance().imgui_fonts_build_count();
|
||||
p->imGuiRendererInitialized_ = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1576,6 +1576,9 @@ void MapWidget::paintGL()
|
|||
std::shared_lock imguiFontAtlasLock {
|
||||
manager::FontManager::Instance().imgui_font_atlas_mutex()};
|
||||
|
||||
// Check ImGui fonts
|
||||
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||
p->ImGuiCheckFonts();
|
||||
|
||||
// Update pixel ratio
|
||||
p->context_->set_pixel_ratio(pixelRatio());
|
||||
|
|
@ -1593,7 +1596,6 @@ void MapWidget::paintGL()
|
|||
// Start ImGui Frame
|
||||
ImGui_ImplQt_NewFrame(this);
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
p->ImGuiCheckFonts();
|
||||
ImGui::NewFrame();
|
||||
|
||||
// Set default font
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue