forked from AllenDang/cimgui-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glfw_backend.h
207 lines (196 loc) · 6.92 KB
/
glfw_backend.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#pragma once
#include "cimgui_wrapper.h"
#include "thirdparty/glfw/include/GLFW/glfw3.h" // Will drag system OpenGL headers
#include "extra_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef int GLFWKey;
enum GLFWKey_ {
GLFWKeySpace = GLFW_KEY_SPACE,
GLFWKeyApostrophe = GLFW_KEY_APOSTROPHE,
GLFWKeyComma = GLFW_KEY_COMMA,
GLFWKeyMinus = GLFW_KEY_MINUS,
GLFWKeyPeriod = GLFW_KEY_PERIOD,
GLFWKeySlash = GLFW_KEY_SLASH,
GLFWKey0 = GLFW_KEY_0,
GLFWKey1 = GLFW_KEY_1,
GLFWKey2 = GLFW_KEY_2,
GLFWKey3 = GLFW_KEY_3,
GLFWKey4 = GLFW_KEY_4,
GLFWKey5 = GLFW_KEY_5,
GLFWKey6 = GLFW_KEY_6,
GLFWKey7 = GLFW_KEY_7,
GLFWKey8 = GLFW_KEY_8,
GLFWKey9 = GLFW_KEY_9,
GLFWKeySemicolon = GLFW_KEY_SEMICOLON,
GLFWKeyEqual = GLFW_KEY_EQUAL,
GLFWKeyA = GLFW_KEY_A,
GLFWKeyB = GLFW_KEY_B,
GLFWKeyC = GLFW_KEY_C,
GLFWKeyD = GLFW_KEY_D,
GLFWKeyE = GLFW_KEY_E,
GLFWKeyF = GLFW_KEY_F,
GLFWKeyG = GLFW_KEY_G,
GLFWKeyH = GLFW_KEY_H,
GLFWKeyI = GLFW_KEY_I,
GLFWKeyJ = GLFW_KEY_J,
GLFWKeyK = GLFW_KEY_K,
GLFWKeyL = GLFW_KEY_L,
GLFWKeyM = GLFW_KEY_M,
GLFWKeyN = GLFW_KEY_N,
GLFWKeyO = GLFW_KEY_O,
GLFWKeyP = GLFW_KEY_P,
GLFWKeyQ = GLFW_KEY_Q,
GLFWKeyR = GLFW_KEY_R,
GLFWKeyS = GLFW_KEY_S,
GLFWKeyT = GLFW_KEY_T,
GLFWKeyU = GLFW_KEY_U,
GLFWKeyV = GLFW_KEY_V,
GLFWKeyW = GLFW_KEY_W,
GLFWKeyX = GLFW_KEY_X,
GLFWKeyY = GLFW_KEY_Y,
GLFWKeyZ = GLFW_KEY_Z,
GLFWKeyLeftBracket = GLFW_KEY_LEFT_BRACKET,
GLFWKeyBackslash = GLFW_KEY_BACKSLASH,
GLFWKeyRightBracket = GLFW_KEY_RIGHT_BRACKET,
GLFWKeyGraveAccent = GLFW_KEY_GRAVE_ACCENT,
GLFWKeyWorld1 = GLFW_KEY_WORLD_1,
GLFWKeyWorld2 = GLFW_KEY_WORLD_2,
/* Function keys */
GLFWKeyEscape = GLFW_KEY_ESCAPE,
GLFWKeyEnter = GLFW_KEY_ENTER,
GLFWKeyTab = GLFW_KEY_TAB,
GLFWKeyBackspace = GLFW_KEY_BACKSPACE,
GLFWKeyInsert = GLFW_KEY_INSERT,
GLFWKeyDelete = GLFW_KEY_DELETE,
GLFWKeyRight = GLFW_KEY_RIGHT,
GLFWKeyLeft = GLFW_KEY_LEFT,
GLFWKeyDown = GLFW_KEY_DOWN,
GLFWKeyUp = GLFW_KEY_UP,
GLFWKeyPageUp = GLFW_KEY_PAGE_UP,
GLFWKeyPageDown = GLFW_KEY_PAGE_DOWN,
GLFWKeyHome = GLFW_KEY_HOME,
GLFWKeyEnd = GLFW_KEY_END,
GLFWKeyCapsLock = GLFW_KEY_CAPS_LOCK,
GLFWKeyScrollLock = GLFW_KEY_SCROLL_LOCK,
GLFWKeyNumLock = GLFW_KEY_NUM_LOCK,
GLFWKeyPrintScreen = GLFW_KEY_PRINT_SCREEN,
GLFWKeyPause = GLFW_KEY_PAUSE,
GLFWKeyF1 = GLFW_KEY_F1,
GLFWKeyF2 = GLFW_KEY_F2,
GLFWKeyF3 = GLFW_KEY_F3,
GLFWKeyF4 = GLFW_KEY_F4,
GLFWKeyF5 = GLFW_KEY_F5,
GLFWKeyF6 = GLFW_KEY_F6,
GLFWKeyF7 = GLFW_KEY_F7,
GLFWKeyF8 = GLFW_KEY_F8,
GLFWKeyF9 = GLFW_KEY_F9,
GLFWKeyF10 = GLFW_KEY_F10,
GLFWKeyF11 = GLFW_KEY_F11,
GLFWKeyF12 = GLFW_KEY_F12,
GLFWKeyF13 = GLFW_KEY_F13,
GLFWKeyF14 = GLFW_KEY_F14,
GLFWKeyF15 = GLFW_KEY_F15,
GLFWKeyF16 = GLFW_KEY_F16,
GLFWKeyF17 = GLFW_KEY_F17,
GLFWKeyF18 = GLFW_KEY_F18,
GLFWKeyF19 = GLFW_KEY_F19,
GLFWKeyF20 = GLFW_KEY_F20,
GLFWKeyF21 = GLFW_KEY_F21,
GLFWKeyF22 = GLFW_KEY_F22,
GLFWKeyF23 = GLFW_KEY_F23,
GLFWKeyF24 = GLFW_KEY_F24,
GLFWKeyF25 = GLFW_KEY_F25,
GLFWKeyKp0 = GLFW_KEY_KP_0,
GLFWKeyKp1 = GLFW_KEY_KP_1,
GLFWKeyKp2 = GLFW_KEY_KP_2,
GLFWKeyKp3 = GLFW_KEY_KP_3,
GLFWKeyKp4 = GLFW_KEY_KP_4,
GLFWKeyKp5 = GLFW_KEY_KP_5,
GLFWKeyKp6 = GLFW_KEY_KP_6,
GLFWKeyKp7 = GLFW_KEY_KP_7,
GLFWKeyKp8 = GLFW_KEY_KP_8,
GLFWKeyKp9 = GLFW_KEY_KP_9,
GLFWKeyKpDecimal = GLFW_KEY_KP_DECIMAL,
GLFWKeyKpDivide = GLFW_KEY_KP_DIVIDE,
GLFWKeyKpMultiply = GLFW_KEY_KP_MULTIPLY,
GLFWKeyKpSubtract = GLFW_KEY_KP_SUBTRACT,
GLFWKeyKpAdd = GLFW_KEY_KP_ADD,
GLFWKeyKpEnter = GLFW_KEY_KP_ENTER,
GLFWKeyKpEqual = GLFW_KEY_KP_EQUAL,
GLFWKeyLeftShift = GLFW_KEY_LEFT_SHIFT,
GLFWKeyLeftControl = GLFW_KEY_LEFT_CONTROL,
GLFWKeyLeftAlt = GLFW_KEY_LEFT_ALT,
GLFWKeyLeftSuper = GLFW_KEY_LEFT_SUPER,
GLFWKeyRightShift = GLFW_KEY_RIGHT_SHIFT,
GLFWKeyRightControl = GLFW_KEY_RIGHT_CONTROL,
GLFWKeyRightAlt = GLFW_KEY_RIGHT_ALT,
GLFWKeyRightSuper = GLFW_KEY_RIGHT_SUPER,
GLFWKeyMenu = GLFW_KEY_MENU,
};
typedef int GLFWModifierKey;
enum GLFWModifierKey_ {
GLFWModShift = GLFW_MOD_SHIFT,
GLFWModControl = GLFW_MOD_CONTROL,
GLFWModAlt = GLFW_MOD_ALT,
GLFWModSuper = GLFW_MOD_SUPER,
GLFWModCapsLock = GLFW_MOD_CAPS_LOCK,
GLFWModNumLock = GLFW_MOD_NUM_LOCK,
};
typedef int GLFWWindowFlags;
enum GLFWWindowFlags_ {
GLFWWindowNone = 0,
GLFWWindowResizable = GLFW_RESIZABLE,
GLFWWindowMaximized = GLFW_MAXIMIZED,
GLFWWindowTransparentFramebuffer = GLFW_TRANSPARENT_FRAMEBUFFER,
GLFWWindowDecorated= GLFW_DECORATED,
GLFWWindowVisible = GLFW_VISIBLE,
GLFWWindowFloating = GLFW_FLOATING,
GLFWWindowFocused = GLFW_FOCUSED,
GLFWWindowIconified = GLFW_ICONIFIED,
GLFWWindowAutoIconify = GLFW_AUTO_ICONIFY,
};
typedef struct CImage {
int width;
int height;
unsigned char* pixels;
}CImage ;
typedef struct GLFWwindow GLFWwindow;
typedef struct GLFWmonitor GLFWmonitor;
typedef struct GLFWimage GLFWimage;
struct GLFWwindow;
struct GLFWmonitor;
struct GLFWimage;
extern void igSetBgColor(ImVec4 color);
extern void igSetTargetFPS(unsigned int fps);
extern int igInitGLFW();
extern GLFWwindow *igCreateGLFWWindow(const char *title, int width, int height,
VoidCallback afterCreateContext);
extern void igGLFWRunLoop(GLFWwindow *window, VoidCallback loop, VoidCallback beforeRender, VoidCallback afterRender,
VoidCallback beforeDestroyContext);
extern void igGLFWWindow_GetDisplaySize(GLFWwindow *window, int *width, int *height);
extern void igGLFWWindow_GetContentScale(GLFWwindow *window, float *width, float *height);
extern void igGLFWWindow_SetWindowPos(GLFWwindow *window, int x, int y);
extern void igGLFWWindow_GetWindowPos(GLFWwindow *window, int *x, int *y);
extern void igGLFWWindow_SetShouldClose(GLFWwindow *window, int value);
extern void igGLFWWindow_SetDropCallbackCB(GLFWwindow *window);
extern void igGLFWWindow_SetSize(GLFWwindow *window, int width, int height);
extern void igGLFWWindow_SetTitle(GLFWwindow *window, const char *title);
extern void igGLFWWindow_SetSizeLimits(GLFWwindow *window, int minWidth, int minHeight, int maxWidth, int maxHeight);
extern void igGLFWWindow_SetCloseCallback(GLFWwindow *window);
extern void igGLFWWindow_SetKeyCallback(GLFWwindow *window);
extern void igGLFWWindow_SetSizeCallback(GLFWwindow *window);
extern void igGLFWWindow_SetIcon(GLFWwindow *window, int count, CImage* images);
extern void igRefresh();
extern ImTextureID igCreateTexture(unsigned char *pixels, int width, int height);
extern void igDeleteTexture(ImTextureID id);
extern void igWindowHint(GLFWWindowFlags hint, int value);
extern void iggImplGlfw_KeyCallback(GLFWwindow* w, int k,int s,int a,int m);
extern void dropCallback(int, char **);
extern void closeCallback(GLFWwindow *window);
extern void keyCallback(int key, int scancode, int action, int mods);
extern void sizeCallback(int width, int height);
#ifdef __cplusplus
}
#endif