diff options
-rw-r--r-- | game/src/game.c | 5 | ||||
-rw-r--r-- | game/src/plugins/viewer.c | 46 |
2 files changed, 27 insertions, 24 deletions
diff --git a/game/src/game.c b/game/src/game.c index dc2248b..51f5cbe 100644 --- a/game/src/game.c +++ b/game/src/game.c | |||
@@ -14,14 +14,9 @@ | |||
14 | #include <gfx/core.h> | 14 | #include <gfx/core.h> |
15 | #include <gfx/gfx.h> | 15 | #include <gfx/gfx.h> |
16 | #include <gfx/renderer.h> | 16 | #include <gfx/renderer.h> |
17 | #include <gfx/scene/camera.h> | ||
18 | #include <gfx/scene/node.h> | ||
19 | #include <gfx/scene/object.h> | ||
20 | #include <gfx/scene/scene.h> | ||
21 | 17 | ||
22 | #include <error.h> | 18 | #include <error.h> |
23 | #include <log/log.h> | 19 | #include <log/log.h> |
24 | #include <math/camera.h> | ||
25 | #include <plugin.h> | 20 | #include <plugin.h> |
26 | 21 | ||
27 | #include <assert.h> | 22 | #include <assert.h> |
diff --git a/game/src/plugins/viewer.c b/game/src/plugins/viewer.c index 5fc4be7..23b9ffb 100644 --- a/game/src/plugins/viewer.c +++ b/game/src/plugins/viewer.c | |||
@@ -12,15 +12,28 @@ | |||
12 | 12 | ||
13 | #include <stdlib.h> | 13 | #include <stdlib.h> |
14 | 14 | ||
15 | // Skybox. | ||
16 | static const char* skybox[6] = { | ||
17 | "/home/jeanne/Nextcloud/assets/textures/skybox/clouds1/clouds1_east.bmp", | ||
18 | "/home/jeanne/Nextcloud/assets/textures/skybox/clouds1/clouds1_west.bmp", | ||
19 | "/home/jeanne/Nextcloud/assets/textures/skybox/clouds1/clouds1_up.bmp", | ||
20 | "/home/jeanne/Nextcloud/assets/textures/skybox/clouds1/clouds1_down.bmp", | ||
21 | "/home/jeanne/Nextcloud/assets/textures/skybox/clouds1/clouds1_south.bmp", | ||
22 | "/home/jeanne/Nextcloud/assets/textures/skybox/clouds1/clouds1_north.bmp", | ||
23 | }; | ||
24 | |||
15 | // Paths to various scene files. | 25 | // Paths to various scene files. |
16 | static const char* BOX = "/assets/models/box.gltf"; | 26 | static const char* BOX = "/home/jeanne/Nextcloud/assets/models/box.gltf"; |
17 | static const char* SUZANNE = "/assets/models/suzanne.gltf"; | 27 | static const char* SUZANNE = |
18 | static const char* SPONZA = | 28 | "/home/jeanne/Nextcloud/assets/models/suzanne.gltf"; |
19 | "/assets/glTF-Sample-Models/2.0/Sponza/glTF/Sponza.gltf"; | 29 | static const char* SPONZA = "/home/jeanne/Nextcloud/assets/glTF-Sample-Models/" |
30 | "2.0/Sponza/glTF/Sponza.gltf"; | ||
20 | static const char* FLIGHT_HELMET = | 31 | static const char* FLIGHT_HELMET = |
21 | "/assets/glTF-Sample-Models/2.0/FlightHelmet/glTF/FlightHelmet.gltf"; | 32 | "/home/jeanne/Nextcloud/assets/glTF-Sample-Models/2.0/FlightHelmet/glTF/" |
33 | "FlightHelmet.gltf"; | ||
22 | static const char* DAMAGED_HELMET = | 34 | static const char* DAMAGED_HELMET = |
23 | "/assets/glTF-Sample-Models/2.0/DamagedHelmet/glTF/DamagedHelmet.gltf"; | 35 | "/home/jeanne/Nextcloud/assets/glTF-Sample-Models/2.0/DamagedHelmet/glTF/" |
36 | "DamagedHelmet.gltf"; | ||
24 | static const char* GIRL = | 37 | static const char* GIRL = |
25 | "/home/jeanne/Nextcloud/assets/models/girl/girl-with-ground.gltf"; | 38 | "/home/jeanne/Nextcloud/assets/models/girl/girl-with-ground.gltf"; |
26 | static const char* BOXES = | 39 | static const char* BOXES = |
@@ -67,12 +80,9 @@ static const Texture* load_environment_map(Gfx* gfx) { | |||
67 | .filtering = NearestFiltering, | 80 | .filtering = NearestFiltering, |
68 | .mipmaps = false, | 81 | .mipmaps = false, |
69 | .data.cubemap.filepaths = { | 82 | .data.cubemap.filepaths = { |
70 | mstring_make("/assets/skybox/clouds1/clouds1_east.bmp"), | 83 | mstring_make(skybox[0]), mstring_make(skybox[1]), |
71 | mstring_make("/assets/skybox/clouds1/clouds1_west.bmp"), | 84 | mstring_make(skybox[2]), mstring_make(skybox[3]), |
72 | mstring_make("/assets/skybox/clouds1/clouds1_up.bmp"), | 85 | mstring_make(skybox[4]), mstring_make(skybox[5])} |
73 | mstring_make("/assets/skybox/clouds1/clouds1_down.bmp"), | ||
74 | mstring_make("/assets/skybox/clouds1/clouds1_south.bmp"), | ||
75 | mstring_make("/assets/skybox/clouds1/clouds1_north.bmp")} | ||
76 | }); | 86 | }); |
77 | } | 87 | } |
78 | 88 | ||
@@ -109,9 +119,8 @@ static Model* load_scene(Game* game, State* state, const char* scene_filepath) { | |||
109 | } | 119 | } |
110 | 120 | ||
111 | Model* model = gfx_load_model( | 121 | Model* model = gfx_load_model( |
112 | game->gfx, | 122 | game->gfx, &(LoadModelCmd){.origin = AssetFromFile, |
113 | &(LoadModelCmd){ | 123 | .filepath = mstring_make(scene_filepath)}); |
114 | .origin = AssetFromFile, .filepath = mstring_make(scene_filepath)}); | ||
115 | if (!model) { | 124 | if (!model) { |
116 | return 0; | 125 | return 0; |
117 | } | 126 | } |
@@ -341,10 +350,9 @@ void render(const Game* game, const State* state) { | |||
341 | assert(renderer); | 350 | assert(renderer); |
342 | 351 | ||
343 | gfx_render_scene( | 352 | gfx_render_scene( |
344 | renderer, &(RenderSceneParams){ | 353 | renderer, &(RenderSceneParams){.mode = RenderDefault, |
345 | .mode = RenderDefault, | 354 | .scene = state->scene, |
346 | .scene = state->scene, | 355 | .camera = state->camera}); |
347 | .camera = state->camera}); | ||
348 | 356 | ||
349 | if (RenderBoundingBoxes) { | 357 | if (RenderBoundingBoxes) { |
350 | render_bounding_boxes(game, state); | 358 | render_bounding_boxes(game, state); |