Changeset 20e4c2b in opengl-game for vulkan-game.hpp
- Timestamp:
- Mar 9, 2021, 2:59:40 AM (4 years ago)
- Branches:
- feature/imgui-sdl
- Children:
- 187b0f5
- Parents:
- 40eb092
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vulkan-game.hpp
r40eb092 r20e4c2b 7 7 #include <vector> 8 8 9 #include <vulkan/vulkan.h> 10 11 #include <SDL2/SDL.h> 12 #include <SDL2/SDL_ttf.h> 13 9 14 #define GLM_FORCE_RADIANS 10 15 #define GLM_FORCE_DEPTH_ZERO_TO_ONE // Since, in Vulkan, the depth range is 0 to 1 instead of -1 to 1 … … 14 19 #include <glm/gtc/matrix_transform.hpp> 15 20 16 #include <vulkan/vulkan.h>17 18 #include <SDL2/SDL.h>19 #include <SDL2/SDL_ttf.h>20 21 21 #include "IMGUI/imgui_impl_vulkan.h" 22 22 … … 26 26 27 27 #include "game-gui-sdl.hpp" 28 29 #include "gui/screen.hpp"30 28 31 29 using namespace glm; … … 196 194 }; 197 195 196 enum UIValueType { 197 UIVALUE_INT, 198 UIVALUE_DOUBLE, 199 }; 200 201 struct UIValue { 202 UIValueType type; 203 string label; 204 void* value; 205 206 UIValue(UIValueType _type, string _label, void* _value) : type(_type), label(_label), value(_value) {} 207 }; 208 198 209 class VulkanGame { 199 210 public: … … 203 214 void run(int width, int height, unsigned char guiFlags); 204 215 205 void goToScreen(Screen* screen);206 void quitGame();207 208 map<ScreenType, Screen*> screens;209 Screen* currentScreen;210 211 TTF_Font* lazyFont;212 TTF_Font* proggyFont;213 214 int score;215 float fps;216 217 GraphicsPipeline_Vulkan<OverlayVertex, void*> overlayPipeline;218 219 216 GraphicsPipeline_Vulkan<ModelVertex, SSBO_ModelObject> modelPipeline; 220 221 217 GraphicsPipeline_Vulkan<ShipVertex, SSBO_ModelObject> shipPipeline; 222 223 218 GraphicsPipeline_Vulkan<AsteroidVertex, SSBO_Asteroid> asteroidPipeline; 224 225 219 GraphicsPipeline_Vulkan<LaserVertex, SSBO_Laser> laserPipeline; 226 227 220 GraphicsPipeline_Vulkan<ExplosionVertex, SSBO_Explosion> explosionPipeline; 228 221 … … 250 243 SDL_version sdlVersion; 251 244 SDL_Window* window = nullptr; 252 SDL_Renderer* renderer = nullptr;253 254 SDL_Texture* uiOverlay = nullptr;255 245 256 246 VkInstance instance; … … 299 289 VkSampler textureSampler; 300 290 301 VulkanImage sdlOverlayImage;302 VkDescriptorImageInfo sdlOverlayImageDescriptor;303 304 291 VulkanImage floorTextureImage; 305 292 VkDescriptorImageInfo floorTextureImageDescriptor; … … 318 305 // if there is a need to add other uniform variables to one or more of the shaders 319 306 320 vector<SceneObject<OverlayVertex, void*>> overlayObjects;321 322 307 vector<SceneObject<ModelVertex, SSBO_ModelObject>> modelObjects; 323 308 … … 361 346 362 347 vector<BaseEffectOverTime*> effects; 348 349 float shipSpeed = 0.5f; 350 float asteroidSpeed = 2.0f; 351 352 float spawnRate_asteroid = 0.5; 353 float lastSpawn_asteroid; 354 355 unsigned int leftLaserIdx = -1; 356 EffectOverTime<AsteroidVertex, SSBO_Asteroid>* leftLaserEffect = nullptr; 357 358 unsigned int rightLaserIdx = -1; 359 EffectOverTime<AsteroidVertex, SSBO_Asteroid>* rightLaserEffect = nullptr; 360 361 /*** High-level vars ***/ 362 363 void (VulkanGame::* currentRenderScreenFn)(); 364 365 map<string, vector<UIValue>> valueLists; 366 367 int score; 368 float fps; 363 369 364 370 // TODO: Make a separate TImer class … … 369 375 int frameCount; 370 376 371 float shipSpeed = 0.5f; 372 float asteroidSpeed = 2.0f; 373 374 float spawnRate_asteroid = 0.5; 375 float lastSpawn_asteroid; 376 377 unsigned int leftLaserIdx = -1; 378 EffectOverTime<AsteroidVertex, SSBO_Asteroid>* leftLaserEffect = nullptr; 379 380 unsigned int rightLaserIdx = -1; 381 EffectOverTime<AsteroidVertex, SSBO_Asteroid>* rightLaserEffect = nullptr; 377 /*** Functions ***/ 382 378 383 379 bool initUI(int width, int height, unsigned char guiFlags); … … 385 381 void initGraphicsPipelines(); 386 382 void initMatrices(); 387 void mainLoop();383 void renderLoop(); 388 384 void updateScene(); 389 385 void cleanup(); … … 458 454 459 455 void cleanupSwapChain(); 456 457 /*** High-level functions ***/ 458 459 void renderMainScreen(); 460 void renderGameScreen(); 461 462 void initGuiValueLists(map<string, vector<UIValue>>& valueLists); 463 void renderGuiValueList(vector<UIValue>& values); 464 465 void goToScreen(void (VulkanGame::* renderScreenFn)()); 466 void quitGame(); 460 467 }; 461 468
Note:
See TracChangeset
for help on using the changeset viewer.