summaryrefslogtreecommitdiff
path: root/gltfview/src/plugins/texture_view.c
diff options
context:
space:
mode:
Diffstat (limited to 'gltfview/src/plugins/texture_view.c')
-rw-r--r--gltfview/src/plugins/texture_view.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/gltfview/src/plugins/texture_view.c b/gltfview/src/plugins/texture_view.c
index 2bca4a1..f16c8d1 100644
--- a/gltfview/src/plugins/texture_view.c
+++ b/gltfview/src/plugins/texture_view.c
@@ -9,16 +9,16 @@
9#include <math/camera.h> 9#include <math/camera.h>
10 10
11#include <assert.h> 11#include <assert.h>
12#include <stdlib.h>
13 12
14// Default texture to load if no texture is provided. 13// Default texture to load if no texture is provided.
15static const char* CLOUDS1_TEXTURE = "/assets/skybox/clouds1/clouds1_west.bmp"; 14static const char* DEFAULT_TEXTURE = "/assets/skybox/clouds1/clouds1_west.bmp";
15// static const char* DEFAULT_TEXTURE = "/assets/checkerboard.jpg";
16 16
17bool boot(State* state, Game* game) { 17bool boot(State* state, Game* game) {
18 assert(game); 18 assert(game);
19 19
20 // Usage: [texture file] 20 // Usage: [texture file]
21 const char* texture_file = game->argc > 1 ? game->argv[1] : CLOUDS1_TEXTURE; 21 const char* texture_file = game->argc > 1 ? game->argv[1] : DEFAULT_TEXTURE;
22 22
23 RenderBackend* render_backend = gfx_get_render_backend(game->gfx); 23 RenderBackend* render_backend = gfx_get_render_backend(game->gfx);
24 24
@@ -29,6 +29,9 @@ bool boot(State* state, Game* game) {
29 .filtering = LinearFiltering, 29 .filtering = LinearFiltering,
30 .mipmaps = false, 30 .mipmaps = false,
31 .data.texture.filepath = mstring_make(texture_file)}); 31 .data.texture.filepath = mstring_make(texture_file)});
32 if (!texture) {
33 return false;
34 }
32 35
33 ShaderProgram* shader = gfx_make_view_texture_shader(render_backend); 36 ShaderProgram* shader = gfx_make_view_texture_shader(render_backend);
34 if (!shader) { 37 if (!shader) {
@@ -40,22 +43,19 @@ bool boot(State* state, Game* game) {
40 return false; 43 return false;
41 } 44 }
42 45
43 MaterialDesc material_desc = (MaterialDesc){0}; 46 MaterialDesc material_desc = (MaterialDesc){.num_uniforms = 1};
44 material_desc.uniforms[0] = (ShaderUniform){ 47 material_desc.uniforms[0] = (ShaderUniform){
45 .type = UniformTexture, 48 .type = UniformTexture,
46 .value.texture = texture, 49 .value.texture = texture,
47 .name = sstring_make("Texture")}; 50 .name = sstring_make("Texture")};
48 material_desc.num_uniforms = 1; 51 Material* material = gfx_make_material(&material_desc);
49 Material* material = gfx_make_material(&material_desc);
50 if (!material) { 52 if (!material) {
51 return false; 53 return false;
52 } 54 }
53 55
54 MeshDesc mesh_desc = (MeshDesc){0}; 56 const MeshDesc mesh_desc =
55 mesh_desc.geometry = geometry; 57 (MeshDesc){.geometry = geometry, .material = material, .shader = shader};
56 mesh_desc.material = material; 58 Mesh* mesh = gfx_make_mesh(&mesh_desc);
57 mesh_desc.shader = shader;
58 Mesh* mesh = gfx_make_mesh(&mesh_desc);
59 if (!mesh) { 59 if (!mesh) {
60 return false; 60 return false;
61 } 61 }