summaryrefslogtreecommitdiff
path: root/game/src/plugins
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2024-02-08 07:58:22 -0800
committer3gg <3gg@shellblade.net>2024-02-08 07:58:22 -0800
commitd130c2c7314cf4884f444db16d7717b7356b54ff (patch)
tree19080622054c32b5e09b5f455b4a8490e7ae6048 /game/src/plugins
parentdda4b3e598c7c955a44e3874bf2c57bd16b1c3ea (diff)
Add window width and height to game.
Diffstat (limited to 'game/src/plugins')
-rw-r--r--game/src/plugins/gltf_view.c16
-rw-r--r--game/src/plugins/plugin.h2
-rw-r--r--game/src/plugins/texture_view.c3
3 files changed, 16 insertions, 5 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
198void 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}
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);
41void render(const Game*, const State*); 41void render(const Game*, const State*);
42 42
43/// Called when the game's window is resized. 43/// Called when the game's window is resized.
44void resize(Game* game, State* state, int width, int height); 44void resize(Game*, State*, int width, int height);
45 45
46// Signatures for the plugin's exposed functions. 46// Signatures for the plugin's exposed functions.
47typedef bool (*plugin_init)(Game*, State**); 47typedef 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) {
133 assert(game); 133 assert(game);
134 assert(state); 134 assert(state);
135 135
136 RenderBackend* render_backend = gfx_get_render_backend(game->gfx);
137 gfx_set_viewport(render_backend, width, height);
138
139 const R fovy = 90 * TO_RAD; 136 const R fovy = 90 * TO_RAD;
140 const R aspect = (R)width / (R)height; 137 const R aspect = (R)width / (R)height;
141 const R near = 0.1; 138 const R near = 0.1;