From 78f48bb795e5ea54ec2f8e232dc1f06315af340b Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 25 Dec 2017 14:54:54 +0100 Subject: [PATCH 1/2] Examples: DirectX10,DirectX11: Moved call to OMSetRenderTargets() in main loop so example code can integrate more nicely with other code. --- examples/directx10_example/main.cpp | 2 +- examples/directx11_example/main.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/directx10_example/main.cpp b/examples/directx10_example/main.cpp index ecfc156a..38f4054e 100644 --- a/examples/directx10_example/main.cpp +++ b/examples/directx10_example/main.cpp @@ -27,7 +27,6 @@ void CreateRenderTarget() render_target_view_desc.ViewDimension = D3D10_RTV_DIMENSION_TEXTURE2D; g_pSwapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&pBackBuffer); g_pd3dDevice->CreateRenderTargetView(pBackBuffer, &render_target_view_desc, &g_mainRenderTargetView); - g_pd3dDevice->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL); pBackBuffer->Release(); } @@ -196,6 +195,7 @@ int main(int, char**) } // Rendering + g_pd3dDevice->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL); g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_color); ImGui::Render(); diff --git a/examples/directx11_example/main.cpp b/examples/directx11_example/main.cpp index d7eb1df2..79e7bb16 100644 --- a/examples/directx11_example/main.cpp +++ b/examples/directx11_example/main.cpp @@ -27,7 +27,6 @@ void CreateRenderTarget() render_target_view_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; g_pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&pBackBuffer); g_pd3dDevice->CreateRenderTargetView(pBackBuffer, &render_target_view_desc, &g_mainRenderTargetView); - g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL); pBackBuffer->Release(); } @@ -199,6 +198,7 @@ int main(int, char**) } // Rendering + g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL); g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_color); ImGui::Render(); From 3849bb4470aebb4ff276113170f26cc82f990f49 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 25 Dec 2017 16:03:58 +0100 Subject: [PATCH 2/2] Moving window doesn't use accumulating MouseDelta so straying out of boundaries keeps moved window at the same spot. --- imgui.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index a2214220..d8eba7a5 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2379,9 +2379,10 @@ void ImGui::NewFrame() IM_ASSERT(g.MovingWindow->MoveId == g.MovingWindowMoveId); if (g.IO.MouseDown[0]) { - g.MovingWindow->RootWindow->PosFloat += g.IO.MouseDelta; - if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f) + ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset; + if (g.MovingWindow->RootWindow->PosFloat.x != pos.x || g.MovingWindow->RootWindow->PosFloat.y != pos.y) MarkIniSettingsDirty(g.MovingWindow->RootWindow); + g.MovingWindow->RootWindow->PosFloat = pos; FocusWindow(g.MovingWindow); } else @@ -2930,6 +2931,7 @@ void ImGui::EndFrame() g.MovingWindow = g.HoveredWindow; g.MovingWindowMoveId = g.MovingWindow->MoveId; SetActiveID(g.MovingWindowMoveId, g.HoveredRootWindow); + g.ActiveIdClickOffset = g.IO.MousePos - g.MovingWindow->RootWindow->Pos; } } else if (g.NavWindow != NULL && GetFrontMostModalRootWindow() == NULL)