From a0f01d229039417d139a06fd3da687c8add56377 Mon Sep 17 00:00:00 2001 From: joeslay <54322500+joeslay@users.noreply.github.com> Date: Wed, 11 Mar 2020 17:51:02 +0000 Subject: [PATCH] Improve resizing in dx11 example (#3057) Make the dx11 example implementation resize the window in a sane way, i.e. not the stretching/scaling the initial render to fit the new window size (current behaviour). --- examples/example_sdl_directx11/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/example_sdl_directx11/main.cpp b/examples/example_sdl_directx11/main.cpp index 0a97325d..5b748ed6 100644 --- a/examples/example_sdl_directx11/main.cpp +++ b/examples/example_sdl_directx11/main.cpp @@ -101,6 +101,15 @@ int main(int, char**) done = true; if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window)) done = true; + if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED) + { + g_pd3dDeviceContext->OMSetRenderTargets(0, 0, 0); + // Release all outstanding references to the swap chain's buffers. + g_mainRenderTargetView->Release(); + + g_pSwapChain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0); + CreateRenderTarget(); + } } // Start the Dear ImGui frame