Changeset cabdd5c in opengl-game for vulkan-ref.cpp


Ignore:
Timestamp:
Sep 14, 2019, 12:13:54 AM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
2e77b3f
Parents:
cb01aff
Message:

Mark which parts of the old code were moved over to the new openglgame and vulkangame code and remove some TODOs that were moved over

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-ref.cpp

    rcb01aff rcabdd5c  
    108108};
    109109
     110/*** START OF REFACTORED CODE ***/
    110111VkResult CreateDebugUtilsMessengerEXT(VkInstance instance,
    111112      const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
     
    144145   private:
    145146      GameGui* gui = new GameGui_SDL();
     147
    146148      SDL_version sdlVersion;
    147149      SDL_Window* window = nullptr;
    148 
    149       // TODO: Come up with more descriptive names for these
    150150      SDL_Renderer* gRenderer = nullptr;
     151/*** END OF REFACTORED CODE ***/
    151152      SDL_Texture* uiOverlay = nullptr;
    152153
     
    155156      SDL_Texture* uiImage = nullptr;
    156157
     158/*** START OF REFACTORED CODE ***/
    157159      VkInstance instance;
    158160      VkDebugUtilsMessengerEXT debugMessenger;
     161/*** END OF REFACTORED CODE ***/
    159162      VkSurfaceKHR surface;
    160163
     
    222225      bool framebufferResized = false;
    223226
    224       // TODO: Make make some more initi functions, or call this initUI if the
    225       // amount of things initialized here keeps growing
     227/*** START OF REFACTORED CODE ***/
    226228      bool initWindow() {
    227          // TODO: Put all fonts, textures, and images in the assets folder
    228 
    229229         if (gui->init() == RTWO_ERROR) {
    230230            cout << "UI library could not be initialized!" << endl;
     
    245245            return RTWO_ERROR;
    246246         }
     247/*** END OF REFACTORED CODE ***/
    247248
    248249         SDL_VERSION(&sdlVersion);
     
    307308      }
    308309
     310/*** START OF REFACTORED CODE ***/
    309311      void initVulkan() {
    310312         createInstance();
    311313         setupDebugMessenger();
     314/*** END OF REFACTORED CODE ***/
    312315         createSurface();
    313316         pickPhysicalDevice();
     
    459462      }
    460463
     464/*** START OF REFACTORED CODE ***/
    461465      vector<const char*> getRequiredExtensions() {
    462466         vector<const char*> extensions = gui->getRequiredExtensions();
     
    487491         createInfo.pfnUserCallback = debugCallback;
    488492      }
     493      /*** END OF REFACTORED CODE ***/
    489494
    490495      void createSurface() {
     
    708713         if (capabilities.currentExtent.width != numeric_limits<uint32_t>::max()) {
    709714            return capabilities.currentExtent;
    710          }
    711          else {
    712             int width, height;
    713             gui->getWindowSize(&width, &height);
    714 
     715         } else {
    715716            VkExtent2D actualExtent = {
    716                static_cast<uint32_t>(width),
    717                static_cast<uint32_t>(height)
     717               static_cast<uint32_t>(gui->getWindowWidth()),
     718               static_cast<uint32_t>(gui->getWindowHeight())
    718719            };
    719720
     
    18111812
    18121813      void recreateSwapChain() {
    1813          int width = 0, height = 0;
    1814 
    1815          gui->getWindowSize(&width, &height);
    1816 
    1817          while (width == 0 || height == 0 ||
     1814         gui->refreshWindowSize();
     1815
     1816         while (gui->getWindowWidth() == 0 || gui->getWindowHeight() == 0 ||
    18181817            (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) != 0) {
    18191818            SDL_WaitEvent(nullptr);
    1820             gui->getWindowSize(&width, &height);
     1819            gui->refreshWindowSize();
    18211820         }
    18221821
     
    18751874
    18761875         vkDestroyCommandPool(device, commandPool, nullptr);
    1877 
    18781876         vkDestroyDevice(device, nullptr);
    1879 
     1877         vkDestroySurfaceKHR(instance, surface, nullptr);
     1878
     1879/*** START OF REFACTORED CODE ***/
    18801880         if (enableValidationLayers) {
    18811881            DestroyDebugUtilsMessengerEXT(instance, debugMessenger, nullptr);
    18821882         }
    18831883
    1884          vkDestroySurfaceKHR(instance, surface, nullptr);
    18851884         vkDestroyInstance(instance, nullptr);
     1885/*** END OF REFACTORED CODE ***/
    18861886
    18871887         // TODO: Check if any of these functions accept null parameters
     
    19061906         }
    19071907
     1908/*** START OF REFACTORED CODE ***/
    19081909         SDL_DestroyRenderer(gRenderer);
    19091910         gRenderer = nullptr;
     
    19121913         gui->shutdown();
    19131914         delete gui;
     1915/*** END OF REFACTORED CODE ***/
    19141916      }
    19151917
     
    19861988};
    19871989
     1990/*** START OF REFACTORED CODE ***/
    19881991int main(int argc, char* argv[]) {
    19891992
     
    20092012   return EXIT_SUCCESS;
    20102013}
     2014/*** END OF REFACTORED CODE ***/
Note: See TracChangeset for help on using the changeset viewer.