Skip to content

Commit

Permalink
dx11 backend: add check / does not support window resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Feb 1, 2024
1 parent 1810fb8 commit 2b31940
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/hello_imgui/internal/backend_impls/abstract_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ float AbstractRunner::ImGuiDefaultFontGlobalScale()

float AbstractRunner::DpiWindowSizeFactor()
{
return mBackendWindowHelper->GetWindowSizeDpiScaleFactor(mWindow);
#ifdef HELLOIMGUI_HAS_DIRECTX11
return 1.f; // The current implementation of Dx11 backend does not support changing the window size
#endif
float r = mBackendWindowHelper->GetWindowSizeDpiScaleFactor(mWindow);
return 1.f;
}


Expand Down
11 changes: 11 additions & 0 deletions src/hello_imgui/internal/backend_impls/rendering_dx11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "rendering_dx11.h"
#include "hello_imgui/hello_imgui.h"

#include <cstdio>
#include <d3d11.h>
#include <iostream>

Expand Down Expand Up @@ -83,6 +84,16 @@ namespace HelloImGui
// Impl of RenderingCallbacks_Impl_SwapBuffers
void SwapDx11Buffers()
{
static ImVec2 viewportInitialSize = ImGui::GetMainViewport()->Size;
ImVec2 currentViewportSize = ImGui::GetMainViewport()->Size;
if ((currentViewportSize.x != viewportInitialSize.x) || (currentViewportSize.y != viewportInitialSize.y))
{
// Help appreciated!
IM_ASSERT(false && "rendering_dx11.cpp::SwapDx11Buffers() The current implementation of Dx11 backend does "
"not support changing the window size!");
// Once solved, AbstractRunner::DpiWindowSizeFactor() can be corrected by removing the ifdef
}

auto& gDx11Globals = GetDx11Globals();
gDx11Globals.pSwapChain->Present(1, 0); // Present with vsync
}
Expand Down

0 comments on commit 2b31940

Please sign in to comment.