blob: adbec8db4b9101d123040801932cbf69e8db7c4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "light_impl.h"
#include "node_impl.h"
#include "scene_memory.h"
#include <error.h>
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);
}
}
|