Changeset 8667f76 in opengl-game


Ignore:
Timestamp:
Jul 19, 2019, 9:49:52 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
80edd70
Parents:
0e6ecf3
git-author:
Dmitry Portnoy <dmitry.portnoy@…> (07/19/19 21:45:27)
git-committer:
Dmitry Portnoy <dmitry.portnoy@…> (07/19/19 21:49:52)
Message:

Move getWindowSize and getRequiredExtensions to the game gui

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • game-gui-glfw.cpp

    r0e6ecf3 r8667f76  
    2626      RTWO_SUCCESS : RTWO_ERROR;
    2727}
     28
     29vector<const char*> GameGui_GLFW::GetRequiredExtensions() {
     30   uint32_t glfwExtensionCount = 0;
     31   const char** glfwExtensions;
     32
     33   glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
     34
     35   vector<const char*> extensions(glfwExtensions, glfwExtensions + glfwExtensionCount);
     36
     37   return extensions;
     38}
     39
     40void GameGui_GLFW::GetWindowSize(int* width, int* height) {
     41   glfwGetFramebufferSize(window, width, height);
     42}
  • game-gui-glfw.hpp

    r0e6ecf3 r8667f76  
    1616
    1717      bool CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface);
     18      vector<const char*> GetRequiredExtensions();
     19      void GetWindowSize(int* width, int* height);
    1820
    1921   private:
  • game-gui-sdl.cpp

    r0e6ecf3 r8667f76  
    3737      RTWO_SUCCESS : RTWO_ERROR;
    3838}
     39
     40vector<const char*> GameGui_SDL::GetRequiredExtensions() {
     41   uint32_t extensionCount = 0;
     42   SDL_Vulkan_GetInstanceExtensions(window, &extensionCount, nullptr);
     43
     44   vector<const char*> extensions(extensionCount);
     45   SDL_Vulkan_GetInstanceExtensions(window, &extensionCount, extensions.data());
     46
     47   return extensions;
     48}
     49
     50void GameGui_SDL::GetWindowSize(int* width, int* height) {
     51   SDL_GetWindowSize(window, width, height);
     52}
  • game-gui-sdl.hpp

    r0e6ecf3 r8667f76  
    1616
    1717      bool CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface);
     18      vector<const char*> GetRequiredExtensions();
     19      void GetWindowSize(int* width, int* height);
    1820
    1921   private:
  • game-gui.hpp

    r0e6ecf3 r8667f76  
    55
    66#include <string>
     7#include <vector>
    78
    89using namespace std;
     
    2122      virtual void DestroyWindow() = 0;
    2223
    23       virtual bool CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) = 0;
     24      virtual bool CreateVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) = 0;
     25      virtual vector<const char*> GetRequiredExtensions() = 0;
     26      virtual void GetWindowSize(int* width, int* height) = 0;
    2427};
    2528
  • vulkan-game.cpp

    r0e6ecf3 r8667f76  
    1414#include <optional>
    1515#include <set>
    16 #include <vector>
    1716
    1817using namespace std;
     
    125124      bool framebufferResized = false;
    126125
    127       // both SDL and GLFW create window functions return NULL on failure
    128126      bool initWindow() {
    129127         if (gui->Init() == RTWO_ERROR) {
     
    160158      void recreateSwapChain() {
    161159         int width = 0, height = 0;
    162          SDL_GetWindowSize(window, &width, &height);
     160         gui->GetWindowSize(&width, &height);
    163161
    164162         while (width == 0 || height == 0 ||
    165163            (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) != 0) {
    166164            SDL_WaitEvent(nullptr);
    167             SDL_GetWindowSize(window, &width, &height);
     165            gui->GetWindowSize(&width, &height);
    168166         }
    169167
     
    219217         createInfo.ppEnabledExtensionNames = extensions.data();
    220218
    221          cout << endl << "SDL extensions:" << endl;
     219         cout << endl << "Extensions:" << endl;
    222220         for (const char* extensionName : extensions) {
    223221            cout << extensionName << endl;
     
    488486         } else {
    489487            int width, height;
    490             SDL_GetWindowSize(window, &width, &height);
     488            gui->GetWindowSize(&width, &height);
    491489
    492490            VkExtent2D actualExtent = {
     
    511509
    512510      vector<const char*> getRequiredExtensions() {
    513          uint32_t extensionCount = 0;
    514          SDL_Vulkan_GetInstanceExtensions(window, &extensionCount, nullptr);
    515 
    516          vector<const char*> extensions(extensionCount);
    517          SDL_Vulkan_GetInstanceExtensions(window, &extensionCount, extensions.data());
     511         vector<const char*> extensions = gui->GetRequiredExtensions();
    518512
    519513         if (enableValidationLayers) {
Note: See TracChangeset for help on using the changeset viewer.