Changeset 8d96e95 in opengl-game


Ignore:
Timestamp:
Feb 14, 2021, 6:37:24 PM (4 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
6053b24
Parents:
81869ef
Message:

Avoid recreating the swap chain when the window is minimized

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • game-gui-sdl.cpp

    r81869ef r8d96e95  
    157157   // TODO: Make sure this works on a mac (the analogous glfw function had issues on Mac retina displays)
    158158   SDL_GetWindowSize(window, &windowWidth, &windowHeight);
     159
     160   if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) {
     161      windowWidth = 0;
     162      windowHeight = 0;
     163   }
    159164}
    160165
  • sdl-game.cpp

    r81869ef r8d96e95  
    170170      if (shouldRecreateSwapChain) {
    171171         gui->refreshWindowSize();
    172 
    173          int width = gui->getWindowWidth();
    174          int height = gui->getWindowHeight();
    175          if (width > 0 && height > 0) {
     172         const bool isMinimized = gui->getWindowWidth() == 0 || gui->getWindowHeight() == 0;
     173
     174         if (!isMinimized) {
    176175            // TODO: This should be used if the min image count changes, presumably because a new surface was created
    177176            // with a different image count or something like that. Maybe I want to add code to query for a new min image count
     
    211210
    212211      gui->refreshWindowSize();
    213 
    214       const bool isMinimized = gui->getWindowWidth() <= 0 || gui->getWindowHeight() <= 0;
     212      const bool isMinimized = gui->getWindowWidth() == 0 || gui->getWindowHeight() == 0;
    215213
    216214      if (!isMinimized) {
  • vulkan-game.cpp

    r81869ef r8d96e95  
    938938      if (shouldRecreateSwapChain) {
    939939         gui->refreshWindowSize();
    940 
    941          int width = gui->getWindowWidth();
    942          int height = gui->getWindowHeight();
    943          if (width > 0 && height > 0) {
     940         const bool isMinimized = gui->getWindowWidth() == 0 || gui->getWindowHeight() == 0;
     941
     942         if (!isMinimized) {
    944943            // TODO: This should be used if the min image count changes, presumably because a new surface was created
    945944            // with a different image count or something like that. Maybe I want to add code to query for a new min image count
     
    965964
    966965      ImGui_ImplVulkan_NewFrame();
    967       ImGui_ImplSDL2_NewFrame(this->window);
     966      ImGui_ImplSDL2_NewFrame(window);
    968967      ImGui::NewFrame();
    969968
     
    994993
    995994      gui->refreshWindowSize();
    996 
    997       const bool isMinimized = gui->getWindowWidth() <= 0 || gui->getWindowHeight() <= 0;
     995      const bool isMinimized = gui->getWindowWidth() == 0 || gui->getWindowHeight() == 0;
    998996
    999997      if (!isMinimized) {
Note: See TracChangeset for help on using the changeset viewer.