feature/imgui-sdl
points-test
Last change
on this file since 83b5b4b 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
|
Rev | Line | |
---|
[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 |
|
---|
| 11 | using namespace std;
|
---|
| 12 |
|
---|
[f6521fb] | 13 | enum EventType {
|
---|
| 14 | UI_EVENT_QUIT,
|
---|
| 15 | UI_EVENT_WINDOW,
|
---|
[0e09340] | 16 | UI_EVENT_WINDOWRESIZE,
|
---|
[f6521fb] | 17 | UI_EVENT_KEY,
|
---|
| 18 | UI_EVENT_MOUSEBUTTONDOWN,
|
---|
| 19 | UI_EVENT_MOUSEBUTTONUP,
|
---|
[a0da009] | 20 | UI_EVENT_MOUSEMOTION,
|
---|
| 21 | UI_EVENT_UNKNOWN
|
---|
[f6521fb] | 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;
|
---|
[a0da009] | 35 | /*
|
---|
| 36 | int button;
|
---|
| 37 | int action;
|
---|
| 38 | int x;
|
---|
| 39 | int y;
|
---|
| 40 | */
|
---|
| 41 | };
|
---|
| 42 |
|
---|
[83b5b4b] | 43 | struct WindowResizeEvent {
|
---|
| 44 | EventType type;
|
---|
| 45 | int width;
|
---|
| 46 | int height;
|
---|
| 47 | };
|
---|
| 48 |
|
---|
[a0da009] | 49 | struct UnknownEvent {
|
---|
| 50 | EventType type;
|
---|
| 51 | unsigned int eventType;
|
---|
[f6521fb] | 52 | };
|
---|
| 53 |
|
---|
| 54 | union UIEvent {
|
---|
| 55 | EventType type;
|
---|
| 56 | WindowEvent window;
|
---|
| 57 | KeyEvent key;
|
---|
| 58 | MouseEvent mouse;
|
---|
[83b5b4b] | 59 | WindowResizeEvent windowResize;
|
---|
[a0da009] | 60 | UnknownEvent unknown;
|
---|
[f6521fb] | 61 | };
|
---|
| 62 |
|
---|
[f898c5f] | 63 | class GameGui {
|
---|
| 64 | public:
|
---|
[98f3232] | 65 | virtual ~GameGui() {};
|
---|
| 66 |
|
---|
[7fc5e27] | 67 | virtual string& getError() = 0;
|
---|
[d5f2b42] | 68 |
|
---|
[7fc5e27] | 69 | virtual bool init() = 0;
|
---|
| 70 | virtual void shutdown() = 0;
|
---|
[0e6ecf3] | 71 |
|
---|
[7fc5e27] | 72 | virtual void* createWindow(const string& title, int width, int height, bool fullscreen) = 0;
|
---|
| 73 | virtual void destroyWindow() = 0;
|
---|
[0e6ecf3] | 74 |
|
---|
[f6521fb] | 75 | virtual void processEvents() = 0;
|
---|
| 76 | virtual int pollEvent(UIEvent* event) = 0;
|
---|
| 77 |
|
---|
[a6f6833] | 78 | virtual void refreshWindowSize() = 0;
|
---|
| 79 | virtual int getWindowWidth() = 0;
|
---|
| 80 | virtual int getWindowHeight() = 0;
|
---|
[27c40ce] | 81 |
|
---|
[4eb4d0a] | 82 | #ifdef GAMEGUI_INCLUDE_VULKAN
|
---|
[7fc5e27] | 83 | virtual bool createVulkanSurface(VkInstance instance, VkSurfaceKHR* surface) = 0;
|
---|
| 84 | virtual vector<const char*> getRequiredExtensions() = 0;
|
---|
[a6f6833] | 85 | #endif
|
---|
[0e6ecf3] | 86 | };
|
---|
| 87 |
|
---|
[27c40ce] | 88 | #endif // _GAME_GUI_H
|
---|
Note:
See
TracBrowser
for help on using the repository browser.