summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2024-02-08 19:46:24 -0800
committer3gg <3gg@shellblade.net>2024-02-08 19:46:24 -0800
commitb116ac146cd1c802b4c87c980971dc20cb65a881 (patch)
treeca9d7cdf9c74a6b7d2a056a80ff78134082ea575
parent1e75db817c3bef320b57e3c8ef608715f36550a7 (diff)
Add missing render call back.
-rw-r--r--game/src/plugins/gltf_view.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/game/src/plugins/gltf_view.c b/game/src/plugins/gltf_view.c
index 7c73844..83fc8ed 100644
--- a/game/src/plugins/gltf_view.c
+++ b/game/src/plugins/gltf_view.c
@@ -160,7 +160,9 @@ void update(Game* game, State* state, double t, double dt) {
160} 160}
161 161
162/// Render the bounding boxes of all scene objects. 162/// Render the bounding boxes of all scene objects.
163static void render_bounding_boxes(ImmRenderer* imm, const SceneNode* node) { 163static void render_bounding_boxes_rec(ImmRenderer* imm, const SceneNode* node) {
164 assert(imm);
165 assert(node);
164 if (gfx_get_node_type(node) == ObjectNode) { 166 if (gfx_get_node_type(node) == ObjectNode) {
165 // TODO: Look at the scene log. The JointNodes are detached from the 167 // TODO: Look at the scene log. The JointNodes are detached from the
166 // ObjectNodes. This is why the boxes are not being transformed as expected 168 // ObjectNodes. This is why the boxes are not being transformed as expected
@@ -175,16 +177,14 @@ static void render_bounding_boxes(ImmRenderer* imm, const SceneNode* node) {
175 // Render children's boxes. 177 // Render children's boxes.
176 for (NodeIter it = gfx_get_node_child(node); it; 178 for (NodeIter it = gfx_get_node_child(node); it;
177 it = gfx_get_next_child(it)) { 179 it = gfx_get_next_child(it)) {
178 render_bounding_boxes(imm, gfx_get_iter_node(it)); 180 render_bounding_boxes_rec(imm, gfx_get_iter_node(it));
179 } 181 }
180} 182}
181 183
182void render(const Game* game, const State* state) { 184/// Render the bounding boxes of all scene objects.
183 assert(state); 185static void render_bounding_boxes(const Game* game, const State* state) {
184 assert(game); 186 assert(game);
185 assert(game->gfx); 187 assert(state);
186 assert(state->scene);
187 assert(state->camera);
188 188
189 RenderBackend* render_backend = gfx_get_render_backend(game->gfx); 189 RenderBackend* render_backend = gfx_get_render_backend(game->gfx);
190 ImmRenderer* imm = gfx_get_imm_renderer(game->gfx); 190 ImmRenderer* imm = gfx_get_imm_renderer(game->gfx);
@@ -198,7 +198,7 @@ void render(const Game* game, const State* state) {
198 gfx_imm_start(imm); 198 gfx_imm_start(imm);
199 gfx_imm_set_camera(imm, gfx_get_camera_camera(state->camera)); 199 gfx_imm_set_camera(imm, gfx_get_camera_camera(state->camera));
200 gfx_imm_set_colour(imm, vec4_make(0.2, 0.2, 1.0, 0.3)); 200 gfx_imm_set_colour(imm, vec4_make(0.2, 0.2, 1.0, 0.3));
201 render_bounding_boxes(imm, gfx_get_scene_root(state->scene)); 201 render_bounding_boxes_rec(imm, gfx_get_scene_root(state->scene));
202 gfx_imm_end(imm); 202 gfx_imm_end(imm);
203 203
204 gfx_set_polygon_offset(render_backend, 0.0f, 0.0f); 204 gfx_set_polygon_offset(render_backend, 0.0f, 0.0f);
@@ -206,6 +206,25 @@ void render(const Game* game, const State* state) {
206 gfx_set_blending(render_backend, false); 206 gfx_set_blending(render_backend, false);
207} 207}
208 208
209void render(const Game* game, const State* state) {
210 assert(state);
211 assert(game);
212 assert(game->gfx);
213 assert(state->scene);
214 assert(state->camera);
215
216 Renderer* renderer = gfx_get_renderer(game->gfx);
217 assert(renderer);
218
219 gfx_render_scene(
220 renderer, &(RenderSceneParams){
221 .mode = RenderDefault,
222 .scene = state->scene,
223 .camera = state->camera});
224
225 render_bounding_boxes(game, state);
226}
227
209void resize(Game* game, State* state, int width, int height) { 228void resize(Game* game, State* state, int width, int height) {
210 assert(game); 229 assert(game);
211 assert(state); 230 assert(state);