Browse Source

Merge pull request #1622 from AtomicGameEngine/fix/SystemUI-UrhoUI-interop

Move imgui ui assembly and rendering to END_RENDERING event.
JoshEngebretson 8 years ago
parent
commit
0b50c462b2
2 changed files with 7 additions and 8 deletions
  1. 6 7
      Source/Atomic/UI/SystemUI/SystemUI.cpp
  2. 1 1
      Source/Atomic/UI/SystemUI/SystemUI.h

+ 6 - 7
Source/Atomic/UI/SystemUI/SystemUI.cpp

@@ -79,12 +79,7 @@ SystemUI::SystemUI(Atomic::Context* context)
     UpdateProjectionMatrix();
 
     // Subscribe to events
-    SubscribeToEvent(E_POSTUPDATE, std::bind(&SystemUI::OnPostUpdate, this, _2));
-    SubscribeToEvent(E_ENDRENDERING, [&](StringHash, VariantMap&)
-    {
-        ATOMIC_PROFILE(SystemUiRender);
-        ImGui::Render();
-    });
+    SubscribeToEvent(E_ENDRENDERING, std::bind(&SystemUI::OnEndRendering, this, _2));
     SubscribeToEvent(E_SDLRAWINPUT, std::bind(&SystemUI::OnRawEvent, this, _2));
     SubscribeToEvent(E_SCREENMODE, std::bind(&SystemUI::UpdateProjectionMatrix, this));
 
@@ -190,14 +185,18 @@ void SystemUI::OnRawEvent(VariantMap& args)
     }
 }
 
-void SystemUI::OnPostUpdate(VariantMap& args)
+void SystemUI::OnEndRendering(VariantMap& args)
 {
     auto& io = ImGui::GetIO();
     float timeStep = args[PostUpdate::P_TIMESTEP].GetFloat();
     io.DeltaTime = timeStep > 0.0f ? timeStep : 1.0f / 60.0f;
     ImGui::NewFrame();
+
     ATOMIC_PROFILE(SystemUiFrame);
     SendEvent(E_SYSTEMUIFRAME);
+
+    ATOMIC_PROFILE(SystemUiRender);
+    ImGui::Render();
 }
 
 void SystemUI::OnRenderDrawLists(ImDrawData* data)

+ 1 - 1
Source/Atomic/UI/SystemUI/SystemUI.h

@@ -82,7 +82,7 @@ protected:
 
     void ReallocateFontTexture();
     void UpdateProjectionMatrix();
-    void OnPostUpdate(Atomic::VariantMap& args);
+    void OnEndRendering(Atomic::VariantMap& args);
     void OnRenderDrawLists(ImDrawData* data);
     void OnRawEvent(VariantMap& args);
 };