diff options
| author | 3gg <3gg@shellblade.net> | 2024-02-08 07:55:30 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2024-02-08 07:55:30 -0800 |
| commit | 32897d35fa724e46e4195927d385da4e35ac7c76 (patch) | |
| tree | 7d9c23aba558b5e703aa07aa55350d7d127ab148 /gfx-app/include | |
| parent | 3cd5b0bcca694630fcb4b977ddf7be7cd1bce153 (diff) | |
Add function to check for key press.
Diffstat (limited to 'gfx-app/include')
| -rw-r--r-- | gfx-app/include/gfx/gfx_app.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gfx-app/include/gfx/gfx_app.h b/gfx-app/include/gfx/gfx_app.h index 3c544fa..86c502a 100644 --- a/gfx-app/include/gfx/gfx_app.h +++ b/gfx-app/include/gfx/gfx_app.h | |||
| @@ -28,12 +28,44 @@ typedef struct GfxAppCallbacks { | |||
| 28 | GfxAppShutdown shutdown; | 28 | GfxAppShutdown shutdown; |
| 29 | } GfxAppCallbacks; | 29 | } GfxAppCallbacks; |
| 30 | 30 | ||
| 31 | typedef enum Key { | ||
| 32 | KeyA = 'a', | ||
| 33 | KeyB, | ||
| 34 | KeyC, | ||
| 35 | KeyD, | ||
| 36 | KeyE, | ||
| 37 | KeyF, | ||
| 38 | KeyG, | ||
| 39 | KeyH, | ||
| 40 | KeyI, | ||
| 41 | KeyJ, | ||
| 42 | KeyK, | ||
| 43 | KeyL, | ||
| 44 | KeyM, | ||
| 45 | KeyN, | ||
| 46 | KeyO, | ||
| 47 | KeyP, | ||
| 48 | KeyQ, | ||
| 49 | KeyR, | ||
| 50 | KeyS, | ||
| 51 | KeyT, | ||
| 52 | KeyU, | ||
| 53 | KeyV, | ||
| 54 | KeyW, | ||
| 55 | KeyX, | ||
| 56 | KeyY, | ||
| 57 | KeyZ, | ||
| 58 | } Key; | ||
| 59 | |||
| 31 | /// Create a window with an OpenGL context and run the main loop. | 60 | /// Create a window with an OpenGL context and run the main loop. |
| 32 | bool gfx_app_run(const GfxAppDesc*, const GfxAppCallbacks*); | 61 | bool gfx_app_run(const GfxAppDesc*, const GfxAppCallbacks*); |
| 33 | 62 | ||
| 34 | /// Get the mouse coordinates relative to the app's window. | 63 | /// Get the mouse coordinates relative to the app's window. |
| 35 | void gfx_app_get_mouse_position(double* x, double* y); | 64 | void gfx_app_get_mouse_position(double* x, double* y); |
| 36 | 65 | ||
| 66 | /// Return true if the given key is pressed. | ||
| 67 | bool gfx_is_key_pressed(Key); | ||
| 68 | |||
| 37 | /// Define a main function that initializes and puts the application in a loop. | 69 | /// Define a main function that initializes and puts the application in a loop. |
| 38 | /// See also: gfx_app_run(). | 70 | /// See also: gfx_app_run(). |
| 39 | #define GFX_APP_MAIN(WIDTH, HEIGHT, MAX_FPS) \ | 71 | #define GFX_APP_MAIN(WIDTH, HEIGHT, MAX_FPS) \ |
