Changeset 81869ef in opengl-game


Ignore:
Timestamp:
Feb 14, 2021, 4:08:47 PM (4 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
8d96e95
Parents:
484334e
Message:

Avoid rendering frames while the window is minimized

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sdl-game.cpp

    r484334e r81869ef  
    209209
    210210      ImGui::Render();
    211       ImDrawData* draw_data = ImGui::GetDrawData();
    212       const bool is_minimized = (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f);
    213       if (!is_minimized) {
    214          renderFrame(draw_data);
     211
     212      gui->refreshWindowSize();
     213
     214      const bool isMinimized = gui->getWindowWidth() <= 0 || gui->getWindowHeight() <= 0;
     215
     216      if (!isMinimized) {
     217         renderFrame(ImGui::GetDrawData());
    215218         presentFrame();
    216219      }
  • vulkan-game.cpp

    r484334e r81869ef  
    986986      ImGui::Render();
    987987
    988       renderFrame(ImGui::GetDrawData());
    989       presentFrame();
     988      // There is already code in renderFrame to render screen-specific things
     989      // The imgui code above should be moved to the renderUI function of the particular screen it's needed in
     990      // and currentScreen->renderUI should be called in renderFrame.
     991      // Since I am no longer drawing the UI to an sdl texture and then rendering that, I don't have to worry
     992      // about calling populateVulkanImageFromSDLTexture at all.
     993      // If I do ever want to do that again, I can still actually do it inside renderFrame
     994
     995      gui->refreshWindowSize();
     996
     997      const bool isMinimized = gui->getWindowWidth() <= 0 || gui->getWindowHeight() <= 0;
     998
     999      if (!isMinimized) {
     1000         renderFrame(ImGui::GetDrawData());
     1001         presentFrame();
     1002      }
    9901003   }
    9911004}
Note: See TracChangeset for help on using the changeset viewer.