Kohi Game Engine
kasset_types.h File Reference
#include "containers/array.h"
#include "core_render_types.h"
#include "core_resource_types.h"
#include "defines.h"
#include "identifiers/identifier.h"
#include "math/math_types.h"
#include "parsers/kson_parser.h"
#include "strings/kname.h"

Go to the source code of this file.

Data Structures

struct  binary_asset_header
 The primary header for binary assets, to be used for serialization. This should be the first member of the asset-specific binary file header. NOTE: Binary asset headers should be 32-bit aligned. More...
 
struct  kasset_importer
 Represents the interface point for an importer. More...
 
struct  kasset_metadata
 Various metadata included with the asset. More...
 
struct  kasset
 a structure meant to be included as the first member in the struct of all asset types for quick casting purposes. More...
 
struct  kasset_heightmap_terrain
 
struct  kasset_image
 
struct  kasset_static_mesh_geometry
 
struct  kasset_static_mesh
 Represents a static mesh asset. More...
 
struct  kasset_material
 
struct  kasset_text
 
struct  kasset_binary
 
struct  kasset_kson
 
struct  kasset_scene
 
struct  kasset_shader_stage
 
struct  kasset_shader_attribute
 
struct  kasset_shader_uniform
 Represents a shader uniform within a shader asset. More...
 
struct  kasset_shader
 Represents a shader asset, typically loaded from disk. More...
 
struct  kasset_system_font_face
 
struct  kasset_system_font
 
struct  kasset_bitmap_font_glyph
 
struct  kasset_bitmap_font_kerning
 
struct  kasset_bitmap_font_page
 
struct  kasset_bitmap_font
 
struct  kasset_audio
 

Macros

#define ASSET_MAGIC   0xcafebabe
 A magic number indicating the file as a kohi binary asset file. More...
 
#define ASSET_MAGIC_U64   0xcafebabebadc0ffee
 
#define KASSET_TYPE_MAX_LENGTH   64
 
#define KASSET_NAME_MAX_LENGTH   256
 
#define KPACKAGE_NAME_MAX_LENGTH   128
 
#define KASSET_FULLY_QUALIFIED_NAME_MAX_LENGTH   = (KPACKAGE_NAME_MAX_LENGTH + KASSET_TYPE_MAX_LENGTH + KASSET_NAME_MAX_LENGTH + 2)
 
#define KASSET_TYPE_NAME_HEIGHTMAP_TERRAIN   "HeightmapTerrain"
 
#define KASSET_TYPE_NAME_IMAGE   "Image"
 
#define KASSET_TYPE_NAME_STATIC_MESH   "StaticMesh"
 
#define KASSET_TYPE_NAME_MATERIAL   "Material"
 
#define KASSET_TYPE_NAME_TEXT   "Text"
 
#define KASSET_TYPE_NAME_BINARY   "Binary"
 
#define KASSET_TYPE_NAME_KSON   "Kson"
 
#define KASSET_TYPE_NAME_SCENE   "Scene"
 
#define KASSET_TYPE_NAME_SHADER   "Shader"
 
#define KASSET_TYPE_NAME_SYSTEM_FONT   "SystemFont"
 
#define KASSET_TYPE_NAME_BITMAP_FONT   "BitmapFont"
 
#define KASSET_TYPE_NAME_AUDIO   "Audio"
 

Typedefs

typedef enum kasset_type kasset_type
 
typedef struct binary_asset_header binary_asset_header
 The primary header for binary assets, to be used for serialization. This should be the first member of the asset-specific binary file header. NOTE: Binary asset headers should be 32-bit aligned. More...
 
typedef enum asset_request_result asset_request_result
 
typedef void(* PFN_kasset_on_result) (asset_request_result result, const struct kasset *asset, void *listener_inst)
 A function pointer typedef to be used to provide the asset asset_system with a calback function when asset loading is complete or failed. This process is asynchronus. More...
 
typedef void(* PFN_kasset_on_hot_reload) (const struct vfs_asset_data *asset_data, const struct kasset *asset)
 A function pointer typedef to be used to provide the asset system with a callback function when an asset is written to on-disk (i.e. a hot-reload). This process is synchronous. More...
 
