From d130c2c7314cf4884f444db16d7717b7356b54ff Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Thu, 8 Feb 2024 07:58:22 -0800 Subject: Add window width and height to game. --- game/src/plugins/gltf_view.c | 16 +++++++++++++++- game/src/plugins/plugin.h | 2 +- game/src/plugins/texture_view.c | 3 --- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'game/src/plugins') diff --git a/game/src/plugins/gltf_view.c b/game/src/plugins/gltf_view.c index c19d1b8..4ffdd1e 100644 --- a/game/src/plugins/gltf_view.c +++ b/game/src/plugins/gltf_view.c @@ -169,7 +169,7 @@ static void render_bounding_boxes(ImmRenderer* imm, const SceneNode* node) { const SceneObject* obj = gfx_get_node_object(node); const aabb3 box = gfx_calc_object_aabb(obj); gfx_imm_set_model_matrix(imm, &model); - gfx_imm_draw_aabb(imm, box); + gfx_imm_draw_aabb3(imm, box); } // Render children's boxes. @@ -194,3 +194,17 @@ void render(const Game* game, const State* state) { render_bounding_boxes(imm, gfx_get_scene_root(state->scene)); gfx_imm_end(imm); } + +void resize(Game* game, State* state, int width, int height) { + assert(game); + assert(state); + + const R fovy = 90 * TO_RAD; + const R aspect = (R)width / (R)height; + const R near = 0.1; + const R far = 1000; + const mat4 projection = mat4_perspective(fovy, aspect, near, far); + + Camera* camera = gfx_get_camera_camera(state->camera); + camera->projection = projection; +} diff --git a/game/src/plugins/plugin.h b/game/src/plugins/plugin.h index a2632cd..f7219c6 100644 --- a/game/src/plugins/plugin.h +++ b/game/src/plugins/plugin.h @@ -41,7 +41,7 @@ void update(Game*, State*, double t, double dt); void render(const Game*, const State*); /// Called when the game's window is resized. -void resize(Game* game, State* state, int width, int height); +void resize(Game*, State*, int width, int height); // Signatures for the plugin's exposed functions. typedef bool (*plugin_init)(Game*, State**); diff --git a/game/src/plugins/texture_view.c b/game/src/plugins/texture_view.c index b424158..31bf23e 100644 --- a/game/src/plugins/texture_view.c +++ b/game/src/plugins/texture_view.c @@ -133,9 +133,6 @@ void resize(Game* game, State* state, int width, int height) { assert(game); assert(state); - RenderBackend* render_backend = gfx_get_render_backend(game->gfx); - gfx_set_viewport(render_backend, width, height); - const R fovy = 90 * TO_RAD; const R aspect = (R)width / (R)height; const R near = 0.1; -- cgit v1.2.3