Kohi Game Engine
light_system.h File Reference

This file contains the implementation of the light system, which manages all lighting objects within the engine. More...

#include "defines.h"
#include "math/math_types.h"

Go to the source code of this file.

Data Structures

struct  directional_light_data
 
struct  directional_light
 A directional light, typically used to emulate sun/moon light. More...
 
struct  point_light_data
 
struct  point_light
 A point light, the most common light source, which radiates out from the given position. More...
 

Typedefs

typedef struct directional_light_data directional_light_data
 
typedef struct directional_light directional_light
 A directional light, typically used to emulate sun/moon light. More...
 
typedef struct point_light_data point_light_data
 
typedef struct point_light point_light
 A point light, the most common light source, which radiates out from the given position. More...
 

Functions

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 obtain the memory requirement (where memory=0), and a second time passing allocated memory the size of memory_requirement. More...
 
void light_system_shutdown (void *state)
 Shuts down the light system, releasing all resources. More...
 
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, and is overwritten when one is passed here. More...
 
KAPI b8 light_system_point_add (point_light *light)
 Attempts to add a point light to the system. More...
 
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 to be removed must be the original that was added. More...
 
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 to be removed must be the original that was added. More...
 
KAPI directional_lightlight_system_directional_light_get (void)
 Obtains a pointer to the current directional light. Can be NULL if one has not been added. More...
 
KAPI u32 light_system_point_light_count (void)
 Returns the total number of point lights currently in the system. More...
 
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 least enough space as determined by a call to light_system_point_light_count(). More...
 

Detailed Description

This file contains the implementation of the light system, which manages all lighting objects within the engine.

Author
Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
Version
1.0
Date
2023-03-02

Typedef Documentation

◆ directional_light

A directional light, typically used to emulate sun/moon light.

◆ directional_light_data

◆ point_light

typedef struct point_light point_light

A point light, the most common light source, which radiates out from the given position.

◆ point_light_data

Function Documentation

◆ light_system_directional_add()

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, and is overwritten when one is passed here.

Parameters
lightA pointer to the light to be added.
Returns
True on success; otherwise false.

◆ light_system_directional_light_get()

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.

Returns
A pointer to the current directional light.

◆ light_system_directional_remove()

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 to be removed must be the original that was added.

Parameters
lightA pointer to the light to be removed.
Returns
True on successful removal; otherwise false.

◆ light_system_initialize()

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 obtain the memory requirement (where memory=0), and a second time passing allocated memory the size of memory_requirement.

Parameters
memory_requirementA pointer to hold the memory requirement.
memoryBlock of allocated memory, or 0 if requesting memory requirement.
configConfiguration for this system. Currently unused.
Returns
True on success; otherwise false.

◆ light_system_point_add()

KAPI b8 light_system_point_add ( point_light light)

Attempts to add a point light to the system.

Parameters
lightA pointer to the light to be added.
Returns
True on success; otherwise false.

◆ light_system_point_light_count()

KAPI u32 light_system_point_light_count ( void  )

Returns the total number of point lights currently in the system.

Returns
The total number of point lights currently in the system.

◆ light_system_point_lights_get()

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 least enough space as determined by a call to light_system_point_light_count().

Parameters
p_lightsAn array of point lights. These lights are copies of the original.
Returns
True on success; otherwise false.

◆ light_system_point_remove()

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 to be removed must be the original that was added.

Parameters
lightA pointer to the light to be removed.
Returns
True on successful removal; otherwise false.

◆ light_system_shutdown()

void light_system_shutdown ( void *  state)

Shuts down the light system, releasing all resources.

Parameters
stateThe state/memory block for the system.