summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--game/src/plugins/texture_view.c2
-rw-r--r--game/src/plugins/viewer.c4
-rw-r--r--gfx/CMakeLists.txt6
-rw-r--r--gfx/src/asset/asset_cache.c9
-rw-r--r--gfx/src/asset/scene.c (renamed from gfx/src/util/scene.c)56
-rw-r--r--gfx/src/asset/scene.h (renamed from gfx/include/gfx/util/scene.h)2
-rw-r--r--gfx/src/asset/texture.c (renamed from gfx/src/util/texture.c)8
-rw-r--r--gfx/src/asset/texture.h (renamed from gfx/include/gfx/util/texture.h)2
8 files changed, 45 insertions, 44 deletions
diff --git a/game/src/plugins/texture_view.c b/game/src/plugins/texture_view.c
index 31bf23e..2c5db34 100644
--- a/game/src/plugins/texture_view.c
+++ b/game/src/plugins/texture_view.c
@@ -1,11 +1,11 @@
1#include "plugin.h" 1#include "plugin.h"
2 2
3#include "../../../gfx/src/asset/texture.h"
3#include <gfx/render_backend.h> 4#include <gfx/render_backend.h>
4#include <gfx/renderer.h> 5#include <gfx/renderer.h>
5#include <gfx/scene.h> 6#include <gfx/scene.h>
6#include <gfx/util/geometry.h> 7#include <gfx/util/geometry.h>
7#include <gfx/util/shader.h> 8#include <gfx/util/shader.h>
8#include <gfx/util/texture.h>
9 9
10#include <math/camera.h> 10#include <math/camera.h>
11 11
diff --git a/game/src/plugins/viewer.c b/game/src/plugins/viewer.c
index 769887f..ad87821 100644
--- a/game/src/plugins/viewer.c
+++ b/game/src/plugins/viewer.c
@@ -1,10 +1,10 @@
1#include "plugin.h" 1#include "plugin.h"
2 2
3#include "../../../gfx/src/asset/scene.h"
4#include "../../../gfx/src/asset/texture.h"
3#include <gfx/renderer.h> 5#include <gfx/renderer.h>
4#include <gfx/scene.h> 6#include <gfx/scene.h>
5#include <gfx/util/scene.h>
6#include <gfx/util/skyquad.h> 7#include <gfx/util/skyquad.h>
7#include <gfx/util/texture.h>
8#include <math/camera.h> 8#include <math/camera.h>
9#include <math/spatial3.h> 9#include <math/spatial3.h>
10 10
diff --git a/gfx/CMakeLists.txt b/gfx/CMakeLists.txt
index 2b295d5..2d83a7c 100644
--- a/gfx/CMakeLists.txt
+++ b/gfx/CMakeLists.txt
@@ -34,6 +34,8 @@ add_shader_library(shaders
34 34
35add_library(gfx SHARED 35add_library(gfx SHARED
36 src/asset/asset_cache.c 36 src/asset/asset_cache.c
37 src/asset/scene.c
38 src/asset/texture.c
37 src/render/buffer.c 39 src/render/buffer.c
38 src/render/framebuffer.c 40 src/render/framebuffer.c
39 src/render/geometry.c 41 src/render/geometry.c
@@ -57,9 +59,7 @@ add_library(gfx SHARED
57 src/util/geometry.c 59 src/util/geometry.c
58 src/util/ibl.c 60 src/util/ibl.c
59 src/util/shader.c 61 src/util/shader.c
60 src/util/scene.c 62 src/util/skyquad.c)
61 src/util/skyquad.c
62 src/util/texture.c)
63 63
64target_include_directories(gfx PUBLIC 64target_include_directories(gfx PUBLIC
65 include) 65 include)
diff --git a/gfx/src/asset/asset_cache.c b/gfx/src/asset/asset_cache.c
index fd9f1f8..0075d41 100644
--- a/gfx/src/asset/asset_cache.c
+++ b/gfx/src/asset/asset_cache.c
@@ -1,11 +1,14 @@
1#include "asset_cache.h" 1#include "asset_cache.h"
2 2
3#include "scene.h"
4#include "texture.h"
3#include <gfx/asset.h> 5#include <gfx/asset.h>
4#include <gfx/gfx.h> 6#include <gfx/gfx.h>
5#include <gfx/util/scene.h> 7#include <gfx/scene/node.h>
6#include <gfx/util/texture.h>
7#include <gfx_assert.h> 8#include <gfx_assert.h>
8 9
10#include "scene/node_impl.h"
11
9#include <cstring.h> 12#include <cstring.h>
10#include <log/log.h> 13#include <log/log.h>
11 14
@@ -119,8 +122,6 @@ SceneNode* gfx_load_scene(
119 AssetCache* cache = gfx_get_asset_cache(gfx); 122 AssetCache* cache = gfx_get_asset_cache(gfx);
120 123
121 // First search for the asset in the cache. 124 // First search for the asset in the cache.
122 // TODO: Animated models are currently mutated in place, so sharing them is
123 // not really valid.
124 const uint64_t hash = calc_scene_hash(cmd); 125 const uint64_t hash = calc_scene_hash(cmd);
125 Asset* asset = lookup_cache(cache, hash); 126 Asset* asset = lookup_cache(cache, hash);
126 if (asset) { 127 if (asset) {
diff --git a/gfx/src/util/scene.c b/gfx/src/asset/scene.c
index a491238..156e7b6 100644
--- a/gfx/src/util/scene.c
+++ b/gfx/src/asset/scene.c
@@ -79,34 +79,34 @@
79/// In our case, we use the specular-glosiness model if parameters for it are 79/// In our case, we use the specular-glosiness model if parameters for it are
80/// provided, otherwise we use the metallic-roughness model. 80/// provided, otherwise we use the metallic-roughness model.
81 81
82#include <gfx/util/scene.h> 82#include "asset/scene.h"
83 83
84#include <gfx/gfx.h> 84#include "asset/texture.h"
85#include <gfx/render_backend.h> 85#include "gfx/gfx.h"
86#include <gfx/scene/animation.h> 86#include "gfx/render_backend.h"
87#include <gfx/scene/camera.h> 87#include "gfx/scene/animation.h"
88#include <gfx/scene/material.h> 88#include "gfx/scene/camera.h"
89#include <gfx/scene/mesh.h> 89#include "gfx/scene/material.h"
90#include <gfx/scene/node.h> 90#include "gfx/scene/mesh.h"
91#include <gfx/scene/object.h> 91#include "gfx/scene/node.h"
92#include <gfx/scene/scene.h> 92#include "gfx/scene/object.h"
93#include <gfx/sizes.h> 93#include "gfx/scene/scene.h"
94#include <gfx/util/shader.h> 94#include "gfx/sizes.h"
95#include <gfx/util/texture.h> 95#include "gfx/util/shader.h"
96 96
97#include <cstring.h> 97#include "cstring.h"
98#include <error.h> 98#include "error.h"
99#include <log/log.h> 99#include "log/log.h"
100#include <math/camera.h> 100#include "math/camera.h"
101#include <math/defs.h> 101#include "math/defs.h"
102#include <math/mat4.h> 102#include "math/mat4.h"
103#include <math/quat.h> 103#include "math/quat.h"
104#include <math/vec2.h> 104#include "math/vec2.h"
105#include <math/vec3.h> 105#include "math/vec3.h"
106 106
107#include <cgltf_tangents.h> 107#include "cgltf_tangents.h"
108#define CGLTF_IMPLEMENTATION 108#define CGLTF_IMPLEMENTATION
109#include <cgltf.h> 109#include "cgltf.h"
110 110
111#include <assert.h> 111#include <assert.h>
112#include <stdbool.h> 112#include <stdbool.h>
@@ -1320,7 +1320,7 @@ static void load_nodes(
1320 gfx_construct_object_node(nodes[n], object); 1320 gfx_construct_object_node(nodes[n], object);
1321 if (node->skin) { 1321 if (node->skin) {
1322 assert(anima); 1322 assert(anima);
1323 1323
1324 const cgltf_size skin_index = node->skin - data->skins; 1324 const cgltf_size skin_index = node->skin - data->skins;
1325 assert(skin_index < data->skins_count); 1325 assert(skin_index < data->skins_count);
1326 const Skeleton* skeleton = gfx_get_anima_skeleton(anima, skin_index); 1326 const Skeleton* skeleton = gfx_get_anima_skeleton(anima, skin_index);
diff --git a/gfx/include/gfx/util/scene.h b/gfx/src/asset/scene.h
index 5c47196..a8dab13 100644
--- a/gfx/include/gfx/util/scene.h
+++ b/gfx/src/asset/scene.h
@@ -1,7 +1,7 @@
1/// Load scene files. 1/// Load scene files.
2#pragma once 2#pragma once
3 3
4#include <gfx/asset.h> 4#include "gfx/asset.h"
5 5
6typedef struct Gfx Gfx; 6typedef struct Gfx Gfx;
7typedef struct SceneNode SceneNode; 7typedef struct SceneNode SceneNode;
diff --git a/gfx/src/util/texture.c b/gfx/src/asset/texture.c
index 0d2e4b8..d15f09f 100644
--- a/gfx/src/util/texture.c
+++ b/gfx/src/asset/texture.c
@@ -1,11 +1,11 @@
1#include <gfx/util/texture.h> 1#include "texture.h"
2 2
3#include <gfx/render_backend.h> 3#include "gfx/render_backend.h"
4 4
5#include <error.h> 5#include "error.h"
6 6
7#define STB_IMAGE_IMPLEMENTATION 7#define STB_IMAGE_IMPLEMENTATION
8#include <stb_image.h> 8#include "stb_image.h"
9 9
10#include <assert.h> 10#include <assert.h>
11 11
diff --git a/gfx/include/gfx/util/texture.h b/gfx/src/asset/texture.h
index a3239fe..4204008 100644
--- a/gfx/include/gfx/util/texture.h
+++ b/gfx/src/asset/texture.h
@@ -1,7 +1,7 @@
1/// Load textures from images. 1/// Load textures from images.
2#pragma once 2#pragma once
3 3
4#include <gfx/asset.h> 4#include "gfx/asset.h"
5 5
6/// Load a texture. 6/// Load a texture.
7Texture* gfx_texture_load(RenderBackend*, const LoadTextureCmd*); 7Texture* gfx_texture_load(RenderBackend*, const LoadTextureCmd*);