diff options
| author | 3gg <3gg@shellblade.net> | 2024-02-08 07:58:22 -0800 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2024-02-08 07:58:22 -0800 |
| commit | d130c2c7314cf4884f444db16d7717b7356b54ff (patch) | |
| tree | 19080622054c32b5e09b5f455b4a8490e7ae6048 /game/src/plugins/gltf_view.c | |
| parent | dda4b3e598c7c955a44e3874bf2c57bd16b1c3ea (diff) | |
Add window width and height to game.
Diffstat (limited to 'game/src/plugins/gltf_view.c')
| -rw-r--r-- | game/src/plugins/gltf_view.c | 16 |
1 files changed, 15 insertions, 1 deletions
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) { | |||
| 169 | const SceneObject* obj = gfx_get_node_object(node); | 169 | const SceneObject* obj = gfx_get_node_object(node); |
| 170 | const aabb3 box = gfx_calc_object_aabb(obj); | 170 | const aabb3 box = gfx_calc_object_aabb(obj); |
| 171 | gfx_imm_set_model_matrix(imm, &model); | 171 | gfx_imm_set_model_matrix(imm, &model); |
| 172 | gfx_imm_draw_aabb(imm, box); | 172 | gfx_imm_draw_aabb3(imm, box); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | // Render children's boxes. | 175 | // Render children's boxes. |
| @@ -194,3 +194,17 @@ void render(const Game* game, const State* state) { | |||
| 194 | render_bounding_boxes(imm, gfx_get_scene_root(state->scene)); | 194 | render_bounding_boxes(imm, gfx_get_scene_root(state->scene)); |
| 195 | gfx_imm_end(imm); | 195 | gfx_imm_end(imm); |
| 196 | } | 196 | } |
| 197 | |||
| 198 | void resize(Game* game, State* state, int width, int height) { | ||
| 199 | assert(game); | ||
| 200 | assert(state); | ||
| 201 | |||
| 202 | const R fovy = 90 * TO_RAD; | ||
| 203 | const R aspect = (R)width / (R)height; | ||
| 204 | const R near = 0.1; | ||
| 205 | const R far = 1000; | ||
| 206 | const mat4 projection = mat4_perspective(fovy, aspect, near, far); | ||
| 207 | |||
| 208 | Camera* camera = gfx_get_camera_camera(state->camera); | ||
| 209 | camera->projection = projection; | ||
| 210 | } | ||
