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