diff options
Diffstat (limited to 'src/plugins')
| -rw-r--r-- | src/plugins/plugin.h | 17 | ||||
| -rw-r--r-- | src/plugins/viewer.c | 19 |
2 files changed, 17 insertions, 19 deletions
diff --git a/src/plugins/plugin.h b/src/plugins/plugin.h index f7219c6..2831045 100644 --- a/src/plugins/plugin.h +++ b/src/plugins/plugin.h | |||
| @@ -5,11 +5,6 @@ | |||
| 5 | 5 | ||
| 6 | #include "../game.h" | 6 | #include "../game.h" |
| 7 | 7 | ||
| 8 | #include <gfx/gfx.h> | ||
| 9 | #include <gfx/scene.h> | ||
| 10 | |||
| 11 | #include <stdbool.h> | ||
| 12 | |||
| 13 | typedef struct State State; | 8 | typedef struct State State; |
| 14 | 9 | ||
| 15 | /// Initialize the plugin, which may optionally return a state object. | 10 | /// Initialize the plugin, which may optionally return a state object. |
| @@ -44,9 +39,9 @@ void render(const Game*, const State*); | |||
| 44 | void resize(Game*, State*, int width, int height); | 39 | void resize(Game*, State*, int width, int height); |
| 45 | 40 | ||
| 46 | // Signatures for the plugin's exposed functions. | 41 | // Signatures for the plugin's exposed functions. |
| 47 | typedef bool (*plugin_init)(Game*, State**); | 42 | typedef bool (*PluginInit)(Game*, State**); |
| 48 | typedef bool (*plugin_shutdown)(Game*, State*); | 43 | typedef bool (*PluginShutdown)(Game*, State*); |
| 49 | typedef bool (*plugin_boot)(Game*, State*); | 44 | typedef bool (*PluginBoot)(Game*, State*); |
| 50 | typedef void (*plugin_update)(Game*, State*, double t, double dt); | 45 | typedef void (*PluginUpdate)(Game*, State*, double t, double dt); |
| 51 | typedef void (*plugin_render)(const Game*, const State*); | 46 | typedef void (*PluginRender)(const Game*, const State*); |
| 52 | typedef void (*plugin_resize)(Game* game, State* state, int width, int height); | 47 | typedef void (*PluginResize)(Game* game, State* state, int width, int height); |
diff --git a/src/plugins/viewer.c b/src/plugins/viewer.c index 97c718e..83c7320 100644 --- a/src/plugins/viewer.c +++ b/src/plugins/viewer.c | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | #include <gfx/app.h> | 3 | #include <gfx/app.h> |
| 4 | #include <gfx/asset.h> | 4 | #include <gfx/asset.h> |
| 5 | #include <gfx/gfx.h> | ||
| 5 | #include <gfx/llr/llr.h> | 6 | #include <gfx/llr/llr.h> |
| 6 | #include <gfx/renderer.h> | 7 | #include <gfx/renderer.h> |
| 7 | #include <gfx/renderer/imm_renderer.h> | 8 | #include <gfx/renderer/imm_renderer.h> |
| @@ -204,13 +205,13 @@ void shutdown(Game* game, State* state) { | |||
| 204 | } | 205 | } |
| 205 | } | 206 | } |
| 206 | 207 | ||
| 207 | static CameraCommand make_camera_command_from_input() { | 208 | static CameraCommand make_camera_command_from_input(GfxApp* app) { |
| 208 | return (CameraCommand){ | 209 | return (CameraCommand){ |
| 209 | .CameraMoveLeft = gfx_app_is_key_pressed(KeyA), | 210 | .CameraMoveLeft = gfx_app_is_key_pressed(app, KeyA), |
| 210 | .CameraMoveRight = gfx_app_is_key_pressed(KeyD), | 211 | .CameraMoveRight = gfx_app_is_key_pressed(app, KeyD), |
| 211 | .CameraMoveForward = gfx_app_is_key_pressed(KeyW), | 212 | .CameraMoveForward = gfx_app_is_key_pressed(app, KeyW), |
| 212 | .CameraMoveBackward = gfx_app_is_key_pressed(KeyS), | 213 | .CameraMoveBackward = gfx_app_is_key_pressed(app, KeyS), |
| 213 | .CameraIsRotating = gfx_app_is_mouse_button_pressed(LMB), | 214 | .CameraIsRotating = gfx_app_is_mouse_button_pressed(app, LMB), |
| 214 | }; | 215 | }; |
| 215 | } | 216 | } |
| 216 | 217 | ||
| @@ -248,15 +249,17 @@ static void update_camera( | |||
| 248 | 249 | ||
| 249 | void update(Game* game, State* state, double t, double dt) { | 250 | void update(Game* game, State* state, double t, double dt) { |
| 250 | assert(game); | 251 | assert(game); |
| 252 | assert(game->app); | ||
| 251 | assert(state); | 253 | assert(state); |
| 252 | assert(state->scene); | 254 | assert(state->scene); |
| 253 | assert(state->camera); | 255 | assert(state->camera); |
| 254 | 256 | ||
| 255 | double mouse_x, mouse_y; | 257 | double mouse_x, mouse_y; |
| 256 | gfx_app_get_mouse_position(&mouse_x, &mouse_y); | 258 | gfx_app_get_mouse_position(game->app, &mouse_x, &mouse_y); |
| 257 | const vec2 mouse_position = {(R)mouse_x, (R)mouse_y}; | 259 | const vec2 mouse_position = {(R)mouse_x, (R)mouse_y}; |
| 258 | 260 | ||
| 259 | const CameraCommand camera_command = make_camera_command_from_input(); | 261 | const CameraCommand camera_command = |
| 262 | make_camera_command_from_input(game->app); | ||
| 260 | update_camera( | 263 | update_camera( |
| 261 | &state->camera_controller, (R)dt, mouse_position, camera_command, | 264 | &state->camera_controller, (R)dt, mouse_position, camera_command, |
| 262 | &gfx_get_camera_camera(state->camera)->spatial); | 265 | &gfx_get_camera_camera(state->camera)->spatial); |
