source: opengl-game/vulkan-game.hpp@ 0b1b52d

feature/imgui-sdl points-test
Last change on this file since 0b1b52d was 7d2b0b9, checked in by Dmitry Portnoy <dmp1488@…>, 5 years ago

Add and begin implementing a GraphicsPipeline class to hold info for the Vulkan graphics pipeline

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#ifndef _VULKAN_GAME_H
2#define _VULKAN_GAME_H
3
4#include "game-gui-sdl.hpp"
5#include "graphics-pipeline_vulkan.hpp"
6
7#ifdef NDEBUG
8 const bool ENABLE_VALIDATION_LAYERS = false;
9#else
10 const bool ENABLE_VALIDATION_LAYERS = true;
11#endif
12
13class VulkanGame {
14 public:
15 VulkanGame();
16 ~VulkanGame();
17
18 void run(int width, int height, unsigned char guiFlags);
19
20 private:
21 GameGui* gui;
22
23 vector<GraphicsPipeline_Vulkan> graphicsPipelines;
24
25 SDL_version sdlVersion;
26 SDL_Window* window;
27 SDL_Renderer* renderer;
28
29 VkInstance instance;
30 VkDebugUtilsMessengerEXT debugMessenger;
31 VkSurfaceKHR surface; // TODO: Change the variable name to vulkanSurface
32 VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
33 VkDevice device;
34
35 VkQueue graphicsQueue;
36 VkQueue presentQueue;
37
38 VkSwapchainKHR swapChain;
39 vector<VkImage> swapChainImages;
40 VkFormat swapChainImageFormat;
41 VkExtent2D swapChainExtent;
42 vector<VkImageView> swapChainImageViews;
43
44 VkRenderPass renderPass;
45 VkCommandPool commandPool;
46
47 bool framebufferResized = false;
48
49 bool initWindow(int width, int height, unsigned char guiFlags);
50 void initVulkan();
51 void mainLoop();
52 void renderUI();
53 void renderScene();
54 void cleanup();
55
56 void createVulkanInstance(const vector<const char*> &validationLayers);
57 void setupDebugMessenger();
58 void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo);
59 void createVulkanSurface();
60 void pickPhysicalDevice(const vector<const char*>& deviceExtensions);
61 bool isDeviceSuitable(VkPhysicalDevice physicalDevice, const vector<const char*>& deviceExtensions);
62 void createLogicalDevice(
63 const vector<const char*> validationLayers,
64 const vector<const char*>& deviceExtensions);
65 void createSwapChain();
66 void createImageViews();
67 void createRenderPass();
68 VkFormat findDepthFormat();
69 void createCommandPool();
70
71 void cleanupSwapChain();
72
73 static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
74 VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
75 VkDebugUtilsMessageTypeFlagsEXT messageType,
76 const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
77 void* pUserData);
78};
79
80#endif // _VULKAN_GAME_H
Note: See TracBrowser for help on using the repository browser.