Changeset 187b0f5 in opengl-game for sdl-game.cpp


Ignore:
Timestamp:
Mar 11, 2021, 2:44:43 AM (4 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
301c90a
Parents:
20e4c2b
git-author:
Dmitry Portnoy <dportnoy@…> (03/11/21 02:39:25)
git-committer:
Dmitry Portnoy <dportnoy@…> (03/11/21 02:44:43)
Message:

Change VulkanGame and SDLGame to only use discrete GPUs and switch the timer class to steady_clock

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sdl-game.cpp

    r20e4c2b r187b0f5  
    4949   swapChainPresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR;
    5050   swapChainMinImageCount = 0;
    51 
     51   currentFrame = 0;
     52   imageIndex = 0;
    5253   shouldRecreateSwapChain = false;
    5354
     
    254255
    255256void VulkanGame::renderLoop() {
    256    startTime = high_resolution_clock::now();
    257    curTime = duration<float, seconds::period>(high_resolution_clock::now() - startTime).count();
     257   startTime = steady_clock::now();
     258   curTime = duration<float, seconds::period>(steady_clock::now() - startTime).count();
    258259
    259260   fpsStartTime = curTime;
     
    265266   while (!done) {
    266267
    267       curTime = duration<float, seconds::period>(high_resolution_clock::now() - startTime).count();
     268      curTime = duration<float, seconds::period>(steady_clock::now() - startTime).count();
    268269
    269270      if (curTime - fpsStartTime >= 1.0f) {
     
    333334            recreateSwapChain();
    334335
    335             imageIndex = 0;
    336336            shouldRecreateSwapChain = false;
    337337         }
     
    496496
    497497   cout << "Device: " << deviceProperties.deviceName << endl;
     498
     499   // TODO: Eventually, maybe let the user pick out of a set of GPUs in case the user does want to use
     500   // an integrated GPU. On my laptop, this function returns TRUE for the integrated GPU, but crashes
     501   // when trying to use it to render. Maybe I just need to figure out which other extensions and features
     502   // to check.
     503   if (deviceProperties.deviceType != VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) {
     504      return false;
     505   }
    498506
    499507   QueueFamilyIndices indices = VulkanUtils::findQueueFamilies(physicalDevice, surface);
     
    970978
    971979   createSyncObjects();
     980
     981   imageIndex = 0;
    972982}
    973983
Note: See TracChangeset for help on using the changeset viewer.