Kohi Game Engine
resource_system.h File Reference

This file contains the implementation of the resource system. The resource system is responsible for managing resources and their loaders in the engine. More...

Go to the source code of this file.

Data Structures

struct  resource_system_config
 The configuration for the resource system. More...
 
struct  resource_loader
 An "interface" for a resource loader. All registered loaders use this. More...
 

Typedefs

typedef struct resource_system_config resource_system_config
 The configuration for the resource system. More...
 
typedef struct resource_loader resource_loader
 An "interface" for a resource loader. All registered loaders use this. More...
 

Functions

b8 resource_system_initialize (u64 *memory_requirement, void *state, void *config)
 Initializes this system. Should be called twice; once to get the memory requirement (passing state=0), and a second time passing an allocated block of memory to actually initialize the system. More...
 
void resource_system_shutdown (void *state)
 Shuts down the resource system. More...
 
KAPI b8 resource_system_loader_register (resource_loader loader)
 Registers the given resource loader with the system. More...
 
KAPI b8 resource_system_load (const char *name, resource_type type, void *params, resource *out_resource)
 Loads a resource of the given name. More...
 
KAPI b8 resource_system_load_custom (const char *name, const char *custom_type, void *params, resource *out_resource)
 Loads a resource of the given name and of a custom type. More...
 
KAPI void resource_system_unload (resource *resource)
 Unloads the given resource. More...
 
KAPI const char * resource_system_base_path (void)
 Returns the base path of the resource system. More...
 

Detailed Description

This file contains the implementation of the resource system. The resource system is responsible for managing resources and their loaders in the engine.

Author
Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
Version
1.0
Date
2022-01-11

Typedef Documentation

◆ resource_loader

An "interface" for a resource loader. All registered loaders use this.

◆ resource_system_config

The configuration for the resource system.

Function Documentation

◆ resource_system_base_path()

KAPI const char* resource_system_base_path ( void  )

Returns the base path of the resource system.

◆ resource_system_initialize()

b8 resource_system_initialize ( u64 memory_requirement,
void *  state,
void *  config 
)

Initializes this system. Should be called twice; once to get the memory requirement (passing state=0), and a second time passing an allocated block of memory to actually initialize the system.

Parameters
memory_requirementA pointer to hold the memory requirement as it is calculated.
stateA block of memory to hold the state or, if gathering the memory requirement, 0.
configThe configuration (resource_system_config) for this system.
Returns
True on success; otherwise false.

◆ resource_system_load()

KAPI b8 resource_system_load ( const char *  name,
resource_type  type,
void *  params,
resource out_resource 
)

Loads a resource of the given name.

Parameters
nameThe name of the resource to load.
typeThe type of resource to load.
paramsParameters to be passed to the loader, or 0.
out_resourceA pointer to hold the newly-loaded resource.
Returns
True on success; otherwise false.

◆ resource_system_load_custom()

KAPI b8 resource_system_load_custom ( const char *  name,
const char *  custom_type,
void *  params,
resource out_resource 
)

Loads a resource of the given name and of a custom type.

Parameters
nameThe name of the resource to load.
custom_typeThe custom resource type.
paramsParameters to be passed to the loader, or 0.
out_resourceA pointer to hold the newly-loaded resource.
Returns
True on success; otherwise false.

◆ resource_system_loader_register()

KAPI b8 resource_system_loader_register ( resource_loader  loader)

Registers the given resource loader with the system.

Parameters
loaderThe loader to be registered.
Returns
True on success; otherwise false.

◆ resource_system_shutdown()

void resource_system_shutdown ( void *  state)

Shuts down the resource system.

Parameters
stateThe state block of memory for this system.

◆ resource_system_unload()

KAPI void resource_system_unload ( resource resource)

Unloads the given resource.

Parameters
resourceA pointer to the resource to be unloaded.