Changeset 0e6ecf3 in opengl-game for vulkan-game.cpp


Ignore:
Timestamp:
Jul 19, 2019, 8:50:06 PM (6 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
8667f76
Parents:
75108ef
Message:

Create a game gui implementation using glfw3 and move window create/destruction and Vulkan surface creation to the game gui

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    r75108ef r0e6ecf3  
    1 #include <vulkan/vulkan.h>
    2 
    3 #include <SDL2/SDL.h>
    4 #include <SDL2/SDL_vulkan.h>
     1#include "game-gui-glfw.hpp"
     2
     3#include "game-gui-sdl.hpp"
    54
    65//#define _USE_MATH_DEFINES // Will be needed when/if I need to # include <cmath>
     
    1110#include <glm/mat4x4.hpp>
    1211
     12#include <fstream>
    1313#include <iostream>
     14#include <optional>
     15#include <set>
    1416#include <vector>
    15 #include <set>
    16 #include <stdexcept>
    17 #include <cstdlib>
    18 #include <optional>
    19 #include <algorithm>
    20 #include <fstream>
    21 
    22 #include "game-gui-sdl.hpp"
    2317
    2418using namespace std;
     
    137131            return RTWO_ERROR;
    138132         } else {
    139             // On Apple's OS X you must set the NSHighResolutionCapable Info.plist property to YES,
    140             // otherwise you will not receive a High DPI OpenGL canvas.
    141 
    142             // TODO: Move this into some generic method in game-gui-sdl
    143             window = SDL_CreateWindow("Vulkan Game",
    144                SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
    145                SCREEN_WIDTH, SCREEN_HEIGHT,
    146                SDL_WINDOW_VULKAN | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
     133            window = (SDL_Window*) gui->CreateWindow("Vulkan Game", SCREEN_WIDTH, SCREEN_HEIGHT);
    147134
    148135            if (window == nullptr) {
     
    274261         }
    275262
    276          if (!SDL_Vulkan_CreateSurface(window, instance, &surface)) {
     263         if (gui->CreateVulkanSurface(instance, &surface) == RTWO_ERROR) {
    277264            throw runtime_error("failed to create window surface!");
    278265         }
    279 
    280          /*
    281          if (glfwCreateWindowSurface(instance, window, nullptr, &surface) != VK_SUCCESS) {
    282             throw runtime_error("failed to create window surface!");
    283          }
    284          */
    285266      }
    286267
     
    1014995         vkDestroyInstance(instance, nullptr);
    1015996
    1016          // TODO: Move this into some generic method in game-gui-sdl
    1017          SDL_DestroyWindow(window);
    1018 
     997         gui->DestroyWindow();
    1019998         gui->Shutdown();
    1020999         delete gui;
     
    10291008
    10301009         return VK_FALSE;
    1031 }
     1010      }
    10321011
    10331012      static vector<char> readFile(const string& filename) {
Note: See TracChangeset for help on using the changeset viewer.