Kohi Game Engine
resource_types.h File Reference

This file contains the types for common resources the engine uses. More...

#include "math/math_types.h"

Go to the source code of this file.

Data Structures

struct  resource_header
 The header data for binary resource types. More...
 
struct  resource
 A generic structure for a resource. All resource loaders load data into these. More...
 
struct  image_resource_data
 A structure to hold image resource data. More...
 
struct  image_resource_params
 Parameters used when loading an image. More...
 
struct  texture
 Represents a texture. More...
 
struct  texture_map
 A structure which maps a texture, use and other properties. More...
 
struct  font_glyph
 
struct  font_kerning
 
struct  font_data
 
struct  bitmap_font_page
 
struct  bitmap_font_resource_data
 
struct  system_font_face
 
struct  system_font_resource_data
 
struct  geometry
 Represents actual geometry in the world. Typically (but not always, depending on use) paired with a material. More...
 
struct  mesh_config
 
struct  mesh
 
struct  shader_attribute_config
 Configuration for an attribute. More...
 
struct  shader_uniform_config
 Configuration for a uniform. More...
 
struct  shader_config
 Configuration for a shader. Typically created and destroyed by the shader resource loader, and set to the properties found in a .shadercfg resource file. More...
 
struct  material_config_prop
 
struct  material_map
 
struct  material_config
 
struct  material_phong_properties
 
struct  material_ui_properties
 
struct  material_terrain_properties
 
struct  material
 A material, which represents various properties of a surface in the world such as texture, colour, bumpiness, shininess and more. More...
 
struct  skybox_simple_scene_config
 
struct  directional_light_simple_scene_config
 
struct  point_light_simple_scene_config
 
struct  mesh_simple_scene_config
 
struct  terrain_simple_scene_config
 
struct  simple_scene_config
 

Macros

#define TERRAIN_MAX_MATERIAL_COUNT   4
 
#define RESOURCE_MAGIC   0xcafebabe
 A magic number indicating the file as a kohi binary file. More...
 
#define TEXTURE_NAME_MAX_LENGTH   512
 The maximum length of a texture name. More...
 
#define MATERIAL_NAME_MAX_LENGTH   256
 The maximum length of a material name. More...
 
#define GEOMETRY_NAME_MAX_LENGTH   256
 The maximum length of a geometry name. More...
 

Typedefs

typedef enum resource_type resource_type
 Pre-defined resource types. More...
 
typedef struct resource_header resource_header
 The header data for binary resource types. More...
 
typedef struct resource resource
 A generic structure for a resource. All resource loaders load data into these. More...
 
typedef struct image_resource_data image_resource_data
 A structure to hold image resource data. More...
 
typedef struct image_resource_params image_resource_params
 Parameters used when loading an image. More...
 
typedef enum face_cull_mode face_cull_mode
 Determines face culling mode during rendering. More...
 
typedef enum primitive_topology_type primitive_topology_type
 
typedef enum texture_flag texture_flag
 
typedef u8 texture_flag_bits
 Holds bit flags for textures.. More...
 
typedef enum texture_type texture_type
 Represents various types of textures. More...
 
typedef struct texture texture
 Represents a texture. More...
 
typedef enum texture_filter texture_filter
 Represents supported texture filtering modes. More...
 
typedef enum texture_repeat texture_repeat
 
typedef struct texture_map texture_map
 A structure which maps a texture, use and other properties. More...
 
typedef struct font_glyph font_glyph
 
typedef struct font_kerning font_kerning
 
typedef enum font_type font_type
 
typedef struct font_data font_data
 
typedef struct bitmap_font_page bitmap_font_page
 
typedef struct bitmap_font_resource_data bitmap_font_resource_data
 
typedef struct system_font_face system_font_face
 
typedef struct system_font_resource_data system_font_resource_data
 
typedef struct geometry geometry
 Represents actual geometry in the world. Typically (but not always, depending on use) paired with a material. More...
 
typedef struct mesh_config mesh_config
 
typedef struct mesh mesh
 
typedef enum shader_stage shader_stage
 Shader stages available in the system. More...
 