typedef b8(* PFN_kasset_importer_import) (const struct kasset_importer *self, u64 data_size, const void *data, void *params, struct kasset *out_asset)
 Imports an asset according to the provided params and the importer's internal logic. NOTE: Some importers (i.e. .obj for static meshes) can also trigger imports of other assets. Those assets are immediately serialized to disk/package and not returned here though. More...
 
typedef struct kasset_importer kasset_importer
 Represents the interface point for an importer. More...
 
typedef struct kasset_metadata kasset_metadata
 Various metadata included with the asset. More...
 
typedef struct kasset kasset
 a structure meant to be included as the first member in the struct of all asset types for quick casting purposes. More...
 
typedef struct kasset_heightmap_terrain kasset_heightmap_terrain
 
typedef struct kasset_image kasset_image
 
typedef struct kasset_static_mesh_geometry kasset_static_mesh_geometry
 
typedef struct kasset_static_mesh kasset_static_mesh
 Represents a static mesh asset. More...
 
typedef struct kasset_material kasset_material
 
typedef struct kasset_text kasset_text
 
typedef struct kasset_binary kasset_binary
 
typedef struct kasset_kson kasset_kson
 
typedef struct kasset_scene kasset_scene
 
typedef struct kasset_shader_stage kasset_shader_stage
 
typedef struct kasset_shader_attribute kasset_shader_attribute
 
typedef struct kasset_shader_uniform kasset_shader_uniform
 Represents a shader uniform within a shader asset. More...
 
typedef struct kasset_shader kasset_shader
 Represents a shader asset, typically loaded from disk. More...
 
typedef struct kasset_system_font_face kasset_system_font_face
 
typedef struct kasset_system_font kasset_system_font
 
typedef struct kasset_bitmap_font_glyph kasset_bitmap_font_glyph
 
typedef struct kasset_bitmap_font_kerning kasset_bitmap_font_kerning
 
typedef struct kasset_bitmap_font_page kasset_bitmap_font_page
 
typedef struct kasset_bitmap_font kasset_bitmap_font
 
typedef struct kasset_audio kasset_audio
 

Enumerations

enum  kasset_type {
  KASSET_TYPE_UNKNOWN , KASSET_TYPE_IMAGE = 1 , KASSET_TYPE_MATERIAL = 2 , KASSET_TYPE_STATIC_MESH = 3 ,
  KASSET_TYPE_HEIGHTMAP_TERRAIN = 4 , KASSET_TYPE_SCENE = 5 , KASSET_TYPE_BITMAP_FONT = 6 , KASSET_TYPE_SYSTEM_FONT = 7 ,
  KASSET_TYPE_TEXT = 8 , KASSET_TYPE_BINARY = 9 , KASSET_TYPE_KSON = 10 , KASSET_TYPE_VOXEL_TERRAIN = 11 ,
  KASSET_TYPE_SKELETAL_MESH = 12 , KASSET_TYPE_AUDIO = 13 , KASSET_TYPE_SHADER = 14 , KASSET_TYPE_MAX
}
 
enum  asset_request_result {
  ASSET_REQUEST_RESULT_SUCCESS , ASSET_REQUEST_RESULT_INVALID_PACKAGE , ASSET_REQUEST_RESULT_INVALID_ASSET_TYPE , ASSET_REQUEST_RESULT_INVALID_NAME ,
  ASSET_REQUEST_RESULT_PARSE_FAILED , ASSET_REQUEST_RESULT_GPU_UPLOAD_FAILED , ASSET_REQUEST_RESULT_INTERNAL_FAILURE , ASSET_REQUEST_RESULT_NO_HANDLER ,
  ASSET_REQUEST_RESULT_NO_IMPORTER_FOR_SOURCE_ASSET , ASSET_REQUEST_RESULT_VFS_REQUEST_FAILED , ASSET_REQUEST_RESULT_AUTO_IMPORT_FAILED , ASSET_REQUEST_RESULT_COUNT
}
 

Functions

 ARRAY_TYPE (kasset_bitmap_font_glyph)
 
 ARRAY_TYPE (kasset_bitmap_font_kerning)
 
 ARRAY_TYPE (kasset_bitmap_font_page)
 

Macro Definition Documentation

◆ ASSET_MAGIC

#define ASSET_MAGIC   0xcafebabe

