diff options
Diffstat (limited to 'src/plugins/viewer.c')
-rw-r--r-- | src/plugins/viewer.c | 19 |
1 files changed, 11 insertions, 8 deletions
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); |