Changeset 28ea92f in opengl-game


Ignore:
Timestamp:
Feb 14, 2021, 3:12:38 AM (3 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
737c26a
Parents:
4e2c709
Message:

Rename the flag for recreating the swap chain to shouldRecreateSwapChain in both VulkanGame and SDLGame

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sdl-game.cpp

    r4e2c709 r28ea92f  
    1515
    1616#define IMGUI_UNLIMITED_FRAME_RATE
    17 
    18 static bool g_SwapChainRebuild = false;
    1917
    2018static void check_imgui_vk_result(VkResult res) {
     
    172170
    173171      // Resize swap chain?
    174       if (g_SwapChainRebuild) {
     172      if (shouldRecreateSwapChain) {
    175173         int width, height;
    176174         SDL_GetWindowSize(window, &width, &height);
     
    184182
    185183            imageIndex = 0;
    186             g_SwapChainRebuild = false;
     184            shouldRecreateSwapChain = false;
    187185         }
    188186      }
     
    823821
    824822   if (result == VK_ERROR_OUT_OF_DATE_KHR) {
    825       g_SwapChainRebuild = true;
     823      shouldRecreateSwapChain = true;
    826824      return;
    827    }
    828    else {
     825   } else {
    829826      VKUTIL_CHECK_RESULT(result, "failed to acquire swap chain image!");
    830827   }
     
    895892
    896893void VulkanGame::presentFrame() {
    897    if (g_SwapChainRebuild)
     894   if (shouldRecreateSwapChain) {
    898895      return;
     896   }
    899897
    900898   VkSemaphore signalSemaphores[] = { renderCompleteSemaphores[currentFrame] };
     
    914912   // to framebufferResized, but not quite the same
    915913   if (result == VK_ERROR_OUT_OF_DATE_KHR) {
    916       g_SwapChainRebuild = true;
     914      shouldRecreateSwapChain = true;
    917915      return;
    918    }
    919    else if (result != VK_SUCCESS) {
     916   } else if (result != VK_SUCCESS) {
    920917      throw runtime_error("failed to present swap chain image!");
    921918   }
  • sdl-game.hpp

    r4e2c709 r28ea92f  
    8686      uint32_t currentFrame;
    8787
     88      bool shouldRecreateSwapChain;
     89
    8890      // My code, but not complete. Skips creating the SDL renderer, probably because it doesn't use hardware acceleration.
    8991      // I should try to get uncapped framerate and compare performance w/ and w/out an SDL renderer
  • vulkan-game.cpp

    r4e2c709 r28ea92f  
    6565
    6666   this->currentFrame = 0;
    67    this->framebufferResized = false;
     67   shouldRecreateSwapChain = false;
    6868
    6969   this->object_VP_mats = {};
     
    812812            case UI_EVENT_WINDOWRESIZE:
    813813               cout << "Window resize event detected" << endl;
    814                framebufferResized = true;
     814               shouldRecreateSwapChain = true;
    815815               break;
    816816            case UI_EVENT_KEYDOWN:
     
    18001800   VkResult result = vkQueuePresentKHR(presentQueue, &presentInfo);
    18011801
    1802    if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || framebufferResized) {
    1803       framebufferResized = false;
     1802   if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || shouldRecreateSwapChain) {
     1803      shouldRecreateSwapChain = false;
    18041804      recreateSwapChain();
    18051805   } else if (result != VK_SUCCESS) {
  • vulkan-game.hpp

    r4e2c709 r28ea92f  
    293293      uint32_t currentFrame;
    294294
    295       bool framebufferResized;
     295      bool shouldRecreateSwapChain;
    296296
    297297      VkDescriptorPool imguiDescriptorPool;
Note: See TracChangeset for help on using the changeset viewer.