A magic number indicating the file as a kohi binary asset file.

◆ ASSET_MAGIC_U64

#define ASSET_MAGIC_U64   0xcafebabebadc0ffee

◆ KASSET_FULLY_QUALIFIED_NAME_MAX_LENGTH

#define KASSET_FULLY_QUALIFIED_NAME_MAX_LENGTH   = (KPACKAGE_NAME_MAX_LENGTH + KASSET_TYPE_MAX_LENGTH + KASSET_NAME_MAX_LENGTH + 2)

◆ KASSET_NAME_MAX_LENGTH

#define KASSET_NAME_MAX_LENGTH   256

◆ KASSET_TYPE_MAX_LENGTH

#define KASSET_TYPE_MAX_LENGTH   64

◆ KASSET_TYPE_NAME_AUDIO

#define KASSET_TYPE_NAME_AUDIO   "Audio"

◆ KASSET_TYPE_NAME_BINARY

#define KASSET_TYPE_NAME_BINARY   "Binary"

◆ KASSET_TYPE_NAME_BITMAP_FONT

#define KASSET_TYPE_NAME_BITMAP_FONT   "BitmapFont"

◆ KASSET_TYPE_NAME_HEIGHTMAP_TERRAIN

#define KASSET_TYPE_NAME_HEIGHTMAP_TERRAIN   "HeightmapTerrain"

◆ KASSET_TYPE_NAME_IMAGE

#define KASSET_TYPE_NAME_IMAGE   "Image"

◆ KASSET_TYPE_NAME_KSON

#define KASSET_TYPE_NAME_KSON   "Kson"

◆ KASSET_TYPE_NAME_MATERIAL

#define KASSET_TYPE_NAME_MATERIAL   "Material"

◆ KASSET_TYPE_NAME_SCENE

#define KASSET_TYPE_NAME_SCENE   "Scene"

◆ KASSET_TYPE_NAME_SHADER

#define KASSET_TYPE_NAME_SHADER   "Shader"

◆ KASSET_TYPE_NAME_STATIC_MESH

#define KASSET_TYPE_NAME_STATIC_MESH   "StaticMesh"

◆ KASSET_TYPE_NAME_SYSTEM_FONT

#define KASSET_TYPE_NAME_SYSTEM_FONT   "SystemFont"

◆ KASSET_TYPE_NAME_TEXT

#define KASSET_TYPE_NAME_TEXT   "Text"

◆ KPACKAGE_NAME_MAX_LENGTH

#define KPACKAGE_NAME_MAX_LENGTH   128

Typedef Documentation

◆ asset_request_result

◆ binary_asset_header

The primary header for binary assets, to be used for serialization. This should be the first member of the asset-specific binary file header. NOTE: Binary asset headers should be 32-bit aligned.

◆ kasset

typedef struct kasset kasset

a structure meant to be included as the first member in the struct of all asset types for quick casting purposes.

◆ kasset_audio

typedef struct kasset_audio kasset_audio

Represents a Kohi Audio asset.

◆ kasset_binary

typedef struct kasset_binary kasset_binary

◆ kasset_bitmap_font

◆ kasset_bitmap_font_glyph

◆ kasset_bitmap_font_kerning

◆ kasset_bitmap_font_page

◆ kasset_heightmap_terrain

◆ kasset_image

typedef struct kasset_image kasset_image

◆ kasset_importer

Represents the interface point for an importer.

◆ kasset_kson

typedef struct kasset_kson kasset_kson

◆ kasset_material

◆ kasset_metadata

Various metadata included with the asset.

◆ kasset_scene

typedef struct kasset_scene kasset_scene

◆ kasset_shader

typedef struct kasset_shader kasset_shader

Represents a shader asset, typically loaded from disk.

◆ kasset_shader_attribute

◆ kasset_shader_stage

◆ kasset_shader_uniform

Represents a shader uniform within a shader asset.

◆ kasset_static_mesh

Represents a static mesh asset.

◆ kasset_static_mesh_geometry

◆ kasset_system_font

◆ kasset_system_font_face

◆ kasset_text

typedef struct kasset_text kasset_text

◆ kasset_type

typedef enum kasset_type kasset_type

◆ PFN_kasset_importer_import

