Kohi Game Engine
simple_scene.h File Reference
#include "defines.h"
#include "math/math_types.h"
#include "resources/debug/debug_grid.h"

Go to the source code of this file.

Data Structures

struct  pending_mesh
 
struct  simple_scene
 

Typedefs

typedef enum simple_scene_state simple_scene_state
 
typedef struct pending_mesh pending_mesh
 
typedef struct simple_scene simple_scene
 

Enumerations

enum  simple_scene_state {
  SIMPLE_SCENE_STATE_UNINITIALIZED , SIMPLE_SCENE_STATE_INITIALIZED , SIMPLE_SCENE_STATE_LOADING , SIMPLE_SCENE_STATE_LOADED ,
  SIMPLE_SCENE_STATE_UNLOADING , SIMPLE_SCENE_STATE_UNLOADED
}
 

Functions

KAPI b8 simple_scene_create (void *config, simple_scene *out_scene)
 Creates a new scene with the given config with default values. No resources are allocated. Config is not yet processed. More...
 
KAPI b8 simple_scene_initialize (simple_scene *scene)
 Performs initialization routines on the scene, including processing configuration (if provided) and scaffolding heirarchy. More...
 
KAPI b8 simple_scene_load (simple_scene *scene)
 Performs loading routines and resource allocation on the given scene. More...
 
KAPI b8 simple_scene_unload (simple_scene *scene, b8 immediate)
 Performs unloading routines and resource de-allocation on the given scene. A scene is also destroyed when unloading. More...
 
KAPI b8 simple_scene_update (simple_scene *scene, const struct frame_data *p_frame_data)
 Performs any required scene updates for the given frame. More...
 
KAPI b8 simple_scene_populate_render_packet (simple_scene *scene, struct camera *current_camera, struct viewport *v, struct frame_data *p_frame_data, struct render_packet *packet)
 Populate the given render packet with data from the provided scene. More...
 
KAPI b8 simple_scene_raycast (simple_scene *scene, const struct ray *r, struct raycast_result *out_result)
 
KAPI b8 simple_scene_directional_light_add (simple_scene *scene, const char *name, struct directional_light *light)
 
KAPI b8 simple_scene_point_light_add (simple_scene *scene, const char *name, struct point_light *light)
 
KAPI b8 simple_scene_mesh_add (simple_scene *scene, const char *name, struct mesh *m)
 
KAPI b8 simple_scene_skybox_add (simple_scene *scene, const char *name, struct skybox *sb)
 
KAPI b8 simple_scene_terrain_add (simple_scene *scene, const char *name, struct terrain *t)
 
KAPI b8 simple_scene_directional_light_remove (simple_scene *scene, const char *name)
 
KAPI b8 simple_scene_point_light_remove (simple_scene *scene, const char *name)
 
KAPI b8 simple_scene_mesh_remove (simple_scene *scene, const char *name)
 
KAPI b8 simple_scene_skybox_remove (simple_scene *scene, const char *name)
 
KAPI b8 simple_scene_terrain_remove (simple_scene *scene, const char *name)
 
KAPI struct directional_lightsimple_scene_directional_light_get (simple_scene *scene, const char *name)
 
KAPI struct point_lightsimple_scene_point_light_get (simple_scene *scene, const char *name)
 
KAPI struct meshsimple_scene_mesh_get (simple_scene *scene, const char *name)
 
KAPI struct skyboxsimple_scene_skybox_get (simple_scene *scene, const char *name)
 
KAPI struct terrainsimple_scene_terrain_get (simple_scene *scene, const char *name)
 
KAPI struct transformsimple_scene_transform_get_by_id (simple_scene *scene, u32 unique_id)
 
KAPI b8 simple_scene_debug_render_data_query (simple_scene *scene, u32 *data_count, struct geometry_render_data **debug_geometries)
 

Typedef Documentation

◆ pending_mesh

typedef struct pending_mesh pending_mesh

◆ simple_scene

typedef struct simple_scene simple_scene

◆ simple_scene_state

Enumeration Type Documentation

◆ simple_scene_state

Enumerator
SIMPLE_SCENE_STATE_UNINITIALIZED 

created, but nothing more.

SIMPLE_SCENE_STATE_INITIALIZED 

Configuration parsed, not yet loaded hierarchy setup.

SIMPLE_SCENE_STATE_LOADING 

In the process of loading the hierarchy.

SIMPLE_SCENE_STATE_LOADED 

Everything is loaded, ready to play.

SIMPLE_SCENE_STATE_UNLOADING 

In the process of unloading, not ready to play.

SIMPLE_SCENE_STATE_UNLOADED 

Unloaded and ready to be destroyed.

Function Documentation

◆ simple_scene_create()

KAPI b8 simple_scene_create ( void *  config,
simple_scene out_scene 
)