typedef enum shader_attribute_type shader_attribute_type
 Available attribute types. More...
 
typedef enum shader_uniform_type shader_uniform_type
 Available uniform types. More...
 
typedef enum shader_scope shader_scope
 Defines shader scope, which indicates how often it gets updated. More...
 
typedef struct shader_attribute_config shader_attribute_config
 Configuration for an attribute. More...
 
typedef struct shader_uniform_config shader_uniform_config
 Configuration for a uniform. More...
 
typedef struct shader_config shader_config
 Configuration for a shader. Typically created and destroyed by the shader resource loader, and set to the properties found in a .shadercfg resource file. More...
 
typedef enum material_type material_type
 
typedef struct material_config_prop material_config_prop
 
typedef struct material_map material_map
 
typedef struct material_config material_config
 
typedef struct material_phong_properties material_phong_properties
 
typedef struct material_ui_properties material_ui_properties
 
typedef struct material_terrain_properties material_terrain_properties
 
typedef struct material material
 A material, which represents various properties of a surface in the world such as texture, colour, bumpiness, shininess and more. More...
 
typedef struct skybox_simple_scene_config skybox_simple_scene_config
 
typedef struct directional_light_simple_scene_config directional_light_simple_scene_config
 
typedef struct point_light_simple_scene_config point_light_simple_scene_config
 
typedef struct mesh_simple_scene_config mesh_simple_scene_config
 
typedef struct terrain_simple_scene_config terrain_simple_scene_config
 
typedef struct simple_scene_config simple_scene_config
 

Enumerations

enum  resource_type {
  RESOURCE_TYPE_TEXT , RESOURCE_TYPE_BINARY , RESOURCE_TYPE_IMAGE , RESOURCE_TYPE_MATERIAL ,
  RESOURCE_TYPE_SHADER , RESOURCE_TYPE_MESH , RESOURCE_TYPE_BITMAP_FONT , RESOURCE_TYPE_SYSTEM_FONT ,
  RESOURCE_TYPE_SIMPLE_SCENE , RESOURCE_TYPE_TERRAIN , RESOURCE_TYPE_AUDIO , RESOURCE_TYPE_CUSTOM
}
 Pre-defined resource types. More...
 
enum  face_cull_mode { FACE_CULL_MODE_NONE = 0x0 , FACE_CULL_MODE_FRONT = 0x1 , FACE_CULL_MODE_BACK = 0x2 , FACE_CULL_MODE_FRONT_AND_BACK = 0x3 }
 Determines face culling mode during rendering. More...
 
enum  primitive_topology_type {
  PRIMITIVE_TOPOLOGY_TYPE_NONE = 0x00 , PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE_LIST = 0x01 , PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE_STRIP = 0x02 , PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE_FAN = 0x04 ,
  PRIMITIVE_TOPOLOGY_TYPE_LINE_LIST = 0x08 , PRIMITIVE_TOPOLOGY_TYPE_LINE_STRIP = 0x10 , PRIMITIVE_TOPOLOGY_TYPE_POINT_LIST = 0x20 , PRIMITIVE_TOPOLOGY_TYPE_MAX = PRIMITIVE_TOPOLOGY_TYPE_POINT_LIST << 1
}
 
enum  texture_flag { TEXTURE_FLAG_HAS_TRANSPARENCY = 0x1 , TEXTURE_FLAG_IS_WRITEABLE = 0x2 , TEXTURE_FLAG_IS_WRAPPED = 0x4 , TEXTURE_FLAG_DEPTH = 0x8 }
 
enum  texture_type { TEXTURE_TYPE_2D , TEXTURE_TYPE_CUBE }
 Represents various types of textures. More...
 
enum  texture_filter { TEXTURE_FILTER_MODE_NEAREST = 0x0 , TEXTURE_FILTER_MODE_LINEAR = 0x1 }
 Represents supported texture filtering modes. More...
 
enum  texture_repeat { TEXTURE_REPEAT_REPEAT = 0x1 , TEXTURE_REPEAT_MIRRORED_REPEAT = 0x2 , TEXTURE_REPEAT_CLAMP_TO_EDGE = 0x3 , TEXTURE_REPEAT_CLAMP_TO_BORDER = 0x4 }
 
enum  font_type { FONT_TYPE_BITMAP , FONT_TYPE_SYSTEM }
 
enum  shader_stage { SHADER_STAGE_VERTEX = 0x00000001 , SHADER_STAGE_GEOMETRY = 0x00000002 , SHADER_STAGE_FRAGMENT = 0x00000004 , SHADER_STAGE_COMPUTE = 0x0000008 }
 Shader stages available in the system. More...
 
enum  shader_attribute_type {
  SHADER_ATTRIB_TYPE_FLOAT32 = 0U , SHADER_ATTRIB_TYPE_FLOAT32_2 = 1U , SHADER_ATTRIB_TYPE_FLOAT32_3 = 2U , SHADER_ATTRIB_TYPE_FLOAT32_4 = 3U ,
  SHADER_ATTRIB_TYPE_MATRIX_4 = 4U , SHADER_ATTRIB_TYPE_INT8 = 5U , SHADER_ATTRIB_TYPE_UINT8 = 6U , SHADER_ATTRIB_TYPE_INT16 = 7U ,
  SHADER_ATTRIB_TYPE_UINT16 = 8U , SHADER_ATTRIB_TYPE_INT32 = 9U , SHADER_ATTRIB_TYPE_UINT32 = 10U
}
 Available attribute types. More...
 
enum  shader_uniform_type {
  SHADER_UNIFORM_TYPE_FLOAT32 = 0U , SHADER_UNIFORM_TYPE_FLOAT32_2 = 1U , SHADER_UNIFORM_TYPE_FLOAT32_3 = 2U , SHADER_UNIFORM_TYPE_FLOAT32_4 = 3U ,
  SHADER_UNIFORM_TYPE_INT8 = 4U , SHADER_UNIFORM_TYPE_UINT8 = 5U , SHADER_UNIFORM_TYPE_INT16 = 6U , SHADER_UNIFORM_TYPE_UINT16 = 7U ,
  SHADER_UNIFORM_TYPE_INT32 = 8U , SHADER_UNIFORM_TYPE_UINT32 = 9U , SHADER_UNIFORM_TYPE_MATRIX_4 = 10U , SHADER_UNIFORM_TYPE_SAMPLER = 11U ,
  SHADER_UNIFORM_TYPE_CUSTOM = 255U
}
 Available uniform types. More...
 
enum  shader_scope { SHADER_SCOPE_GLOBAL = 0 , SHADER_SCOPE_INSTANCE = 1 , SHADER_SCOPE_LOCAL = 2 }
 Defines shader scope, which indicates how often it gets updated. More...
 
enum  material_type {
  MATERIAL_TYPE_UNKNOWN = 0 , MATERIAL_TYPE_PHONG = 1 , MATERIAL_TYPE_PBR = 2 , MATERIAL_TYPE_UI = 3 ,
  MATERIAL_TYPE_TERRAIN = 4 , MATERIAL_TYPE_CUSTOM = 99
}
 

Detailed Description

This file contains the types for common resources the engine uses.

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

Macro Definition Documentation

◆ GEOMETRY_NAME_MAX_LENGTH

#define GEOMETRY_NAME_MAX_LENGTH   256

The maximum length of a geometry name.

◆ MATERIAL_NAME_MAX_LENGTH

#define MATERIAL_NAME_MAX_LENGTH   256

The maximum length of a material name.

◆ RESOURCE_MAGIC

#define RESOURCE_MAGIC   0xcafebabe

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

◆ TERRAIN_MAX_MATERIAL_COUNT

#define TERRAIN_MAX_MATERIAL_COUNT   4

◆ TEXTURE_NAME_MAX_LENGTH

#define TEXTURE_NAME_MAX_LENGTH   512

The maximum length of a texture name.

Typedef Documentation

◆ bitmap_font_page

◆ bitmap_font_resource_data

◆ directional_light_simple_scene_config

◆ face_cull_mode

Determines face culling mode during rendering.

◆ font_data

typedef struct font_data font_data

◆ font_glyph

typedef struct font_glyph font_glyph

◆ font_kerning

typedef struct font_kerning font_kerning

◆ font_type

typedef enum font_type font_type

◆ geometry

typedef struct geometry geometry

Represents actual geometry in the world. Typically (but not always, depending on use) paired with a material.

◆ image_resource_data

A structure to hold image resource data.

◆ image_resource_params

Parameters used when loading an image.

◆ material

typedef struct material material

A material, which represents various properties of a surface in the world such as texture, colour, bumpiness, shininess and more.

◆ material_config

◆ material_config_prop

◆ material_map

typedef struct material_map material_map

◆ material_phong_properties

◆ material_terrain_properties

◆ material_type

◆ material_ui_properties

◆ mesh

typedef struct mesh mesh

◆ mesh_config

typedef struct mesh_config mesh_config

◆ mesh_simple_scene_config

◆ point_light_simple_scene_config

◆ primitive_topology_type

◆ resource

typedef struct resource resource

A generic structure for a resource. All resource loaders load data into these.

◆ resource_header

The header data for binary resource types.

◆ resource_type

Pre-defined resource types.

◆ shader_attribute_config

Configuration for an attribute.

◆ shader_attribute_type

Available attribute types.

◆ shader_config

typedef struct shader_config shader_config

Configuration for a shader. Typically created and destroyed by the shader resource loader, and set to the properties found in a .shadercfg resource file.

◆ shader_scope

typedef enum shader_scope shader_scope

Defines shader scope, which indicates how often it gets updated.

◆ shader_stage

typedef enum shader_stage shader_stage

Shader stages available in the system.

◆ shader_uniform_config

Configuration for a uniform.

◆ shader_uniform_type

Available uniform types.

◆ simple_scene_config

◆ skybox_simple_scene_config

◆ system_font_face

◆ system_font_resource_data

◆ terrain_simple_scene_config

◆ texture

typedef struct texture texture

Represents a texture.

◆ texture_filter

Represents supported texture filtering modes.

◆ texture_flag

typedef enum texture_flag texture_flag

◆ texture_flag_bits

Holds bit flags for textures..

◆ texture_map

typedef struct texture_map texture_map

A structure which maps a texture, use and other properties.

◆ texture_repeat

◆ texture_type

typedef enum texture_type texture_type

Represents various types of textures.

Enumeration Type Documentation

◆ face_cull_mode

Determines face culling mode during rendering.

Enumerator
FACE_CULL_MODE_NONE 

No faces are culled.

FACE_CULL_MODE_FRONT 

Only front faces are culled.

FACE_CULL_MODE_BACK 

Only back faces are culled.

FACE_CULL_MODE_FRONT_AND_BACK 

Both front and back faces are culled.

◆ font_type

enum font_type
Enumerator
FONT_TYPE_BITMAP 
FONT_TYPE_SYSTEM 

◆ material_type

Enumerator
MATERIAL_TYPE_UNKNOWN 
MATERIAL_TYPE_PHONG 
MATERIAL_TYPE_PBR 
MATERIAL_TYPE_UI 
MATERIAL_TYPE_TERRAIN 
MATERIAL_TYPE_CUSTOM 

◆ primitive_topology_type

Enumerator
PRIMITIVE_TOPOLOGY_TYPE_NONE 

Topology type not defined. Not valid for shader creation.

PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE_LIST 

A list of triangles. The default if nothing is defined.

PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE_STRIP 
PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE_FAN 
PRIMITIVE_TOPOLOGY_TYPE_LINE_LIST 
PRIMITIVE_TOPOLOGY_TYPE_LINE_STRIP 
PRIMITIVE_TOPOLOGY_TYPE_POINT_LIST 
PRIMITIVE_TOPOLOGY_TYPE_MAX 

◆ resource_type

Pre-defined resource types.

Enumerator
RESOURCE_TYPE_TEXT 

Text resource type.

RESOURCE_TYPE_BINARY 

Binary resource type.

RESOURCE_TYPE_IMAGE 

Image resource type.

RESOURCE_TYPE_MATERIAL 

Material resource type.

RESOURCE_TYPE_SHADER 

