Browse Source

Examples: SDL+DX11: Fixed resizing main window. Amend (#3057)

ocornut 5 years ago
parent
commit
b016f1ad70
2 changed files with 5 additions and 6 deletions
  1. 2 1
      docs/CHANGELOG.txt
  2. 3 5
      examples/example_sdl_directx11/main.cpp

+ 2 - 1
docs/CHANGELOG.txt

@@ -67,7 +67,8 @@ Other Changes:
 - Backends: SDL: Added ImGui_ImplSDL2_InitForMetal() for API consistency (even though the function
 - Backends: SDL: Added ImGui_ImplSDL2_InitForMetal() for API consistency (even though the function
   currently does nothing).
   currently does nothing).
 - Backends: SDL: Fixed mapping for ImGuiKey_KeyPadEnter. (#3031) [@Davido71]
 - Backends: SDL: Fixed mapping for ImGuiKey_KeyPadEnter. (#3031) [@Davido71]
-- Examples: Added SDL2+Metal example application. (#3017) [@coding-jackalope]
+- Examples: SDL+DX11: Fixed resizing main window. (#3057) [@joeslay]
+- Examples: Added SDL+Metal example application. (#3017) [@coding-jackalope]
 
 
 
 
 -----------------------------------------------------------------------
 -----------------------------------------------------------------------

+ 3 - 5
examples/example_sdl_directx11/main.cpp

@@ -101,12 +101,10 @@ int main(int, char**)
                 done = true;
                 done = true;
             if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
             if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_CLOSE && event.window.windowID == SDL_GetWindowID(window))
                 done = true;
                 done = true;
-            if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED)
+            if (event.type == SDL_WINDOWEVENT && event.window.event == SDL_WINDOWEVENT_RESIZED && event.window.windowID == SDL_GetWindowID(window))
             {                
             {                
-                g_pd3dDeviceContext->OMSetRenderTargets(0, 0, 0);
-                // Release all outstanding references to the swap chain's buffers.
-                g_mainRenderTargetView->Release();
-
+                // Release all outstanding references to the swap chain's buffers before resizing.
+                CleanupRenderTarget();
                 g_pSwapChain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0);
                 g_pSwapChain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN, 0);
                 CreateRenderTarget();
                 CreateRenderTarget();
             }
             }