source: opengl-game/vulkan-game.hpp@ 771b33a

feature/imgui-sdl points-test
Last change on this file since 771b33a was 771b33a, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 years ago

In openglgame, port over some more of the pipeline creation code and the functionality to specify and initialize varying attributes

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