Changeset 40eb092 in opengl-game for sdl-game.hpp
- Timestamp:
- Mar 9, 2021, 2:47:00 AM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 20e4c2b
- Parents:
- 429ac01
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sdl-game.hpp
r429ac01 r40eb092 2 2 #define _SDL_GAME_H 3 3 4 #include <chrono> 5 #include <map> 4 6 #include <vector> 7 5 8 #include <vulkan/vulkan.h> 6 9 … … 15 18 16 19 using namespace std; 20 using namespace std::chrono; 17 21 18 22 #define VulkanGame NewVulkanGame … … 23 27 const bool ENABLE_VALIDATION_LAYERS = true; 24 28 #endif 29 30 // TODO: Maybe move this to a different header 31 32 enum UIValueType { 33 UIVALUE_INT, 34 UIVALUE_DOUBLE, 35 }; 36 37 struct UIValue { 38 UIValueType type; 39 string label; 40 void* value; 41 42 UIValue(UIValueType _type, string _label, void* _value) : type(_type), label(_label), value(_value) {} 43 }; 25 44 26 45 class VulkanGame { … … 88 107 bool shouldRecreateSwapChain; 89 108 90 // My code, but not complete. Skips creating the SDL renderer, probably because it doesn't use hardware acceleration. 91 // I should try to get uncapped framerate and compare performance w/ and w/out an SDL renderer 109 /*** High-level vars ***/ 110 111 void (VulkanGame::* currentRenderScreenFn)(); 112 113 map<string, vector<UIValue>> valueLists; 114 115 int score; 116 float fps; 117 118 // TODO: Make a separate singleton Timer class 119 // It could also deal with the steady_clock vs high_resolution_clock issue 120 time_point<steady_clock> startTime; 121 float fpsStartTime, curTime; 122 123 int frameCount; 124 125 /*** Functions ***/ 126 92 127 bool initUI(int width, int height, unsigned char guiFlags); 93 void initVulkan(); // Mostly example code 94 void cleanup(); // Mostly example 128 void initVulkan(); 129 void renderLoop(); 130 void cleanup(); 95 131 96 132 void createVulkanInstance(const vector<const char*>& validationLayers); … … 120 156 void cleanupSwapChain(); 121 157 158 /*** High-level functions ***/ 159 160 void renderMainScreen(); 161 void renderGameScreen(); 162 163 void initGuiValueLists(map<string, vector<UIValue>>& valueLists); 164 void renderGuiValueList(vector<UIValue>& values); 165 166 void goToScreen(void (VulkanGame::* renderScreenFn)()); 167 void quitGame(); 168 122 169 // Pipeline variables. Hopefully, I can eventually use the GraphicsPipeline_Vulkan class for the imgui pipeline 123 170 VkDescriptorPool descriptorPool; 124 125 171 }; 126 172
Note:
See TracChangeset
for help on using the changeset viewer.