Kohi Game Engine
|
A system to manage shaders. Respondible for working with the renderer to create, destroy, bind/unbind and set shader properties such as uniforms. More...
Go to the source code of this file.
Data Structures | |
struct | shader_system_config |
Configuration for the shader system. More... | |
struct | shader_uniform |
Represents a single entry in the internal uniform array. More... | |
struct | shader_attribute |
Represents a single shader vertex attribute. More... | |
struct | shader |
Represents a shader on the frontend. More... | |
Typedefs | |
typedef struct shader_system_config | shader_system_config |
Configuration for the shader system. More... | |
typedef enum shader_state | shader_state |
Represents the current state of a given shader. More... | |
typedef struct shader_uniform | shader_uniform |
Represents a single entry in the internal uniform array. More... | |
typedef struct shader_attribute | shader_attribute |
Represents a single shader vertex attribute. More... | |
typedef enum shader_flags | shader_flags |
typedef u32 | shader_flag_bits |
typedef struct shader | shader |
Represents a shader on the frontend. More... | |
Enumerations | |
enum | shader_state { SHADER_STATE_NOT_CREATED , SHADER_STATE_UNINITIALIZED , SHADER_STATE_INITIALIZED } |
Represents the current state of a given shader. More... | |
enum | shader_flags { SHADER_FLAG_NONE = 0x0 , SHADER_FLAG_DEPTH_TEST = 0x1 , SHADER_FLAG_DEPTH_WRITE = 0x2 , SHADER_FLAG_WIREFRAME = 0x4 } |
Functions | |
b8 | shader_system_initialize (u64 *memory_requirement, void *memory, void *config) |
Initializes the shader system using the supplied configuration. NOTE: Call this twice, once to obtain memory requirement (memory = 0) and a second time including allocated memory. More... | |
void | shader_system_shutdown (void *state) |
Shuts down the shader system. More... | |
KAPI b8 | shader_system_create (renderpass *pass, const shader_config *config) |
Creates a new shader with the given config. More... | |
KAPI u32 | shader_system_get_id (const char *shader_name) |
Gets the identifier of a shader by name. More... | |
KAPI shader * | shader_system_get_by_id (u32 shader_id) |
Returns a pointer to a shader with the given identifier. More... | |
KAPI shader * | shader_system_get (const char *shader_name) |
Returns a pointer to a shader with the given name. More... | |
KAPI b8 | shader_system_use (const char *shader_name) |
Uses the shader with the given name. More... | |
KAPI b8 | shader_system_use_by_id (u32 shader_id) |
Uses the shader with the given identifier. More... | |
KAPI u16 | shader_system_uniform_index (shader *s, const char *uniform_name) |
Returns the uniform index for a uniform with the given name, if found. More... | |
KAPI b8 | shader_system_uniform_set (const char *uniform_name, const void *value) |
Sets the value of a uniform with the given name to the supplied value. NOTE: Operates against the currently-used shader. More... | |
KAPI b8 | shader_system_sampler_set (const char *sampler_name, const texture *t) |
Sets the texture of a sampler with the given name to the supplied texture. NOTE: Operates against the currently-used shader. More... | |
KAPI b8 | shader_system_uniform_set_by_index (u16 index, const void *value) |
Sets a uniform value by index. NOTE: Operates against the currently-used shader. More... | |
KAPI b8 | shader_system_sampler_set_by_index (u16 index, const struct texture *t) |
Sets a sampler value by index. NOTE: Operates against the currently-used shader. More... | |
KAPI b8 | shader_system_apply_global (b8 needs_update) |
Applies global-scoped uniforms. NOTE: Operates against the currently-used shader. More... | |
KAPI b8 | shader_system_apply_instance (b8 needs_update) |
Applies instance-scoped uniforms. NOTE: Operates against the currently-used shader. More... | |
KAPI b8 | shader_system_bind_instance (u32 instance_id) |
Binds the instance with the given id for use. Must be done before setting instance-scoped uniforms. NOTE: Operates against the currently-used shader. More... | |
A system to manage shaders. Respondible for working with the renderer to create, destroy, bind/unbind and set shader properties such as uniforms.
typedef struct shader_attribute shader_attribute |
Represents a single shader vertex attribute.
typedef u32 shader_flag_bits |
typedef enum shader_flags shader_flags |
typedef enum shader_state shader_state |
Represents the current state of a given shader.
typedef struct shader_system_config shader_system_config |
Configuration for the shader system.
typedef struct shader_uniform shader_uniform |
Represents a single entry in the internal uniform array.
enum shader_flags |
enum shader_state |
Represents the current state of a given shader.
Applies global-scoped uniforms. NOTE: Operates against the currently-used shader.
needs_update | Indicates if shader internals need to be updated, or just to be bound. |
Applies instance-scoped uniforms. NOTE: Operates against the currently-used shader.
needs_update | Indicates if the shader needs uniform updates or just needs to be bound. |
needs_update | Indicates if shader internals need to be updated, or just to be bound. |
Binds the instance with the given id for use. Must be done before setting instance-scoped uniforms. NOTE: Operates against the currently-used shader.
instance_id | The identifier of the instance to bind. |
KAPI b8 shader_system_create | ( | renderpass * | pass, |
const shader_config * | config | ||
) |
Creates a new shader with the given config.
pass | A pointer to the renderpass to be used with this shader. |
config | The configuration to be used when creating the shader. |
Returns a pointer to a shader with the given name.
shader_name | The name to search for. Case sensitive. |
Returns a pointer to a shader with the given identifier.
shader_id | The shader identifier. |
Gets the identifier of a shader by name.
shader_name | The name of the shader. |
Initializes the shader system using the supplied configuration. NOTE: Call this twice, once to obtain memory requirement (memory = 0) and a second time including allocated memory.
memory_requirement | A pointer to hold the memory requirement of this system in bytes. |
memory | A memory block to be used to hold the state of this system. Pass 0 on the first call to get memory requirement. |
config | The configuration (shader_system_config) to be used when initializing the system. |
Sets the texture of a sampler with the given name to the supplied texture. NOTE: Operates against the currently-used shader.
uniform_name | The name of the uniform to be set. |
t | A pointer to the texture to be set. |
Sets a sampler value by index. NOTE: Operates against the currently-used shader.
index | The index of the uniform. |
value | A pointer to the texture to be set. |
void shader_system_shutdown | ( | void * | state | ) |
Shuts down the shader system.
state | A pointer to the system state. |
Returns the uniform index for a uniform with the given name, if found.
s | A pointer to the shader to obtain the index from. |
uniform_name | The name of the uniform to search for. |
Sets the value of a uniform with the given name to the supplied value. NOTE: Operates against the currently-used shader.
uniform_name | The name of the uniform to be set. |
value | The value to be set. |
Sets a uniform value by index. NOTE: Operates against the currently-used shader.
index | The index of the uniform. |
value | The value of the uniform. |
Uses the shader with the given name.
shader_name | The name of the shader to use. Case sensitive. |