From 175c72557b21f356e295a6f8a4acd91b7e744bef Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Fri, 24 Oct 2025 15:40:40 -0700 Subject: Consolidate LLR into a single file. --- src/llr/material.c | 57 ------------------------------------------------------ 1 file changed, 57 deletions(-) delete mode 100644 src/llr/material.c (limited to 'src/llr/material.c') diff --git a/src/llr/material.c b/src/llr/material.c deleted file mode 100644 index f09dd3f..0000000 --- a/src/llr/material.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "material_impl.h" - -#include "memory.h" - -#include - -static void material_make(Material* material, const MaterialDesc* desc) { - assert(material); - assert(desc); - assert(desc->num_uniforms < GFX_MAX_UNIFORMS_PER_MATERIAL); - material->num_uniforms = desc->num_uniforms; - for (int i = 0; i < desc->num_uniforms; ++i) { - material->uniforms[i] = desc->uniforms[i]; - } -} - -Material* gfx_make_material(const MaterialDesc* desc) { - assert(desc); - Material* material = mem_alloc_material(); - material_make(material, desc); - return material; -} - -void gfx_destroy_material(Material** material) { mem_free_material(material); } - -static void set_uniform(ShaderProgram* prog, const ShaderUniform* uniform) { - switch (uniform->type) { - case UniformTexture: - gfx_set_texture_uniform(prog, uniform->name.str, uniform->value.texture); - break; - case UniformMat4: - gfx_set_mat4_uniform(prog, uniform->name.str, &uniform->value.mat4); - break; - case UniformVec3: - gfx_set_vec3_uniform(prog, uniform->name.str, uniform->value.vec3); - break; - case UniformVec4: - gfx_set_vec4_uniform(prog, uniform->name.str, uniform->value.vec4); - break; - case UniformFloat: - gfx_set_float_uniform(prog, uniform->name.str, uniform->value.scalar); - break; - case UniformMat4Array: - gfx_set_mat4_array_uniform( - prog, uniform->name.str, uniform->value.array.values, - uniform->value.array.count); - break; - } -} - -void gfx_material_activate(ShaderProgram* shader, const Material* material) { - assert(material); - for (int i = 0; i < material->num_uniforms; ++i) { - const ShaderUniform* uniform = &material->uniforms[i]; - set_uniform(shader, uniform); - } -} -- cgit v1.2.3