source: opengl-game/sdl-game.hpp@ 3b7d497

feature/imgui-sdl
Last change on this file since 3b7d497 was 3b7d497, checked in by Dmitry Portnoy <dportnoy@…>, 4 years ago

Start implementing an ImGUI ui on top of SDL and Vulkan using some example code

  • Property mode set to 100644
File size: 2.4 KB
Line 
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
10#include "consts.hpp"
11
12#include "game-gui-sdl.hpp"
13
14using namespace std;
15
16#define VulkanGame NewVulkanGame
17
18#ifdef NDEBUG
19 const bool ENABLE_VALIDATION_LAYERS = false;
20#else
21 const bool ENABLE_VALIDATION_LAYERS = true;
22#endif
23
24class VulkanGame {
25 public:
26 VulkanGame(int maxFramesInFlight);
27 ~VulkanGame();
28
29 void run(int width, int height, unsigned char guiFlags); // Mostly example code
30
31 private:
32 static VKAPI_ATTR VkBool32 VKAPI_CALL debugCallback(
33 VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
34 VkDebugUtilsMessageTypeFlagsEXT messageType,
35 const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData,
36 void* pUserData);
37
38 // TODO: Make these consts static
39 // Also, maybe move them into consts.hpp
40
41 const int MAX_FRAMES_IN_FLIGHT; // Unused right now
42
43 // TODO: Good place to start using smart pointers
44 GameGui* gui;
45
46 SDL_version sdlVersion;
47 SDL_Window* window;
48
49 VkDebugUtilsMessengerEXT debugMessenger = VK_NULL_HANDLE;
50 VkSurfaceKHR surface; // TODO: Change the variable name to vulkanSurface
51
52 // My code, but not complete. Skips creating the SDL renderer, probably because it doesn't use hardware acceleration.
53 // I should try to get uncapped framerate and compare performance w/ and w/out an SDL renderer
54 bool initUI(int width, int height, unsigned char guiFlags);
55 void initVulkan(); // Mostly example code
56 void cleanup(); // Mostly example
57
58 void createVulkanInstance(const vector<const char*>& validationLayers);
59 void setupDebugMessenger();
60 void populateDebugMessengerCreateInfo(VkDebugUtilsMessengerCreateInfoEXT& createInfo);
61 void createVulkanSurface();
62 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
63 bool isDeviceSuitable(VkPhysicalDevice physicalDevice, const vector<const char*>& deviceExtensions);
64 void createLogicalDevice(const vector<const char*>& validationLayers,
65 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
66};
67
68#endif // _SDL_GAME_H
Note: See TracBrowser for help on using the repository browser.