From 6374541fa21c7a2d15ebfe2e99a460097d86d9ae Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Wed, 21 Jun 2023 08:54:46 -0700 Subject: Formatting. --- gltfview/src/plugins/texture_view.c | 22 +++++++++++----------- 1 file 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 @@ #include #include -#include // Default texture to load if no texture is provided. -static const char* CLOUDS1_TEXTURE = "/assets/skybox/clouds1/clouds1_west.bmp"; +static const char* DEFAULT_TEXTURE = "/assets/skybox/clouds1/clouds1_west.bmp"; +// static const char* DEFAULT_TEXTURE = "/assets/checkerboard.jpg"; bool boot(State* state, Game* game) { assert(game); // Usage: [texture file] - const char* texture_file = game->argc > 1 ? game->argv[1] : CLOUDS1_TEXTURE; + const char* texture_file = game->argc > 1 ? game->argv[1] : DEFAULT_TEXTURE; RenderBackend* render_backend = gfx_get_render_backend(game->gfx); @@ -29,6 +29,9 @@ bool boot(State* state, Game* game) { .filtering = LinearFiltering, .mipmaps = false, .data.texture.filepath = mstring_make(texture_file)}); + if (!texture) { + return false; + } ShaderProgram* shader = gfx_make_view_texture_shader(render_backend); if (!shader) { @@ -40,22 +43,19 @@ bool boot(State* state, Game* game) { return false; } - MaterialDesc material_desc = (MaterialDesc){0}; + MaterialDesc material_desc = (MaterialDesc){.num_uniforms = 1}; material_desc.uniforms[0] = (ShaderUniform){ .type = UniformTexture, .value.texture = texture, .name = sstring_make("Texture")}; - material_desc.num_uniforms = 1; - Material* material = gfx_make_material(&material_desc); + Material* material = gfx_make_material(&material_desc); if (!material) { return false; } - MeshDesc mesh_desc = (MeshDesc){0}; - mesh_desc.geometry = geometry; - mesh_desc.material = material; - mesh_desc.shader = shader; - Mesh* mesh = gfx_make_mesh(&mesh_desc); + const MeshDesc mesh_desc = + (MeshDesc){.geometry = geometry, .material = material, .shader = shader}; + Mesh* mesh = gfx_make_mesh(&mesh_desc); if (!mesh) { return false; } -- cgit v1.2.3