aboutsummaryrefslogtreecommitdiff
path: root/src/llr/light.c
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-07-04 10:27:06 -0700
committer3gg <3gg@shellblade.net>2025-07-04 10:27:06 -0700
commit1ec46bead3cf87971a2329f9ef4ddde5a0c48325 (patch)
tree3f4c404467c3ad9c94265295f4aa1b97a10a9eb3 /src/llr/light.c
parente386405ac636b7e4a41d5c03eb363e9c120ce919 (diff)
Clarify doc
Diffstat (limited to 'src/llr/light.c')
-rw-r--r--src/llr/light.c42
1 files changed, 42 insertions, 0 deletions
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 @@
1#include "../scene/light_impl.h"
2
3#include "../scene/node_impl.h"
4#include "../scene/scene_memory.h"
5
6#include <error.h>
7
8static void make_environment_light(
9 Light* light, const EnvironmentLightDesc* desc) {
10 assert(light);
11 assert(desc);
12 light->type = EnvironmentLightType;
13 light->environment.environment_map = desc->environment_map;
14}
15
16Light* gfx_make_light(const LightDesc* desc) {
17 assert(desc);
18
19 Light* light = mem_alloc_light();
20
21 switch (desc->type) {
22 case EnvironmentLightType:
23 make_environment_light(light, &desc->light.environment);
24 break;
25 default:
26 log_error("Unhandled light type");
27 gfx_destroy_light(&light);
28 return 0;
29 }
30
31 return light;
32}
33
34void gfx_destroy_light(Light** light) {
35 assert(light);
36 if (*light) {
37 if ((*light)->parent.val) {
38 gfx_del_node((*light)->parent);
39 }
40 mem_free_light(light);
41 }
42}