mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 06:50:05 +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
				
			
		|  | @ -124,6 +124,7 @@ public: | ||||||
|                  std::shared_ptr<GenericLayer> layer, |                  std::shared_ptr<GenericLayer> layer, | ||||||
|                  const std::string&            before = {}); |                  const std::string&            before = {}); | ||||||
|    void ConnectSignals(); |    void ConnectSignals(); | ||||||
|  |    void ImGuiCheckFonts(); | ||||||
|    void InitializeNewRadarProductView(const std::string& colorPalette); |    void InitializeNewRadarProductView(const std::string& colorPalette); | ||||||
|    void RadarProductManagerConnect(); |    void RadarProductManagerConnect(); | ||||||
|    void RadarProductManagerDisconnect(); |    void RadarProductManagerDisconnect(); | ||||||
|  | @ -1043,17 +1044,9 @@ void MapWidget::paintGL() | ||||||
|    // Start ImGui Frame
 |    // Start ImGui Frame
 | ||||||
|    ImGui_ImplQt_NewFrame(this); |    ImGui_ImplQt_NewFrame(this); | ||||||
|    ImGui_ImplOpenGL3_NewFrame(); |    ImGui_ImplOpenGL3_NewFrame(); | ||||||
|  |    p->ImGuiCheckFonts(); | ||||||
|    ImGui::NewFrame(); |    ImGui::NewFrame(); | ||||||
| 
 | 
 | ||||||
|    // Update ImGui Fonts if required
 |  | ||||||
|    std::uint64_t currentImGuiFontsBuildCount = |  | ||||||
|       manager::FontManager::Instance().imgui_fonts_build_count(); |  | ||||||
|    if (p->imGuiFontsBuildCount_ != currentImGuiFontsBuildCount) |  | ||||||
|    { |  | ||||||
|       ImGui_ImplOpenGL3_DestroyFontsTexture(); |  | ||||||
|       ImGui_ImplOpenGL3_CreateFontsTexture(); |  | ||||||
|    } |  | ||||||
| 
 |  | ||||||
|    // Update pixel ratio
 |    // Update pixel ratio
 | ||||||
|    p->context_->set_pixel_ratio(pixelRatio()); |    p->context_->set_pixel_ratio(pixelRatio()); | ||||||
| 
 | 
 | ||||||
|  | @ -1087,6 +1080,22 @@ void MapWidget::paintGL() | ||||||
|    Q_EMIT WidgetPainted(); |    Q_EMIT WidgetPainted(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void MapWidgetImpl::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; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| void MapWidgetImpl::RunMousePicking() | void MapWidgetImpl::RunMousePicking() | ||||||
| { | { | ||||||
|    const QMapLibreGL::CustomLayerRenderParameters params = |    const QMapLibreGL::CustomLayerRenderParameters params = | ||||||
|  |  | ||||||
|  | @ -51,6 +51,8 @@ public: | ||||||
|       model::ImGuiContextModel::Instance().DestroyContext(contextName_); |       model::ImGuiContextModel::Instance().DestroyContext(contextName_); | ||||||
|    } |    } | ||||||
| 
 | 
 | ||||||
|  |    void ImGuiCheckFonts(); | ||||||
|  | 
 | ||||||
|    ImGuiDebugWidget* self_; |    ImGuiDebugWidget* self_; | ||||||
|    ImGuiContext*     context_; |    ImGuiContext*     context_; | ||||||
|    std::string       contextName_; |    std::string       contextName_; | ||||||
|  | @ -59,6 +61,7 @@ public: | ||||||
| 
 | 
 | ||||||
|    std::set<ImGuiContext*> renderedSet_ {}; |    std::set<ImGuiContext*> renderedSet_ {}; | ||||||
|    bool                    imGuiRendererInitialized_ {false}; |    bool                    imGuiRendererInitialized_ {false}; | ||||||
|  |    std::uint64_t           imGuiFontsBuildCount_ {}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| ImGuiDebugWidget::ImGuiDebugWidget(QWidget* parent) : | ImGuiDebugWidget::ImGuiDebugWidget(QWidget* parent) : | ||||||
|  | @ -103,6 +106,8 @@ void ImGuiDebugWidget::initializeGL() | ||||||
|    // Initialize ImGui OpenGL3 backend
 |    // Initialize ImGui OpenGL3 backend
 | ||||||
|    ImGui::SetCurrentContext(p->context_); |    ImGui::SetCurrentContext(p->context_); | ||||||
|    ImGui_ImplOpenGL3_Init(); |    ImGui_ImplOpenGL3_Init(); | ||||||
|  |    p->imGuiFontsBuildCount_ = | ||||||
|  |       manager::FontManager::Instance().imgui_fonts_build_count(); | ||||||
|    p->imGuiRendererInitialized_ = true; |    p->imGuiRendererInitialized_ = true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -116,7 +121,7 @@ void ImGuiDebugWidget::paintGL() | ||||||
| 
 | 
 | ||||||
|    ImGui_ImplQt_NewFrame(this); |    ImGui_ImplQt_NewFrame(this); | ||||||
|    ImGui_ImplOpenGL3_NewFrame(); |    ImGui_ImplOpenGL3_NewFrame(); | ||||||
| 
 |    p->ImGuiCheckFonts(); | ||||||
|    ImGui::NewFrame(); |    ImGui::NewFrame(); | ||||||
| 
 | 
 | ||||||
|    if (!p->renderedSet_.contains(p->currentContext_)) |    if (!p->renderedSet_.contains(p->currentContext_)) | ||||||
|  | @ -141,6 +146,26 @@ void ImGuiDebugWidget::paintGL() | ||||||
|    imguiFontAtlasLock.unlock(); |    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 ui
 | ||||||
| } // namespace qt
 | } // namespace qt
 | ||||||
| } // namespace scwx
 | } // namespace scwx
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat