Kohi Game Engine
resource_system.h
Go to the documentation of this file.
1 
14 #pragma once
15 
17 
19 typedef struct resource_system_config {
25 
27 typedef struct resource_loader {
33  const char* custom_type;
35  const char* type_path;
44  b8 (*load)(struct resource_loader* self, const char* name, void* params, resource* out_resource);
45 
51  void (*unload)(struct resource_loader* self, resource* resource);
53 
64 b8 resource_system_initialize(u64* memory_requirement, void* state, void* config);
65 
71 void resource_system_shutdown(void* state);
72 
80 
90 KAPI b8 resource_system_load(const char* name, resource_type type, void* params, resource* out_resource);
91 
101 KAPI b8 resource_system_load_custom(const char* name, const char* custom_type, void* params, resource* out_resource);
102 
109 
111 KAPI const char* resource_system_base_path(void);
#define KAPI
Import/export qualifier.
Definition: defines.h:177
unsigned int u32
Unsigned 32-bit integer.
Definition: defines.h:25
_Bool b8
8-bit boolean type
Definition: defines.h:58
unsigned long long u64
Unsigned 64-bit integer.
Definition: defines.h:28
KAPI const char * resource_system_base_path(void)
Returns the base path of the resource system.
KAPI b8 resource_system_loader_register(resource_loader loader)
Registers the given resource loader with the system.
KAPI void resource_system_unload(resource *resource)
Unloads the given resource.
struct resource_loader resource_loader
An "interface" for a resource loader. All registered loaders use this.
void resource_system_shutdown(void *state)
Shuts down the resource system.
KAPI b8 resource_system_load(const char *name, resource_type type, void *params, resource *out_resource)
Loads a resource of the given name.
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.
struct resource_system_config resource_system_config
The configuration for the resource system.
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)...
This file contains the types for common resources the engine uses.
struct resource resource
A generic structure for a resource. All resource loaders load data into these.
resource_type
Pre-defined resource types.
Definition: resource_types.h:19
An "interface" for a resource loader. All registered loaders use this.
Definition: resource_system.h:27
const char * type_path
A type path which is prepended for the asset type.
Definition: resource_system.h:35
u32 id
The loader identifier.
Definition: resource_system.h:29
resource_type type
The loader resource type.
Definition: resource_system.h:31
void(* unload)(struct resource_loader *self, resource *resource)
Unloads the given resource. Loader is determined by the resource's assigned loader id.
Definition: resource_system.h:51
b8(* load)(struct resource_loader *self, const char *name, void *params, resource *out_resource)
Loads a resource using this loader.
Definition: resource_system.h:44
const char * custom_type
The loader custom type string, if type is set to custom.
Definition: resource_system.h:33
The configuration for the resource system.
Definition: resource_system.h:19
u32 max_loader_count
The maximum number of loaders that can be registered with this system.
Definition: resource_system.h:21
char * asset_base_path
The relative base path for assets.
Definition: resource_system.h:23
A generic structure for a resource. All resource loaders load data into these.
Definition: resource_types.h:67