Creates a new scene with the given config with default values. No resources are allocated. Config is not yet processed.

Parameters
configA pointer to the configuration. Optional.
out_sceneA pointer to hold the newly created scene. Required.
Returns
True on success; otherwise false.

◆ simple_scene_debug_render_data_query()

KAPI b8 simple_scene_debug_render_data_query ( simple_scene scene,
u32 data_count,
struct geometry_render_data **  debug_geometries 
)

◆ simple_scene_directional_light_add()

KAPI b8 simple_scene_directional_light_add ( simple_scene scene,
const char *  name,
struct directional_light light 
)

◆ simple_scene_directional_light_get()

KAPI struct directional_light* simple_scene_directional_light_get ( simple_scene scene,
const char *  name 
)

◆ simple_scene_directional_light_remove()

KAPI b8 simple_scene_directional_light_remove ( simple_scene scene,
const char *  name 
)

◆ simple_scene_initialize()

KAPI b8 simple_scene_initialize ( simple_scene scene)

Performs initialization routines on the scene, including processing configuration (if provided) and scaffolding heirarchy.

Parameters
sceneA pointer to the scene to be initialized.
Returns
True on success; otherwise false.

◆ simple_scene_load()

KAPI b8 simple_scene_load ( simple_scene scene)

Performs loading routines and resource allocation on the given scene.

Parameters
sceneA pointer to the scene to be loaded.
Returns
True on success; otherwise false.

◆ simple_scene_mesh_add()

KAPI b8 simple_scene_mesh_add ( simple_scene scene,
const char *  name,
struct mesh m 
)

◆ simple_scene_mesh_get()

KAPI struct mesh* simple_scene_mesh_get ( simple_scene scene,
const char *  name 
)

◆ simple_scene_mesh_remove()

KAPI b8 simple_scene_mesh_remove ( simple_scene scene,
const char *  name 
)

◆ simple_scene_point_light_add()

KAPI b8 simple_scene_point_light_add ( simple_scene scene,
const char *  name,
struct point_light light 
)

◆ simple_scene_point_light_get()

KAPI struct point_light* simple_scene_point_light_get ( simple_scene scene,
const char *  name 
)

◆ simple_scene_point_light_remove()

KAPI b8 simple_scene_point_light_remove ( simple_scene scene,
const char *  name 
)

◆ simple_scene_populate_render_packet()

KAPI b8 simple_scene_populate_render_packet ( simple_scene scene,
struct camera current_camera,
struct viewport v,
struct frame_data p_frame_data,
struct render_packet packet 
)

Populate the given render packet with data from the provided scene.

Parameters
sceneA pointer to the scene to be updated.
current_cameraThe current camera to use while rendering the scene.
viewportA pointer to the viewport to be used when populating the render packets.
p_frame_dataA constant pointer to the current frame's data.
packetA pointer to the packet to populate.
Returns
True on success; otherwise false.

◆ simple_scene_raycast()

KAPI b8 simple_scene_raycast ( simple_scene scene,
const struct ray r,
struct raycast_result out_result 
)

◆ simple_scene_skybox_add()

KAPI b8 simple_scene_skybox_add ( simple_scene scene,
const char *  name,
struct skybox sb 
)

◆ simple_scene_skybox_get()

KAPI struct skybox* simple_scene_skybox_get ( simple_scene scene,
const char *  name 
)

◆ simple_scene_skybox_remove()

KAPI b8 simple_scene_skybox_remove ( simple_scene scene,
const char *  name 
)

◆ simple_scene_terrain_add()

KAPI b8 simple_scene_terrain_add ( simple_scene scene,
const char *  name,
struct terrain t 
)

◆ simple_scene_terrain_get()

KAPI struct terrain* simple_scene_terrain_get ( simple_scene scene,
const char *  name 
)

◆ simple_scene_terrain_remove()

KAPI b8 simple_scene_terrain_remove ( simple_scene scene,
const char *  name 
)

◆ simple_scene_transform_get_by_id()

KAPI struct transform* simple_scene_transform_get_by_id ( simple_scene scene,
u32  unique_id 
)

◆ simple_scene_unload()

KAPI b8 simple_scene_unload ( simple_scene scene,
b8  immediate 
)

Performs unloading routines and resource de-allocation on the given scene. A scene is also destroyed when unloading.

Parameters
sceneA pointer to the scene to be unloaded.
immediateUnload immediately instead of the next frame. NOTE: can have unintended side effects if used improperly.
Returns
True on success; otherwise false.

◆ simple_scene_update()

KAPI b8 simple_scene_update ( simple_scene scene,
const struct frame_data p_frame_data 
)

Performs any required scene updates for the given frame.

Parameters
sceneA pointer to the scene to be updated.
p_frame_dataA constant pointer to the current frame's data.
Returns
True on success; otherwise false.