[3b7d497] | 1 | #ifndef _SDL_GAME_H
|
---|
| 2 | #define _SDL_GAME_H
|
---|
| 3 |
|
---|
| 4 | #include <vector>
|
---|
| 5 |
|
---|
| 6 | #include <vulkan/vulkan.h>
|
---|
| 7 |
|
---|
| 8 | #include <SDL2/SDL.h>
|
---|
| 9 |
|
---|
[6493e43] | 10 | #include "IMGUI/imgui_impl_vulkan.h"
|
---|
| 11 |
|
---|
[3b7d497] | 12 | #include "consts.hpp"
|
---|
| 13 |
|
---|
| 14 | #include "game-gui-sdl.hpp"
|
---|
| 15 |
|
---|
| 16 | using namespace std;
|
---|
| 17 |
|
---|
| 18 | #define VulkanGame NewVulkanGame
|
---|
| 19 |
|
---|
| 20 | #ifdef NDEBUG
|
---|
| 21 | const bool ENABLE_VALIDATION_LAYERS = false;
|
---|
| 22 | #else
|
---|
| 23 | const bool ENABLE_VALIDATION_LAYERS = true;
|
---|
| 24 | #endif
|
---|
| 25 |
|
---|
| 26 | class VulkanGame {
|
---|
| 27 | public:
|
---|
| 28 | VulkanGame(int maxFramesInFlight);
|
---|
| 29 | ~VulkanGame();
|
---|
| 30 |
|
---|
| 31 | void run(int width, int height, unsigned char guiFlags); // Mostly example code
|
---|
| 32 |
|
---|
| 33 | private:
|
---|
| 34 | static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
|
---|
| 35 | VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
|
---|
| 36 | VkDebugUtilsMessageTypeFlagsEXT messageType,
|
---|
| 37 | const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
|
---|
| 38 | void* pUserData);
|
---|
| 39 |
|
---|
| 40 | // TODO: Make these consts static
|
---|
| 41 | // Also, maybe move them into consts.hpp
|
---|
| 42 |
|
---|
| 43 | const int MAX_FRAMES_IN_FLIGHT; // Unused right now
|
---|
| 44 |
|
---|
| 45 | // TODO: Good place to start using smart pointers
|
---|
| 46 | GameGui* gui;
|
---|
| 47 |
|
---|
| 48 | SDL_version sdlVersion;
|
---|
| 49 | SDL_Window* window;
|
---|
| 50 |
|
---|
| 51 | VkDebugUtilsMessengerEXT debugMessenger = VK_NULL_HANDLE;
|
---|
| 52 | VkSurfaceKHR surface; // TODO: Change the variable name to vulkanSurface
|
---|
[6493e43] | 53 |
|
---|
| 54 | VkQueue graphicsQueue;
|
---|
| 55 | VkQueue presentQueue;
|
---|
[3b7d497] | 56 |
|
---|
| 57 | // My code, but not complete. Skips creating the SDL renderer, probably because it doesn't use hardware acceleration.
|
---|
| 58 | // I should try to get uncapped framerate and compare performance w/ and w/out an SDL renderer
|
---|
| 59 | bool initUI(int width, int height, unsigned char guiFlags);
|
---|
| 60 | void initVulkan(); // Mostly example code
|
---|
| 61 | void cleanup(); // Mostly example
|
---|
| 62 |
|
---|
| 63 | void createVulkanInstance(const vector<const char*>& validationLayers);
|
---|
| 64 | void setupDebugMessenger();
|
---|
| 65 | void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo);
|
---|
| 66 | void createVulkanSurface();
|
---|
| 67 | void pickPhysicalDevice(const vector<const char*>& deviceExtensions); // Double-check, but it should be a copy of my code. Still uses g_Instance and g_Physical device though
|
---|
| 68 | bool isDeviceSuitable(VkPhysicalDevice physicalDevice, const vector<const char*>& deviceExtensions);
|
---|
| 69 | void createLogicalDevice(const vector<const char*>& validationLayers,
|
---|
| 70 | const vector<const char*>& deviceExtensions); // Only creates the graphics queue. Later, checks that this queue also supports presenting, but this codebase does not seem to support a separate present queue
|
---|
[6493e43] | 71 |
|
---|
| 72 | // Pipeline variables. Hopefully, I can eventually use the GraphicsPipeline_Vulkan class for the imgui pipeline
|
---|
| 73 | VkDescriptorPool descriptorPool;
|
---|
| 74 |
|
---|
[3b7d497] | 75 | };
|
---|
| 76 |
|
---|
[6493e43] | 77 | // These functions are helper functions that were used in the ImGui Vulkan+SDL example
|
---|
| 78 |
|
---|
| 79 | void ImGui_ImplVulkanH_CreateOrResizeWindow(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device,
|
---|
| 80 | ImGui_ImplVulkanH_Window* wnd, uint32_t queue_family, const VkAllocationCallbacks* allocator, int w, int h,
|
---|
| 81 | uint32_t min_image_count);
|
---|
| 82 |
|
---|
| 83 | void ImGui_ImplVulkanH_CreateWindowSwapChain(VkPhysicalDevice physical_device, VkDevice device,
|
---|
| 84 | ImGui_ImplVulkanH_Window* wd, const VkAllocationCallbacks* allocator, int w, int h, uint32_t min_image_count);
|
---|
| 85 |
|
---|
| 86 | // End helper functions
|
---|
| 87 |
|
---|
[3b7d497] | 88 | #endif // _SDL_GAME_H
|
---|