mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 17:50:04 +00:00
Check ImGui fonts before new frame
This commit is contained in:
parent
b66ca2cb09
commit
1f964c49f8
2 changed files with 44 additions and 10 deletions
|
|
@ -51,6 +51,8 @@ public:
|
|||
model::ImGuiContextModel::Instance().DestroyContext(contextName_);
|
||||
}
|
||||
|
||||
void ImGuiCheckFonts();
|
||||
|
||||
ImGuiDebugWidget* self_;
|
||||
ImGuiContext* context_;
|
||||
std::string contextName_;
|
||||
|
|
@ -59,6 +61,7 @@ public:
|
|||
|
||||
std::set<ImGuiContext*> renderedSet_ {};
|
||||
bool imGuiRendererInitialized_ {false};
|
||||
std::uint64_t imGuiFontsBuildCount_ {};
|
||||
};
|
||||
|
||||
ImGuiDebugWidget::ImGuiDebugWidget(QWidget* parent) :
|
||||
|
|
@ -103,6 +106,8 @@ void ImGuiDebugWidget::initializeGL()
|
|||
// Initialize ImGui OpenGL3 backend
|
||||
ImGui::SetCurrentContext(p->context_);
|
||||
ImGui_ImplOpenGL3_Init();
|
||||
p->imGuiFontsBuildCount_ =
|
||||
manager::FontManager::Instance().imgui_fonts_build_count();
|
||||
p->imGuiRendererInitialized_ = true;
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +121,7 @@ void ImGuiDebugWidget::paintGL()
|
|||
|
||||
ImGui_ImplQt_NewFrame(this);
|
||||
ImGui_ImplOpenGL3_NewFrame();
|
||||
|
||||
p->ImGuiCheckFonts();
|
||||
ImGui::NewFrame();
|
||||
|
||||
if (!p->renderedSet_.contains(p->currentContext_))
|
||||
|
|
@ -141,6 +146,26 @@ void ImGuiDebugWidget::paintGL()
|
|||
imguiFontAtlasLock.unlock();
|
||||
}
|
||||
|
||||
void ImGuiDebugWidgetImpl::ImGuiCheckFonts()
|
||||
{
|
||||
// Update ImGui Fonts if required
|
||||
std::uint64_t currentImGuiFontsBuildCount =
|
||||
manager::FontManager::Instance().imgui_fonts_build_count();
|
||||
|
||||
if ((context_ == currentContext_ &&
|
||||
imGuiFontsBuildCount_ != currentImGuiFontsBuildCount) ||
|
||||
!model::ImGuiContextModel::Instance().font_atlas()->IsBuilt())
|
||||
{
|
||||
ImGui_ImplOpenGL3_DestroyFontsTexture();
|
||||
ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||
}
|
||||
|
||||
if (context_ == currentContext_)
|
||||
{
|
||||
imGuiFontsBuildCount_ = currentImGuiFontsBuildCount;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue