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