Shader resource type (or more accurately shader config).

RESOURCE_TYPE_MESH 

Mesh resource type (collection of geometry configs).

RESOURCE_TYPE_BITMAP_FONT 

Bitmap font resource type.

RESOURCE_TYPE_SYSTEM_FONT 

System font resource type.

RESOURCE_TYPE_SIMPLE_SCENE 

Simple scene resource type.

RESOURCE_TYPE_TERRAIN 

Terrain resource type.

RESOURCE_TYPE_AUDIO 

Audio resource type.

RESOURCE_TYPE_CUSTOM 

Custom resource type. Used by loaders outside the core engine.

◆ shader_attribute_type

Available attribute types.

Enumerator
SHADER_ATTRIB_TYPE_FLOAT32 
SHADER_ATTRIB_TYPE_FLOAT32_2 
SHADER_ATTRIB_TYPE_FLOAT32_3 
SHADER_ATTRIB_TYPE_FLOAT32_4 
SHADER_ATTRIB_TYPE_MATRIX_4 
SHADER_ATTRIB_TYPE_INT8 
SHADER_ATTRIB_TYPE_UINT8 
SHADER_ATTRIB_TYPE_INT16 
SHADER_ATTRIB_TYPE_UINT16 
SHADER_ATTRIB_TYPE_INT32 
SHADER_ATTRIB_TYPE_UINT32 

◆ shader_scope

Defines shader scope, which indicates how often it gets updated.

Enumerator
SHADER_SCOPE_GLOBAL 

Global shader scope, generally updated once per frame.

SHADER_SCOPE_INSTANCE 

Instance shader scope, generally updated "per-instance" of the shader.

SHADER_SCOPE_LOCAL 

Local shader scope, generally updated per-object.

◆ shader_stage

Shader stages available in the system.

Enumerator
SHADER_STAGE_VERTEX 
SHADER_STAGE_GEOMETRY 
SHADER_STAGE_FRAGMENT 
SHADER_STAGE_COMPUTE 

◆ shader_uniform_type

Available uniform types.

Enumerator
SHADER_UNIFORM_TYPE_FLOAT32 
SHADER_UNIFORM_TYPE_FLOAT32_2 
SHADER_UNIFORM_TYPE_FLOAT32_3 
SHADER_UNIFORM_TYPE_FLOAT32_4 
SHADER_UNIFORM_TYPE_INT8 
SHADER_UNIFORM_TYPE_UINT8 
SHADER_UNIFORM_TYPE_INT16 
SHADER_UNIFORM_TYPE_UINT16 
SHADER_UNIFORM_TYPE_INT32 
SHADER_UNIFORM_TYPE_UINT32 
SHADER_UNIFORM_TYPE_MATRIX_4 
SHADER_UNIFORM_TYPE_SAMPLER 
SHADER_UNIFORM_TYPE_CUSTOM 

◆ texture_filter

Represents supported texture filtering modes.

Enumerator
TEXTURE_FILTER_MODE_NEAREST 

Nearest-neighbor filtering.

TEXTURE_FILTER_MODE_LINEAR 

Linear (i.e. bilinear) filtering.

◆ texture_flag

Enumerator
TEXTURE_FLAG_HAS_TRANSPARENCY 

Indicates if the texture has transparency.

TEXTURE_FLAG_IS_WRITEABLE 

Indicates if the texture can be written (rendered) to.

TEXTURE_FLAG_IS_WRAPPED 

Indicates if the texture was created via wrapping vs traditional creation.

TEXTURE_FLAG_DEPTH 

Indicates the texture is a depth texture.

◆ texture_repeat

Enumerator
TEXTURE_REPEAT_REPEAT 
TEXTURE_REPEAT_MIRRORED_REPEAT 
TEXTURE_REPEAT_CLAMP_TO_EDGE 
TEXTURE_REPEAT_CLAMP_TO_BORDER 

◆ texture_type

Represents various types of textures.

Enumerator
TEXTURE_TYPE_2D 

A standard two-dimensional texture.

TEXTURE_TYPE_CUBE 

A cube texture, used for cubemaps.