mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:20:05 +00:00 
			
		
		
		
	Add imgui debug window, still need to use unique contexts
This commit is contained in:
		
							parent
							
								
									b18692657a
								
							
						
					
					
						commit
						cd01bb70b6
					
				
					 10 changed files with 325 additions and 3 deletions
				
			
		
							
								
								
									
										56
									
								
								scwx-qt/source/scwx/qt/ui/imgui_debug_widget.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								scwx-qt/source/scwx/qt/ui/imgui_debug_widget.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,56 @@ | |||
| #include <scwx/qt/ui/imgui_debug_widget.hpp> | ||||
| 
 | ||||
| #include <imgui.h> | ||||
| #include <backends/imgui_impl_opengl3.h> | ||||
| #include <backends/imgui_impl_qt.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
| namespace qt | ||||
| { | ||||
| namespace ui | ||||
| { | ||||
| 
 | ||||
| static const std::string logPrefix_ = "scwx::qt::ui::imgui_debug_widget"; | ||||
| 
 | ||||
| class ImGuiDebugWidgetImpl | ||||
| { | ||||
| public: | ||||
|    explicit ImGuiDebugWidgetImpl(ImGuiDebugWidget* self) : self_ {self} | ||||
|    { | ||||
|       // ImGui Configuration
 | ||||
|       auto& io = ImGui::GetIO(); | ||||
| 
 | ||||
|       // Initialize Qt backend
 | ||||
|       ImGui_ImplQt_RegisterWidget(self_); | ||||
|    } | ||||
|    ~ImGuiDebugWidgetImpl() {} | ||||
| 
 | ||||
|    ImGuiDebugWidget* self_; | ||||
| }; | ||||
| 
 | ||||
| ImGuiDebugWidget::ImGuiDebugWidget(QWidget* parent) : | ||||
|     QOpenGLWidget(parent), p {std::make_unique<ImGuiDebugWidgetImpl>(this)} | ||||
| { | ||||
| } | ||||
| 
 | ||||
| void ImGuiDebugWidget::initializeGL() {} | ||||
| 
 | ||||
| void ImGuiDebugWidget::paintGL() | ||||
| { | ||||
|    ImGui_ImplQt_NewFrame(this); | ||||
|    ImGui_ImplOpenGL3_NewFrame(); | ||||
| 
 | ||||
|    ImGui::NewFrame(); | ||||
| 
 | ||||
|    ImGui::ShowDemoWindow(); | ||||
| 
 | ||||
|    ImGui::Render(); | ||||
|    ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); | ||||
| } | ||||
| 
 | ||||
| ImGuiDebugWidget::~ImGuiDebugWidget() {} | ||||
| 
 | ||||
| } // namespace ui
 | ||||
| } // namespace qt
 | ||||
| } // namespace scwx
 | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat