From b116ac146cd1c802b4c87c980971dc20cb65a881 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Thu, 8 Feb 2024 19:46:24 -0800 Subject: Add missing render call back. --- game/src/plugins/gltf_view.c | 35 +++++++++++++++++++++++++++-------- 1 file 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) { } /// Render the bounding boxes of all scene objects. -static void render_bounding_boxes(ImmRenderer* imm, const SceneNode* node) { +static void render_bounding_boxes_rec(ImmRenderer* imm, const SceneNode* node) { + assert(imm); + assert(node); if (gfx_get_node_type(node) == ObjectNode) { // TODO: Look at the scene log. The JointNodes are detached from the // 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) { // Render children's boxes. for (NodeIter it = gfx_get_node_child(node); it; it = gfx_get_next_child(it)) { - render_bounding_boxes(imm, gfx_get_iter_node(it)); + render_bounding_boxes_rec(imm, gfx_get_iter_node(it)); } } -void render(const Game* game, const State* state) { - assert(state); +/// Render the bounding boxes of all scene objects. +static void render_bounding_boxes(const Game* game, const State* state) { assert(game); - assert(game->gfx); - assert(state->scene); - assert(state->camera); + assert(state); RenderBackend* render_backend = gfx_get_render_backend(game->gfx); ImmRenderer* imm = gfx_get_imm_renderer(game->gfx); @@ -198,7 +198,7 @@ void render(const Game* game, const State* state) { gfx_imm_start(imm); gfx_imm_set_camera(imm, gfx_get_camera_camera(state->camera)); gfx_imm_set_colour(imm, vec4_make(0.2, 0.2, 1.0, 0.3)); - render_bounding_boxes(imm, gfx_get_scene_root(state->scene)); + render_bounding_boxes_rec(imm, gfx_get_scene_root(state->scene)); gfx_imm_end(imm); gfx_set_polygon_offset(render_backend, 0.0f, 0.0f); @@ -206,6 +206,25 @@ void render(const Game* game, const State* state) { gfx_set_blending(render_backend, false); } +void render(const Game* game, const State* state) { + assert(state); + assert(game); + assert(game->gfx); + assert(state->scene); + assert(state->camera); + + Renderer* renderer = gfx_get_renderer(game->gfx); + assert(renderer); + + gfx_render_scene( + renderer, &(RenderSceneParams){ + .mode = RenderDefault, + .scene = state->scene, + .camera = state->camera}); + + render_bounding_boxes(game, state); +} + void resize(Game* game, State* state, int width, int height) { assert(game); assert(state); -- cgit v1.2.3