source: opengl-game/game-gui.hpp@ e1f88a9

feature/imgui-sdl
Last change on this file since e1f88a9 was e1f88a9, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 4 years ago

Create a system to draw and switch between different screens, a Screen class, a MainScreen class that extends it, and some classes for UI elements that can be added to screens.

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[0e6ecf3]1#ifndef _GAME_GUI_H
2#define _GAME_GUI_H
3
[9546928]4#include <string>
5#include <vector>
6
[4eb4d0a]7#ifdef GAMEGUI_INCLUDE_VULKAN
8 #include <vulkan/vulkan.h>
9#endif
[0e6ecf3]10
11using namespace std;
12
[e1f88a9]13// TODO: See if it makes sense to combine this with the files in the gui folder
14
[f6521fb]15enum EventType {
16 UI_EVENT_QUIT,
17 UI_EVENT_WINDOW,
[0e09340]18 UI_EVENT_WINDOWRESIZE,
[5a23277]19 UI_EVENT_KEYDOWN,
20 UI_EVENT_KEYUP,
[f6521fb]21 UI_EVENT_MOUSEBUTTONDOWN,
22 UI_EVENT_MOUSEBUTTONUP,
[a0da009]23 UI_EVENT_MOUSEMOTION,
24 UI_EVENT_UNKNOWN
[f6521fb]25};
26
27struct WindowEvent {
28 EventType type;
29};
30
31struct KeyEvent {
32 EventType type;
33 unsigned int keycode;
[0ecab17]34 bool repeat;
[f6521fb]35};
36
37struct MouseEvent {
38 EventType type;
[b8d4456]39 int x;
40 int y;
[a0da009]41 /*
42 int button;
43 int action;
44 */
45};
46
[83b5b4b]47struct WindowResizeEvent {
48 EventType type;
49 int width;
50 int height;
51};
52
[a0da009]53struct UnknownEvent {
54 EventType type;
55 unsigned int eventType;
[f6521fb]56};
57
[e1f88a9]58// TODO: Switch from union to std::variant
59
[f6521fb]60union UIEvent {
61 EventType type;
62 WindowEvent window;
63 KeyEvent key;
64 MouseEvent mouse;
[83b5b4b]65 WindowResizeEvent windowResize;
[a0da009]66 UnknownEvent unknown;
[f6521fb]67};
68
[f898c5f]69class GameGui {
70 public:
[98f3232]71 virtual ~GameGui() {};
72
[7fc5e27]73 virtual string& getError() = 0;
[d5f2b42]74
[7fc5e27]75 virtual bool init() = 0;
76 virtual void shutdown() = 0;
[0e6ecf3]77
[7fc5e27]78 virtual void* createWindow(const string& title, int width, int height, bool fullscreen) = 0;
79 virtual void destroyWindow() = 0;
[0e6ecf3]80
[f6521fb]81 virtual void processEvents() = 0;
82 virtual int pollEvent(UIEvent* event) = 0;
[cd1cb0f]83 virtual bool keyPressed(unsigned int key) = 0;
[f6521fb]84
[a6f6833]85 virtual void refreshWindowSize() = 0;
86 virtual int getWindowWidth() = 0;
87 virtual int getWindowHeight() = 0;
[27c40ce]88
[4eb4d0a]89#ifdef GAMEGUI_INCLUDE_VULKAN
[7fc5e27]90 virtual bool createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) = 0;
91 virtual vector<const char*> getRequiredExtensions() = 0;
[a6f6833]92#endif
[0e6ecf3]93};
94
[27c40ce]95#endif // _GAME_GUI_H
Note: See TracBrowser for help on using the repository browser.