Changeset 40eb092 in opengl-game for sdl-game.hpp


Ignore:
Timestamp:
Mar 9, 2021, 2:47:00 AM (4 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
20e4c2b
Parents:
429ac01
Message:

In SDLGame, implement the game UI using ImGui

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sdl-game.hpp

    r429ac01 r40eb092  
    22#define _SDL_GAME_H
    33
     4#include <chrono>
     5#include <map>
    46#include <vector>
     7
    58#include <vulkan/vulkan.h>
    69
     
    1518
    1619using namespace std;
     20using namespace std::chrono;
    1721
    1822#define VulkanGame NewVulkanGame
     
    2327   const bool ENABLE_VALIDATION_LAYERS = true;
    2428#endif
     29
     30// TODO: Maybe move this to a different header
     31
     32enum UIValueType {
     33   UIVALUE_INT,
     34   UIVALUE_DOUBLE,
     35};
     36
     37struct 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};
    2544
    2645class VulkanGame {
     
    88107      bool shouldRecreateSwapChain;
    89108
    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
    92127      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();
    95131
    96132      void createVulkanInstance(const vector<const char*>& validationLayers);
     
    120156      void cleanupSwapChain();
    121157
     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
    122169      // Pipeline variables. Hopefully, I can eventually use the GraphicsPipeline_Vulkan class for the imgui pipeline
    123170      VkDescriptorPool descriptorPool;
    124 
    125171};
    126172
Note: See TracChangeset for help on using the changeset viewer.