diff options
Diffstat (limited to 'app/include')
-rw-r--r-- | app/include/gfx/app.h | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/app/include/gfx/app.h b/app/include/gfx/app.h index 77b6ad2..639fa2d 100644 --- a/app/include/gfx/app.h +++ b/app/include/gfx/app.h | |||
@@ -1,7 +1,6 @@ | |||
1 | #pragma once | 1 | #pragma once |
2 | 2 | ||
3 | #include <stdbool.h> | 3 | typedef struct GfxApp GfxApp; |
4 | |||
5 | typedef struct GfxAppState GfxAppState; | 4 | typedef struct GfxAppState GfxAppState; |
6 | 5 | ||
7 | /// Application settings. | 6 | /// Application settings. |
@@ -16,11 +15,11 @@ typedef struct GfxAppDesc { | |||
16 | GfxAppState* app_state; | 15 | GfxAppState* app_state; |
17 | } GfxAppDesc; | 16 | } GfxAppDesc; |
18 | 17 | ||
19 | typedef bool (*GfxAppInit)(GfxAppState*, int argc, const char** argv); | 18 | typedef bool (*GfxAppInit)(GfxApp*, GfxAppState*, int argc, const char** argv); |
20 | typedef void (*GfxAppShutdown)(GfxAppState*); | 19 | typedef void (*GfxAppShutdown)(GfxApp*, GfxAppState*); |
21 | typedef void (*GfxAppUpdate)(GfxAppState*, double t, double dt); | 20 | typedef void (*GfxAppUpdate)(GfxApp*, GfxAppState*, double t, double dt); |
22 | typedef void (*GfxAppRender)(GfxAppState*); | 21 | typedef void (*GfxAppRender)(const GfxApp*, GfxAppState*); |
23 | typedef void (*GfxAppResize)(GfxAppState*, int width, int height); | 22 | typedef void (*GfxAppResize)(GfxApp*, GfxAppState*, int width, int height); |
24 | 23 | ||
25 | /// Application callback functions. | 24 | /// Application callback functions. |
26 | typedef struct GfxAppCallbacks { | 25 | typedef struct GfxAppCallbacks { |
@@ -74,13 +73,13 @@ extern "C" { | |||
74 | bool gfx_app_run(const GfxAppDesc*, const GfxAppCallbacks*); | 73 | bool gfx_app_run(const GfxAppDesc*, const GfxAppCallbacks*); |
75 | 74 | ||
76 | /// Get the mouse coordinates relative to the app's window. | 75 | /// Get the mouse coordinates relative to the app's window. |
77 | void gfx_app_get_mouse_position(double* x, double* y); | 76 | void gfx_app_get_mouse_position(GfxApp*, double* x, double* y); |
78 | 77 | ||
79 | /// Return if the given mouse button is pressed. | 78 | /// Return if the given mouse button is pressed. |
80 | bool gfx_app_is_mouse_button_pressed(MouseButton); | 79 | bool gfx_app_is_mouse_button_pressed(GfxApp*, MouseButton); |
81 | 80 | ||
82 | /// Return true if the given key is pressed. | 81 | /// Return true if the given key is pressed. |
83 | bool gfx_app_is_key_pressed(Key); | 82 | bool gfx_app_is_key_pressed(GfxApp*, Key); |
84 | 83 | ||
85 | #ifdef __cplusplus | 84 | #ifdef __cplusplus |
86 | } // extern "C" | 85 | } // extern "C" |
@@ -102,11 +101,10 @@ bool gfx_app_is_key_pressed(Key); | |||
102 | .title = TITLE, \ | 101 | .title = TITLE, \ |
103 | .app_state = &app_state, \ | 102 | .app_state = &app_state, \ |
104 | }, \ | 103 | }, \ |
105 | &(GfxAppCallbacks){ \ | 104 | &(GfxAppCallbacks){.init = Init, \ |
106 | .init = (GfxAppInit)Init, \ | 105 | .shutdown = Shutdown, \ |
107 | .shutdown = (GfxAppShutdown)Shutdown, \ | 106 | .update = Update, \ |
108 | .update = (GfxAppUpdate)Update, \ | 107 | .render = Render, \ |
109 | .render = (GfxAppRender)Render, \ | 108 | .resize = Resize}); \ |
110 | .resize = (GfxAppResize)Resize}); \ | ||
111 | return 0; \ | 109 | return 0; \ |
112 | } | 110 | } |