From 1ec46bead3cf87971a2329f9ef4ddde5a0c48325 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Fri, 4 Jul 2025 10:27:06 -0700 Subject: Clarify doc --- src/llr/light.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/llr/light.c (limited to 'src/llr/light.c') diff --git a/src/llr/light.c b/src/llr/light.c new file mode 100644 index 0000000..168f16a --- /dev/null +++ b/src/llr/light.c @@ -0,0 +1,42 @@ +#include "../scene/light_impl.h" + +#include "../scene/node_impl.h" +#include "../scene/scene_memory.h" + +#include + +static void make_environment_light( + Light* light, const EnvironmentLightDesc* desc) { + assert(light); + assert(desc); + light->type = EnvironmentLightType; + light->environment.environment_map = desc->environment_map; +} + +Light* gfx_make_light(const LightDesc* desc) { + assert(desc); + + Light* light = mem_alloc_light(); + + switch (desc->type) { + case EnvironmentLightType: + make_environment_light(light, &desc->light.environment); + break; + default: + log_error("Unhandled light type"); + gfx_destroy_light(&light); + return 0; + } + + return light; +} + +void gfx_destroy_light(Light** light) { + assert(light); + if (*light) { + if ((*light)->parent.val) { + gfx_del_node((*light)->parent); + } + mem_free_light(light); + } +} -- cgit v1.2.3