diff --git a/scwx-qt/source/scwx/qt/gl/gl_context.cpp b/scwx-qt/source/scwx/qt/gl/gl_context.cpp index 813225e1..d927aef3 100644 --- a/scwx-qt/source/scwx/qt/gl/gl_context.cpp +++ b/scwx-qt/source/scwx/qt/gl/gl_context.cpp @@ -136,6 +136,14 @@ void GlContext::Initialize() p->InitializeGL(); } +void GlContext::StartFrame() +{ + auto& gl = p->gl_; + + gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + gl.glClear(GL_COLOR_BUFFER_BIT); +} + std::size_t GlContext::Impl::GetShaderKey( std::initializer_list> shaders) { diff --git a/scwx-qt/source/scwx/qt/gl/gl_context.hpp b/scwx-qt/source/scwx/qt/gl/gl_context.hpp index 1ba74fb8..b4a6a866 100644 --- a/scwx-qt/source/scwx/qt/gl/gl_context.hpp +++ b/scwx-qt/source/scwx/qt/gl/gl_context.hpp @@ -38,6 +38,7 @@ public: GLuint GetTextureAtlas(); void Initialize(); + void StartFrame(); private: class Impl; diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index cf38222d..e8a561fc 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -1406,6 +1406,8 @@ void MapWidget::paintGL() p->frameDraws_++; + p->context_->StartFrame(); + // Handle hotkey updates p->HandleHotkeyUpdates(); diff --git a/scwx-qt/source/scwx/qt/ui/imgui_debug_widget.cpp b/scwx-qt/source/scwx/qt/ui/imgui_debug_widget.cpp index fcbed5d6..acb8eda3 100644 --- a/scwx-qt/source/scwx/qt/ui/imgui_debug_widget.cpp +++ b/scwx-qt/source/scwx/qt/ui/imgui_debug_widget.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -59,6 +60,8 @@ public: ImGuiContext* currentContext_; + gl::OpenGLFunctions gl_; + std::set renderedSet_ {}; bool imGuiRendererInitialized_ {false}; std::uint64_t imGuiFontsBuildCount_ {}; @@ -103,6 +106,9 @@ void ImGuiDebugWidget::initializeGL() { makeCurrent(); + // Initialize OpenGL Functions + p->gl_.initializeOpenGLFunctions(); + // Initialize ImGui OpenGL3 backend ImGui::SetCurrentContext(p->context_); ImGui_ImplOpenGL3_Init(); @@ -113,6 +119,9 @@ void ImGuiDebugWidget::initializeGL() void ImGuiDebugWidget::paintGL() { + p->gl_.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + p->gl_.glClear(GL_COLOR_BUFFER_BIT); + ImGui::SetCurrentContext(p->currentContext_); // Lock ImGui font atlas prior to new ImGui frame