feature/imgui-sdl
points-test
Last change
on this file since 0b1b52d was 83b5b4b, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 5 years ago |
Handle window resize events in openglgame
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | #ifndef _GAME_GUI_H
|
---|
2 | #define _GAME_GUI_H
|
---|
3 |
|
---|
4 | #include <string>
|
---|
5 | #include <vector>
|
---|
6 |
|
---|
7 | #ifdef GAMEGUI_INCLUDE_VULKAN
|
---|
8 | #include <vulkan/vulkan.h>
|
---|
9 | #endif
|
---|
10 |
|
---|
11 | using namespace std;
|
---|
12 |
|
---|
13 | enum EventType {
|
---|
14 | UI_EVENT_QUIT,
|
---|
15 | UI_EVENT_WINDOW,
|
---|
16 | UI_EVENT_WINDOWRESIZE,
|
---|
17 | UI_EVENT_KEY,
|
---|
18 | UI_EVENT_MOUSEBUTTONDOWN,
|
---|
19 | UI_EVENT_MOUSEBUTTONUP,
|
---|
20 | UI_EVENT_MOUSEMOTION,
|
---|
21 | UI_EVENT_UNKNOWN
|
---|
22 | };
|
---|
23 |
|
---|
24 | struct WindowEvent {
|
---|
25 | EventType type;
|
---|
26 | };
|
---|
27 |
|
---|
28 | struct KeyEvent {
|
---|
29 | EventType type;
|
---|
30 | unsigned int keycode;
|
---|
31 | };
|
---|
32 |
|
---|
33 | struct MouseEvent {
|
---|
34 | EventType type;
|
---|
35 | /*
|
---|
36 | int button;
|
---|
37 | int action;
|
---|
38 | int x;
|
---|
39 | int y;
|
---|
40 | */
|
---|
41 | };
|
---|
42 |
|
---|
43 | struct WindowResizeEvent {
|
---|
44 | EventType type;
|
---|
45 | int width;
|
---|
46 | int height;
|
---|
47 | };
|
---|
48 |
|
---|
49 | struct UnknownEvent {
|
---|
50 | EventType type;
|
---|
51 | unsigned int eventType;
|
---|
52 | };
|
---|
53 |
|
---|
54 | union UIEvent {
|
---|
55 | EventType type;
|
---|
56 | WindowEvent window;
|
---|
57 | KeyEvent key;
|
---|
58 | MouseEvent mouse;
|
---|
59 | WindowResizeEvent windowResize;
|
---|
60 | UnknownEvent unknown;
|
---|
61 | };
|
---|
62 |
|
---|
63 | class GameGui {
|
---|
64 | public:
|
---|
65 | virtual ~GameGui() {};
|
---|
66 |
|
---|
67 | virtual string& getError() = 0;
|
---|
68 |
|
---|
69 | virtual bool init() = 0;
|
---|
70 | virtual void shutdown() = 0;
|
---|
71 |
|
---|
72 | virtual void* createWindow(const string& title, int width, int height, bool fullscreen) = 0;
|
---|
73 | virtual void destroyWindow() = 0;
|
---|
74 |
|
---|
75 | virtual void processEvents() = 0;
|
---|
76 | virtual int pollEvent(UIEvent* event) = 0;
|
---|
77 |
|
---|
78 | virtual void refreshWindowSize() = 0;
|
---|
79 | virtual int getWindowWidth() = 0;
|
---|
80 | virtual int getWindowHeight() = 0;
|
---|
81 |
|
---|
82 | #ifdef GAMEGUI_INCLUDE_VULKAN
|
---|
83 | virtual bool createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) = 0;
|
---|
84 | virtual vector<const char*> getRequiredExtensions() = 0;
|
---|
85 | #endif
|
---|
86 | };
|
---|
87 |
|
---|
88 | #endif // _GAME_GUI_H
|
---|
Note:
See
TracBrowser
for help on using the repository browser.