typedef b8(* PFN_kasset_importer_import) (const struct kasset_importer *self, u64 data_size, const void *data, void *params, struct kasset *out_asset)

Imports an asset according to the provided params and the importer's internal logic. NOTE: Some importers (i.e. .obj for static meshes) can also trigger imports of other assets. Those assets are immediately serialized to disk/package and not returned here though.

Parameters
selfA constant pointer to the importer itself.
data_sizeThe size of the data being imported.
dataA constant pointer to a block of memory containing the data being imported.
paramsA block of memory containing parameters for the import. Optional in general, but required by some importers.
out_assetA pointer to the asset being imported.
Returns
True on success; otherwise false.

◆ PFN_kasset_on_hot_reload

typedef void(* PFN_kasset_on_hot_reload) (const struct vfs_asset_data *asset_data, const struct kasset *asset)

A function pointer typedef to be used to provide the asset system with a callback function when an asset is written to on-disk (i.e. a hot-reload). This process is synchronous.

◆ PFN_kasset_on_result

typedef void(* PFN_kasset_on_result) (asset_request_result result, const struct kasset *asset, void *listener_inst)

A function pointer typedef to be used to provide the asset asset_system with a calback function when asset loading is complete or failed. This process is asynchronus.

Parameters
resultThe result of the asset request.
assetA constant pointer to the asset that is loaded.
listener_instA pointer to the listener, usually passed along with the original request.

Enumeration Type Documentation

◆ asset_request_result

Enumerator
ASSET_REQUEST_RESULT_SUCCESS 

The asset load was a success, including any GPU operations (if required).

ASSET_REQUEST_RESULT_INVALID_PACKAGE 

The specified package name was invalid or not found.

ASSET_REQUEST_RESULT_INVALID_ASSET_TYPE 

The specified asset type was invalid or not found.

ASSET_REQUEST_RESULT_INVALID_NAME 

The specified asset name was invalid or not found.

ASSET_REQUEST_RESULT_PARSE_FAILED 

The asset was found, but failed to load during the parsing stage.

ASSET_REQUEST_RESULT_GPU_UPLOAD_FAILED 

The asset was found, but failed to load during the GPU upload stage.

ASSET_REQUEST_RESULT_INTERNAL_FAILURE 

An internal system failure has occurred. See logs for details.

ASSET_REQUEST_RESULT_NO_HANDLER 

No handler exists for the given asset. See logs for details.

ASSET_REQUEST_RESULT_NO_IMPORTER_FOR_SOURCE_ASSET 

No importer exists for the given asset extension. See logs for details.

ASSET_REQUEST_RESULT_VFS_REQUEST_FAILED 

There was a failure at the VFS level, probably a request for an asset that doesn't exist.

ASSET_REQUEST_RESULT_AUTO_IMPORT_FAILED 

Returned by handlers who attempt (and fail) an auto-import of source asset data when the binary does not exist.

ASSET_REQUEST_RESULT_COUNT 

The total number of result options in this enumeration. Not an actual result value

◆ kasset_type

Enumerator
KASSET_TYPE_UNKNOWN 
KASSET_TYPE_IMAGE 

An image, typically (but not always) used as a texture.

KASSET_TYPE_MATERIAL 
KASSET_TYPE_STATIC_MESH 
KASSET_TYPE_HEIGHTMAP_TERRAIN 
KASSET_TYPE_SCENE 
KASSET_TYPE_BITMAP_FONT 
KASSET_TYPE_SYSTEM_FONT 
KASSET_TYPE_TEXT 
KASSET_TYPE_BINARY 
KASSET_TYPE_KSON 
KASSET_TYPE_VOXEL_TERRAIN 
KASSET_TYPE_SKELETAL_MESH 
KASSET_TYPE_AUDIO 
KASSET_TYPE_SHADER 
KASSET_TYPE_MAX 

Function Documentation

◆ ARRAY_TYPE() [1/3]

ARRAY_TYPE ( kasset_bitmap_font_glyph  )

◆ ARRAY_TYPE() [2/3]

ARRAY_TYPE ( kasset_bitmap_font_kerning  )

◆ ARRAY_TYPE() [3/3]

ARRAY_TYPE ( kasset_bitmap_font_page  )