From e8d4b3dcce0f595eae47eb33c442e60b67682e87 Mon Sep 17 00:00:00 2001 From: pezcode Date: Tue, 20 Apr 2021 00:30:03 +0200 Subject: [PATCH] Fixes for multiple windows and example 22 (#2483) --- examples/22-windows/windows.cpp | 28 ++++++++++++------------- examples/common/entry/entry_windows.cpp | 2 ++ src/bgfx.cpp | 2 +- src/renderer_d3d12.cpp | 1 + 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/examples/22-windows/windows.cpp b/examples/22-windows/windows.cpp index eb8a21e5d..2f944fd12 100644 --- a/examples/22-windows/windows.cpp +++ b/examples/22-windows/windows.cpp @@ -177,20 +177,6 @@ public: { entry::MouseState mouseState = m_state.m_mouse; - imguiBeginFrame(mouseState.m_mx - , mouseState.m_my - , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) - | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) - | (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) - , mouseState.m_mz - , uint16_t(m_width) - , uint16_t(m_height) - ); - - showExampleDialog(this); - - imguiEndFrame(); - if (isValid(m_state.m_handle) ) { if (0 == m_state.m_handle.idx) @@ -231,6 +217,20 @@ public: } } + imguiBeginFrame(mouseState.m_mx + , mouseState.m_my + , (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0) + | (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0) + | (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0) + , mouseState.m_mz + , uint16_t(m_width) + , uint16_t(m_height) + ); + + showExampleDialog(this); + + imguiEndFrame(); + const bx::Vec3 at = { 0.0f, 0.0f, 0.0f }; const bx::Vec3 eye = { 0.0f, 0.0f, -35.0f }; diff --git a/examples/common/entry/entry_windows.cpp b/examples/common/entry/entry_windows.cpp index 703e4cb5d..076bd03b2 100644 --- a/examples/common/entry/entry_windows.cpp +++ b/examples/common/entry/entry_windows.cpp @@ -573,6 +573,8 @@ namespace entry , (HINSTANCE)GetModuleHandle(NULL) , 0 ); + + adjust(hwnd, msg->m_width, msg->m_height, true); clear(hwnd); m_hwnd[_wparam] = hwnd; diff --git a/src/bgfx.cpp b/src/bgfx.cpp index d4e093d24..0c3be13d9 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -1406,7 +1406,7 @@ namespace bgfx { viewRemap[m_viewRemap[ii] ] = ViewId(ii); - View& view = s_ctx->m_view[ii]; + View& view = m_view[ii]; Rect rect(0, 0, uint16_t(m_resolution.width), uint16_t(m_resolution.height) ); if (isValid(view.m_fbh) ) diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index db3d137bd..dae3f7f6d 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -1021,6 +1021,7 @@ namespace bgfx { namespace d3d12 m_resolution.width = _init.resolution.width; m_resolution.height = _init.resolution.height; + m_windows[0] = BGFX_INVALID_HANDLE; m_numWindows = 1; #if BX_PLATFORM_WINDOWS