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