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).
diff --git a/examples/example_sdl_directx11/main.cpp b/examples/example_sdl_directx11/main.cpp
index 0a97325..5b748ed 100644
--- a/examples/example_sdl_directx11/main.cpp
+++ b/examples/example_sdl_directx11/main.cpp
@@ -101,6 +101,15 @@
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