Kohi Game Engine
light_system.h
Go to the documentation of this file.
1 
12 #pragma once
13 
14 #include "defines.h"
15 #include "math/math_types.h"
16 #include "strings/kname.h"
17 
18 typedef struct directional_light_data {
23 
29 
33 typedef struct directional_light {
36 
42  void* debug_data;
44 
45 typedef struct point_light_data {
59 
64 typedef struct point_light {
72  void* debug_data;
73 
74  // The positional offset from whatever this may be attached to.
77 
88 b8 light_system_initialize(u64* memory_requirement, void* memory, void* config);
89 
95 void light_system_shutdown(void* state);
96 
105 
113 
122 
131 
139 
146 
This file contains global type definitions which are used throughout the entire engine and applicatio...
#define KAPI
Import/export qualifier.
Definition: defines.h:205
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:25
_Bool b8
8-bit boolean type
Definition: defines.h:58
float f32
32-bit floating point number
Definition: defines.h:47
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
This files contains an implementation of knames.
u64 kname
A kname is a string hash made for quick comparisons versus traditional string comparisons.
Definition: kname.h:36
KAPI b8 light_system_directional_add(directional_light *light)
Attempts to add a directional light to the system. Only one may be present at once,...
struct directional_light_data directional_light_data
struct point_light point_light
A point light, the most common light source, which radiates out from the given position.
KAPI b8 light_system_point_add(point_light *light)
Attempts to add a point light to the system.
KAPI u32 light_system_point_light_count(void)
Returns the total number of point lights currently in the system.
struct point_light_data point_light_data
b8 light_system_initialize(u64 *memory_requirement, void *memory, void *config)
Initializes the light system. As with most systems, this should be called twice, the first time to ob...
struct directional_light directional_light
A directional light, typically used to emulate sun/moon light.
KAPI b8 light_system_point_lights_get(point_light *p_lights)
Fills in the required array of point lights within the system. Array must already exist and have at l...
KAPI b8 light_system_point_remove(point_light *light)
Attempts to remove the given light from the system. A pointer comparison is done, meaning the light t...
KAPI directional_light * light_system_directional_light_get(void)
Obtains a pointer to the current directional light. Can be NULL if one has not been added.
KAPI b8 light_system_directional_remove(directional_light *light)
Attempts to remove the given light from the system. A pointer comparison is done, meaning the light t...
void light_system_shutdown(void *state)
Shuts down the light system, releasing all resources.
Contains various math types required for the engine.
Definition: light_system.h:18
f32 shadow_distance
Definition: light_system.h:24
f32 padding
Definition: light_system.h:27
f32 shadow_fade_distance
Definition: light_system.h:25
vec4 colour
The light colour.
Definition: light_system.h:20
vec4 direction
The direction of the light. The w component is ignored.
Definition: light_system.h:22
f32 shadow_split_mult
Definition: light_system.h:26
A directional light, typically used to emulate sun/moon light.
Definition: light_system.h:33
void * debug_data
Debug data assigned to the light.
Definition: light_system.h:42
kname name
The name of the directional light.
Definition: light_system.h:35
directional_light_data data
The directional light shader data.
Definition: light_system.h:40
u32 generation
Definition: light_system.h:38
Definition: light_system.h:45
f32 padding
Additional padding used for memory alignment purposes. Ignored.
Definition: light_system.h:57
vec4 position
The position of the light in the world. The w component is ignored.
Definition: light_system.h:49
vec4 colour
The light colour.
Definition: light_system.h:47
f32 constant_f
Usually 1, make sure denominator never gets smaller than 1.
Definition: light_system.h:51
f32 quadratic
Makes the light fall off slower at longer distances.
Definition: light_system.h:55
f32 linear
Reduces light intensity linearly.
Definition: light_system.h:53
A point light, the most common light source, which radiates out from the given position.
Definition: light_system.h:64
void * debug_data
Debug data assigned to the light.
Definition: light_system.h:72
kname name
The name of the light.
Definition: light_system.h:66
u32 generation
The generation of the light, incremented on every update. Can be used to detect when a shader upload ...
Definition: light_system.h:68
point_light_data data
The shader data for the point light.
Definition: light_system.h:70
vec4 position
Definition: light_system.h:75
A 4-element vector.
Definition: math_types.h:89