Kohi Game Engine
renderer_frontend.h File Reference

The renderer frontend, which is the only thing the rest of the engine sees. This is responsible for transferring any data to and from the renderer backend in an agnostic way. More...

#include <defines.h>
#include <math/geometry.h>
#include <strings/kname.h>
#include "core/frame_data.h"
#include "core_render_types.h"
#include "math/math_types.h"
#include "renderer_types.h"

Go to the source code of this file.

Data Structures

struct  renderer_system_config
 

Typedefs

typedef struct renderer_system_config renderer_system_config
 

Functions

b8 renderer_system_deserialize_config (const char *config_str, renderer_system_config *out_config)
 
void renderer_system_destroy_config (renderer_system_config *config)
 
KAPI b8 renderer_system_initialize (u64 *memory_requirement, struct renderer_system_state *state, const renderer_system_config *config)
 Initializes the renderer frontend/system. Should be called twice - once to obtain the memory requirement (passing state=0), and a second time passing allocated memory to state. More...
 
KAPI void renderer_system_shutdown (struct renderer_system_state *state)
 Shuts the renderer system/frontend down. More...
 
KAPI u16 renderer_system_frame_number_get (struct renderer_system_state *state)
 
KAPI b8 renderer_on_window_created (struct renderer_system_state *state, struct kwindow *window)
 
KAPI void renderer_on_window_destroyed (struct renderer_system_state *state, struct kwindow *window)
 
KAPI void renderer_on_window_resized (struct renderer_system_state *state, const struct kwindow *window)
 Handles window resize events. More...
 
KAPI void renderer_begin_debug_label (const char *label_text, vec3 colour)
 Begins the marking of a section of commands, listed under a given name and colour. Becomes a no-op in non-debug builds. NOTE: Each renderer backend will have different or possibly non-existant implementations of this. More...
 
KAPI void renderer_end_debug_label (void)
 Ends the last debug section of commands. Becomes a no-op in non-debug builds. NOTE: Each renderer backend will have different or possibly non-existant implementations of this. More...
 
KAPI b8 renderer_frame_prepare (struct renderer_system_state *state, struct frame_data *p_frame_data)
 Performs setup routines required at the start of a frame. More...
 
KAPI b8 renderer_frame_prepare_window_surface (struct renderer_system_state *state, struct kwindow *window, struct frame_data *p_frame_data)
 Prepares a window's surface for drawing. More...
 
KAPI b8 renderer_frame_command_list_begin (struct renderer_system_state *state, struct frame_data *p_frame_data)
 Begins a render. There must be at least one of these and a matching end per frame. More...
 
KAPI b8 renderer_frame_command_list_end (struct renderer_system_state *state, struct frame_data *p_frame_data)
 Ends a render. More...
 
KAPI b8 renderer_frame_submit (struct renderer_system_state *state, struct frame_data *p_frame_data)
 
KAPI b8 renderer_frame_present (struct renderer_system_state *state, struct kwindow *window, struct frame_data *p_frame_data)
 Performs routines required to draw a frame, such as presentation. Should only be called after a successful return of begin_frame. More...
 
KAPI void renderer_viewport_set (rect_2di rect)
 Sets the renderer viewport to the given rectangle. More...
 
KAPI void renderer_viewport_reset (void)
 Resets the viewport to the default, which matches the application window. More...
 
KAPI void renderer_scissor_set (rect_2di rect)
 Sets the renderer scissor to the given rectangle. More...
 
KAPI void renderer_scissor_reset (void)
 Resets the scissor to the default, which matches the application window. More...
 
KAPI void renderer_winding_set (renderer_winding winding)
 Set the renderer to use the given winding direction. More...
 
KAPI void renderer_cull_mode_set (renderer_cull_mode cull_mode)
 Set the renderer to use the given cull mode. More...
 
KAPI void renderer_set_stencil_test_enabled (b8 enabled)
 Set stencil testing enabled/disabled. More...
 
KAPI void renderer_set_stencil_reference (u32 reference)
 Set the stencil reference for testing. More...
 
KAPI void renderer_set_depth_test_enabled (b8 enabled)
 Set depth testing enabled/disabled. More...
 
KAPI void renderer_set_depth_write_enabled (b8 enabled)
 Set depth write enabled/disabled. More...
 
KAPI void renderer_set_depth_bias (f32 constant_factor, f32 clamp, f32 slope_factor)
 Sets depth bias factors and clamp dynamically. More...
 
KAPI void renderer_set_depth_bias_enabled (b8 enabled)
 Enables/disables depth bias. More...
 
KAPI void renderer_set_stencil_op (renderer_stencil_op fail_op, renderer_stencil_op pass_op, renderer_stencil_op depth_fail_op, renderer_compare_op compare_op)
 Set stencil operation. More...
 
KAPI void renderer_begin_rendering (struct renderer_system_state *state, struct frame_data *p_frame_data, rect_2di render_area, u32 colour_target_count, ktexture *colour_targets, ktexture depth_stencil_target, u32 depth_stencil_layer)
 Begins rendering against the given targets. More...
 
KAPI void renderer_end_rendering (struct renderer_system_state *state, struct frame_data *p_frame_data)
 
KAPI void renderer_set_stencil_compare_mask (u32 compare_mask)
 Set stencil compare mask. More...
 
KAPI void renderer_set_stencil_write_mask (u32 write_mask)
 Set stencil write mask. More...
 
KAPI b8 renderer_texture_resources_acquire (struct renderer_system_state *state, ktexture t, kname name, ktexture_type type, u32 width, u32 height, u8 channel_count, u8 mip_levels, u16 array_size, ktexture_flag_bits flags)
 
KAPI void renderer_texture_resources_release (struct renderer_system_state *state, ktexture t)
 
KAPI b8 renderer_texture_resize (struct renderer_system_state *state, ktexture t, u32 new_width, u32 new_height)
 Resizes a texture. There is no check at this level to see if the texture is writeable. Internal resources are destroyed and re-created at the new resolution. Data is lost and would need to be reloaded. More...
 
KAPI b8 renderer_texture_write_data (struct renderer_system_state *state, ktexture t, u32 offset, u32 size, const u8 *pixels)
 Writes the given data to the provided texture. More...
 
KAPI b8 renderer_texture_read_data (struct renderer_system_state *state, ktexture t, u32 offset, u32 size, u8 **out_memory)
 Reads the given data from the provided texture. More...
 
KAPI b8 renderer_texture_read_pixel (struct renderer_system_state *state, ktexture t, u32 x, u32 y, u8 **out_rgba)
 Reads a pixel from the provided texture at the given x/y coordinate. More...
 
KAPI void renderer_default_texture_register (struct renderer_system_state *state, renderer_default_texture default_texture, ktexture t)
 Registers a texture with the given handle to the default texture slot specified. More...
 
KAPI ktexture renderer_default_texture_get (struct renderer_system_state *state, renderer_default_texture default_texture)
 Gets a texture handle with the default texture slot specified. More...
 
KAPI b8 renderer_geometry_upload (kgeometry *geometry)
 Acquires GPU resources and uploads geometry data. More...
 
KAPI void renderer_geometry_vertex_update (kgeometry *g, u32 offset, u32 vertex_count, void *vertices, b8 include_in_frame_workload)
 Updates vertex data in the given geometry with the provided data in the given range. More...
 
KAPI void renderer_geometry_destroy (kgeometry *geometry)
 Destroys the given geometry, releasing GPU resources. NOTE: Does NOT release index and vertex data arrays. Call geometry_destroy() to do that. More...
 
KAPI void renderer_geometry_draw (geometry_render_data *data)
 Draws the given geometry. More...
 
KAPI void renderer_clear_colour_set (struct renderer_system_state *state, vec4 colour)
 Sets the value to be used on the colour buffer clear. More...
 
KAPI void renderer_clear_depth_set (struct renderer_system_state *state, f32 depth)
 Sets the value to be used on the depth buffer clear. More...
 
KAPI void renderer_clear_stencil_set (struct renderer_system_state *state, u32 stencil)
 Sets the value to be used on the stencil buffer clear. More...
 
KAPI b8 renderer_clear_colour (struct renderer_system_state *state, ktexture t)
 Clears the colour buffer using the previously set clear colour. More...
 
KAPI b8 renderer_clear_depth_stencil (struct renderer_system_state *state, ktexture t)
 Clears the depth/stencil buffer using the previously set clear values. More...
 
KAPI void renderer_colour_texture_prepare_for_present (struct renderer_system_state *state, ktexture t)
 Performs operations required on the supplied colour texture before presentation. More...
 
KAPI void renderer_texture_prepare_for_sampling (struct renderer_system_state *state, ktexture t, ktexture_flag_bits flags)
 Performs operations required on the supplied texture before being used for sampling. More...
 
KAPI b8 renderer_shader_create (struct renderer_system_state *state, kshader shader, kname name, shader_flags flags, primitive_topology_type_bits topology_types, primitive_topology_type default_topology, u8 colour_attachment_count, kpixel_format *colour_attachment_formats, kpixel_format depth_attachment_format, kpixel_format stencil_attachment_format, u8 pipeline_count, shader_pipeline_config *pipelines, u8 binding_set_count, const shader_binding_set_config *binding_sets)
 Creates internal shader resources using the provided parameters. More...
 
KAPI void renderer_shader_destroy (struct renderer_system_state *state, kshader shader)
 Destroys the given shader and releases any resources held by it. More...
 
KAPI b8 renderer_shader_reload (struct renderer_system_state *state, kshader shader, u8 pipeline_count, shader_pipeline_config *pipelines)
 Reloads the internals of the given shader. More...
 
KAPI b8 renderer_shader_use (struct renderer_system_state *state, kshader shader, u8 vertex_layout_index)
 Uses the given shader, activating it for updates to attributes, uniforms and such, and for use in draw calls. Uses the default topology configured by the shader. More...
 
KAPI b8 renderer_shader_use_with_topology (struct renderer_system_state *state, kshader shader, primitive_topology_type type, u8 vertex_layout_index)
 Uses the given shader, activating it for updates to attributes, uniforms and such, and for use in draw calls using the provided topology. More...
 
KAPI b8 renderer_shader_supports_wireframe (struct renderer_system_state *state, kshader shader)
 Determines if the given shader supports wireframe mode. More...
 
KAPI b8 renderer_shader_flag_get (struct renderer_system_state *state, kshader shader, shader_flags flag)
 Indicates if the given shader flag is set. More...
 
KAPI void renderer_shader_flag_set (struct renderer_system_state *state, kshader shader, shader_flags flag, b8 enabled)
 Sets the given shader flag. More...
 
KAPI void renderer_shader_set_immediate_data (struct renderer_system_state *state, kshader shader, const void *data, u8 size)
 
KAPI void renderer_shader_set_binding_data (struct renderer_system_state *state, kshader shader, u8 binding_set, u32 instance_id, u8 binding_index, u64 offset, void *data, u64 size)
 
KAPI void renderer_shader_set_binding_texture (struct renderer_system_state *state, kshader shader, u8 binding_set, u32 instance_id, u8 binding_index, u8 array_index, ktexture texture)
 
KAPI void renderer_shader_set_binding_sampler (struct renderer_system_state *state, kshader shader, u8 binding_set, u32 instance_id, u8 binding_index, u8 array_index, ksampler_backend sampler)
 
KAPI b8 renderer_shader_apply_binding_set (struct renderer_system_state *state, kshader shader, u8 binding_set, u32 instance_id)
 
KAPI u32 renderer_shader_acquire_binding_set_instance (struct renderer_system_state *state, kshader shader, u8 binding_set)
 
KAPI void renderer_shader_release_binding_set_instance (struct renderer_system_state *state, kshader shader, u8 binding_set, u32 instance_id)
 
KAPI u32 renderer_shader_binding_set_get_max_instance_count (struct renderer_system_state *state, kshader shader, u8 binding_set)
 
KAPI ksampler_backend renderer_generic_sampler_get (struct renderer_system_state *state, shader_generic_sampler sampler)
 Gets a handle to a generic sampler of the given type. More...
 
KAPI ksampler_backend renderer_sampler_acquire (struct renderer_system_state *state, kname name, texture_filter filter, texture_repeat repeat, f32 anisotropy)
 Acquires a internal sampler and returns a handle to it. More...
 
KAPI void renderer_sampler_release (struct renderer_system_state *state, ksampler_backend *sampler)
 Releases the internal sampler for the given handle. More...
 
KAPI b8 renderer_sampler_refresh (struct renderer_system_state *state, ksampler_backend *sampler, texture_filter filter, texture_repeat repeat, f32 anisotropy, u32 mip_levels)
 Recreates the internal sampler pointed to by the given handle. Modifies the handle. More...
 
KAPI kname renderer_sampler_name_get (struct renderer_system_state *state, ksampler_backend sampler)
 Attempts to obtain the name of a sampler with the given handle. Returns INVALID_KNAME if not found. More...
 
KAPI b8 renderer_is_multithreaded (void)
 Indicates if the renderer is capable of multi-threading. More...
 
KAPI b8 renderer_flag_enabled_get (renderer_config_flags flag)
 Indicates if the provided renderer flag is enabled. If multiple flags are passed, all must be set for this to return true. More...
 
KAPI void renderer_flag_enabled_set (renderer_config_flags flag, b8 enabled)
 Sets whether the included flag(s) are enabled or not. If multiple flags are passed, multiple are set at once. More...
 
KAPI f32 renderer_max_anisotropy_get (void)
 Obtains the max anisotropy level available from the renderer. 0 means not available. More...
 
KAPI krenderbuffer renderer_renderbuffer_create (struct renderer_system_state *state, kname name, renderbuffer_type type, u64 total_size, renderbuffer_track_type track_type, renderbuffer_flags)
 Creates a new renderbuffer to hold data for a given purpose/use. Backed by a renderer-backend-specific buffer resource. More...
 
KAPI void renderer_renderbuffer_destroy (struct renderer_system_state *state, krenderbuffer buffer)
 Destroys the given renderbuffer. More...
 
KAPI b8 renderer_renderbuffer_bind (struct renderer_system_state *state, krenderbuffer buffer, u64 offset, u32 binding_index)
 Binds the given buffer at the provided offset. More...
 
KAPI b8 renderer_renderbuffer_unbind (struct renderer_system_state *state, krenderbuffer buffer)
 Unbinds the given buffer. More...
 
KAPI void renderer_renderbuffer_map_memory (struct renderer_system_state *state, krenderbuffer buffer, u64 offset, u64 size)
 Maps memory from the given buffer in the provided range to a block of memory and returns it. This memory should be considered invalid once unmapped. More...
 
KAPI void renderer_renderbuffer_unmap_memory (struct renderer_system_state *state, krenderbuffer buffer, u64 offset, u64 size)
 Unmaps memory from the given buffer in the provided range to a block of memory. This memory should be considered invalid once unmapped. More...
 
KAPI void * renderer_renderbuffer_get_mapped_memory (struct renderer_system_state *state, krenderbuffer buffer)
 Obtains the mapped memory of the buffer, if mapped. This memory should be considered invalid once unmapped. More...
 
KAPI b8 renderer_renderbuffer_flush (struct renderer_system_state *state, krenderbuffer buffer, u64 offset, u64 size)
 Flushes buffer memory at the given range. Should be done after a write. More...
 
KAPI b8 renderer_renderbuffer_read (struct renderer_system_state *state, krenderbuffer buffer, u64 offset, u64 size, void **out_memory)
 Reads memory from the provided buffer at the given range to the output variable. More...
 
KAPI b8 renderer_renderbuffer_resize (struct renderer_system_state *state, krenderbuffer buffer, u64 new_total_size)
 Resizes the given buffer to new_total_size. new_total_size must be greater than the current buffer size. Data from the old internal buffer is copied over. More...
 
KAPI b8 renderer_renderbuffer_allocate (struct renderer_system_state *state, krenderbuffer buffer, u64 size, u64 *out_offset)
 Attempts to allocate memory from the given buffer. Should only be used on buffers that were created with use_freelist = true. More...
 
KAPI b8 renderer_renderbuffer_free (struct renderer_system_state *state, krenderbuffer buffer, u64 size, u64 offset)
 Frees memory from the given buffer. More...
 
KAPI b8 renderer_renderbuffer_clear (struct renderer_system_state *state, krenderbuffer buffer, b8 zero_memory)
 Clears the given buffer. Internally, resets the free list if one is used. More...
 
KAPI b8 renderer_renderbuffer_load_range (struct renderer_system_state *state, krenderbuffer buffer, u64 offset, u64 size, const void *data, b8 include_in_frame_workload)
 Loads provided data into the specified rage of the given buffer. More...
 
KAPI b8 renderer_renderbuffer_copy_range (struct renderer_system_state *state, krenderbuffer source, u64 source_offset, krenderbuffer dest, u64 dest_offset, u64 size, b8 include_in_frame_workload)
 Copies data in the specified rage fron the source to the destination buffer. More...
 
KAPI b8 renderer_renderbuffer_draw (struct renderer_system_state *state, krenderbuffer buffer, u64 offset, u32 element_count, u32 binding_index, b8 bind_only)
 Attempts to draw the contents of the provided buffer at the given offset and element count. Only meant to be used with vertex and index buffers. More...
 
KAPI krenderbuffer renderer_renderbuffer_get (struct renderer_system_state *state, kname name)
 Attempts retrieve the renderer's internal buffer of the given name. More...
 
KAPI void renderer_wait_for_idle (void)
 
KAPI b8 renderer_pcf_enabled (struct renderer_system_state *state)
 
KAPI u16 renderer_max_bound_texture_count_get (struct renderer_system_state *state)
 Returns the max number of textures that can be bound at once for a single draw call. More...
 
KAPI u16 renderer_max_bound_sampler_count_get (struct renderer_system_state *state)
 Returns the max number of samplers that can be bound at once for a single draw call. More...
 

Detailed Description

The renderer frontend, which is the only thing the rest of the engine sees. This is responsible for transferring any data to and from the renderer backend in an agnostic way.

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

The lifecycle of a single frame (including mult. monitors) should look something like this:

frame_prepare - Increments renderer frame number

frame_prepare_window_surface - verifies swapchain, gets image index, etc. frame_commands_begin - begins command list/buffer <insert renderpasses, draws, etc. here> frame_commands_end - ends command list/buffer frame_submit - submits command list/buffer for execution. frame_present - once frame execution is complete, presents swapchain image.

Typedef Documentation

◆ renderer_system_config

Function Documentation

◆ renderer_begin_debug_label()

KAPI void renderer_begin_debug_label ( const char *  label_text,
vec3  colour 
)

Begins the marking of a section of commands, listed under a given name and colour. Becomes a no-op in non-debug builds. NOTE: Each renderer backend will have different or possibly non-existant implementations of this.

Parameters
label_textThe text to be used for the label.
colourThe colour to be used for the label.

◆ renderer_begin_rendering()

KAPI void renderer_begin_rendering ( struct renderer_system_state *  state,
struct frame_data p_frame_data,
rect_2di  render_area,
u32  colour_target_count,
ktexture colour_targets,
ktexture  depth_stencil_target,
u32  depth_stencil_layer 
)

Begins rendering against the given targets.

Parameters
stateA pointer to the renderer system state.
p_frame_dataA pointer to the current frame data.
render_areaA rectangle representing the area of the attachments to render to.
colour_target_countThe number of colour targets to be drawn to.
colour_targetsAn array of handles to colour targets. Required unless colour_target_count is 0.
depth_stencil_targetA handle to a depth stencil target to render to.
depth_stencil_layerFor layered depth targets, the layer index to render to. Ignored otherwise.

◆ renderer_clear_colour()

KAPI b8 renderer_clear_colour ( struct renderer_system_state *  state,
ktexture  t 
)

Clears the colour buffer using the previously set clear colour.

Parameters
stateA pointer to the renderer system state.
tA handle to the texture to clear.
Returns
True if successful; otherwise false.

◆ renderer_clear_colour_set()

KAPI void renderer_clear_colour_set ( struct renderer_system_state *  state,
vec4  colour 
)

Sets the value to be used on the colour buffer clear.

Parameters
stateA pointer to the renderer system state.
colourthe RGBA colour to be used for the next clear operation. Each element is clamped to [0-1]

◆ renderer_clear_depth_set()

KAPI void renderer_clear_depth_set ( struct renderer_system_state *  state,
f32  depth 
)

Sets the value to be used on the depth buffer clear.

Parameters
stateA pointer to the renderer system state.
depthThe depth value to be used for the next clear operation. Clamped to [0-1].

◆ renderer_clear_depth_stencil()

KAPI b8 renderer_clear_depth_stencil ( struct renderer_system_state *  state,
ktexture  t 
)

Clears the depth/stencil buffer using the previously set clear values.

Parameters
stateA pointer to the renderer system state.
tA handle to the texture to clear.
Returns
True if successful; otherwise false.

◆ renderer_clear_stencil_set()

KAPI void renderer_clear_stencil_set ( struct renderer_system_state *  state,
u32  stencil 
)

Sets the value to be used on the stencil buffer clear.

Parameters
stateA pointer to the renderer system state.
stencilThe depth value to be used for the next clear operation.

◆ renderer_colour_texture_prepare_for_present()

KAPI void renderer_colour_texture_prepare_for_present ( struct renderer_system_state *  state,
ktexture  t 
)

Performs operations required on the supplied colour texture before presentation.

Parameters
stateA pointer to the renderer system state.
tA handle to the texture to prepare for presentation.

◆ renderer_cull_mode_set()

KAPI void renderer_cull_mode_set ( renderer_cull_mode  cull_mode)

Set the renderer to use the given cull mode.

Parameters
cull_modeThe cull mode.

◆ renderer_default_texture_get()

KAPI ktexture renderer_default_texture_get ( struct renderer_system_state *  state,
renderer_default_texture  default_texture 
)

Gets a texture handle with the default texture slot specified.

Parameters
stateA pointer to the renderer system state.
default_textureThe texture slot to register to.
Returns
A handle to the default texture.

◆ renderer_default_texture_register()

KAPI void renderer_default_texture_register ( struct renderer_system_state *  state,
renderer_default_texture  default_texture,
ktexture  t 
)

Registers a texture with the given handle to the default texture slot specified.

Parameters
stateA pointer to the renderer system state.
default_textureThe texture slot to register to.
tA handle to the texture to be registered.

◆ renderer_end_debug_label()

KAPI void renderer_end_debug_label ( void  )

Ends the last debug section of commands. Becomes a no-op in non-debug builds. NOTE: Each renderer backend will have different or possibly non-existant implementations of this.

◆ renderer_end_rendering()

KAPI void renderer_end_rendering ( struct renderer_system_state *  state,
struct frame_data p_frame_data 
)
Parameters
stateA pointer to the renderer system state.
p_frame_dataA pointer to the current frame data.

◆ renderer_flag_enabled_get()

KAPI b8 renderer_flag_enabled_get ( renderer_config_flags  flag)

Indicates if the provided renderer flag is enabled. If multiple flags are passed, all must be set for this to return true.

Parameters
flagThe flag to be checked.
Returns
True if the flag(s) set; otherwise false.

◆ renderer_flag_enabled_set()

KAPI void renderer_flag_enabled_set ( renderer_config_flags  flag,
b8  enabled 
)

Sets whether the included flag(s) are enabled or not. If multiple flags are passed, multiple are set at once.

Parameters
flagThe flag to be checked.
enabledIndicates whether or not to enable the flag(s).

◆ renderer_frame_command_list_begin()

KAPI b8 renderer_frame_command_list_begin ( struct renderer_system_state *  state,
struct frame_data p_frame_data 
)

Begins a render. There must be at least one of these and a matching end per frame.

Parameters
p_frame_dataA pointer to the current frame's data.
Returns
True if successful; otherwise false.

◆ renderer_frame_command_list_end()

KAPI b8 renderer_frame_command_list_end ( struct renderer_system_state *  state,
struct frame_data p_frame_data 
)

Ends a render.

Parameters
p_frame_dataA pointer to the current frame's data.
Returns
True if successful; otherwise false.

◆ renderer_frame_prepare()

KAPI b8 renderer_frame_prepare ( struct renderer_system_state *  state,
struct frame_data p_frame_data 
)

Performs setup routines required at the start of a frame.

Note
A false result does not necessarily indicate failure. It can also specify that the backend is simply not in a state capable of drawing a frame at the moment, and that it should be attempted again on the next loop. End frame does not need to (and should not) be called if this is the case.
Parameters
p_frame_dataA pointer to the current frame's data.
Returns
True if successful; otherwise false.

◆ renderer_frame_prepare_window_surface()

KAPI b8 renderer_frame_prepare_window_surface ( struct renderer_system_state *  state,
struct kwindow window,
struct frame_data p_frame_data 
)

Prepares a window's surface for drawing.

Parameters
p_frame_dataA pointer to the current frame's data. d
Returns
True if successful; otherwise false.

◆ renderer_frame_present()

KAPI b8 renderer_frame_present ( struct renderer_system_state *  state,
struct kwindow window,
struct frame_data p_frame_data 
)

Performs routines required to draw a frame, such as presentation. Should only be called after a successful return of begin_frame.

Parameters
p_frame_dataA constant pointer to the current frame's data.
Returns
True on success; otherwise false.

◆ renderer_frame_submit()

KAPI b8 renderer_frame_submit ( struct renderer_system_state *  state,
struct frame_data p_frame_data 
)

◆ renderer_generic_sampler_get()

KAPI ksampler_backend renderer_generic_sampler_get ( struct renderer_system_state *  state,
shader_generic_sampler  sampler 
)

Gets a handle to a generic sampler of the given type.

Parameters
stateA pointer to the renderer state.
samplerThe shader sampler to get a handle to.
Returns
A handle to a generic sampler of the given type.

◆ renderer_geometry_destroy()

KAPI void renderer_geometry_destroy ( kgeometry geometry)

Destroys the given geometry, releasing GPU resources. NOTE: Does NOT release index and vertex data arrays. Call geometry_destroy() to do that.

Parameters
geometryA pointer to the geometry to be destroyed.

◆ renderer_geometry_draw()

KAPI void renderer_geometry_draw ( geometry_render_data data)

Draws the given geometry.

Parameters
dataThe render data of the geometry to be drawn.

◆ renderer_geometry_upload()

KAPI b8 renderer_geometry_upload ( kgeometry geometry)

Acquires GPU resources and uploads geometry data.

Parameters
geometryA pointer to the geometry to upload.
Returns
True on success; otherwise false.

◆ renderer_geometry_vertex_update()

KAPI void renderer_geometry_vertex_update ( kgeometry g,
u32  offset,
u32  vertex_count,
void *  vertices,
b8  include_in_frame_workload 
)

Updates vertex data in the given geometry with the provided data in the given range.

Parameters
gA pointer to the geometry to be created.
offsetThe offset in bytes to update. 0 if updating from the beginning.
vertex_countThe number of vertices which will be updated.
verticesThe vertex data.

◆ renderer_is_multithreaded()

KAPI b8 renderer_is_multithreaded ( void  )

Indicates if the renderer is capable of multi-threading.

◆ renderer_max_anisotropy_get()

KAPI f32 renderer_max_anisotropy_get ( void  )

Obtains the max anisotropy level available from the renderer. 0 means not available.

◆ renderer_max_bound_sampler_count_get()

KAPI u16 renderer_max_bound_sampler_count_get ( struct renderer_system_state *  state)

Returns the max number of samplers that can be bound at once for a single draw call.

◆ renderer_max_bound_texture_count_get()

KAPI u16 renderer_max_bound_texture_count_get ( struct renderer_system_state *  state)

Returns the max number of textures that can be bound at once for a single draw call.

◆ renderer_on_window_created()

KAPI b8 renderer_on_window_created ( struct renderer_system_state *  state,
struct kwindow window 
)

◆ renderer_on_window_destroyed()

KAPI void renderer_on_window_destroyed ( struct renderer_system_state *  state,
struct kwindow window 
)

◆ renderer_on_window_resized()

KAPI void renderer_on_window_resized ( struct renderer_system_state *  state,
const struct kwindow window 
)

Handles window resize events.

Parameters
stateA pointer to the state block of memory.
windowA const pointer to the window that was resized.

◆ renderer_pcf_enabled()

KAPI b8 renderer_pcf_enabled ( struct renderer_system_state *  state)

Indicates if PCF filtering is enabled for shadow maps.

◆ renderer_renderbuffer_allocate()

KAPI b8 renderer_renderbuffer_allocate ( struct renderer_system_state *  state,
krenderbuffer  buffer,
u64  size,
u64 out_offset 
)

Attempts to allocate memory from the given buffer. Should only be used on buffers that were created with use_freelist = true.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to be allocated from.
sizeThe size in bytes to allocate.
out_offsetA pointer to hold the offset in bytes of the allocation from the beginning of the buffer.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_bind()

KAPI b8 renderer_renderbuffer_bind ( struct renderer_system_state *  state,
krenderbuffer  buffer,
u64  offset,
u32  binding_index 
)

Binds the given buffer at the provided offset.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to bind.
offsetThe offset in bytes from the beginning of the buffer.
binding_indexThe index of which to bind the buffer. Unless using multiple buffers of the same time, pass 0 here.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_clear()

KAPI b8 renderer_renderbuffer_clear ( struct renderer_system_state *  state,
krenderbuffer  buffer,
b8  zero_memory 
)

Clears the given buffer. Internally, resets the free list if one is used.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to be freed from.
zero_memoryTrue if memory should be zeroed; otherwise false. NOTE: this can be an expensive operation on large sums of memory.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_copy_range()

KAPI b8 renderer_renderbuffer_copy_range ( struct renderer_system_state *  state,
krenderbuffer  source,
u64  source_offset,
krenderbuffer  dest,
u64  dest_offset,
u64  size,
b8  include_in_frame_workload 
)

Copies data in the specified rage fron the source to the destination buffer.

Parameters
stateA pointer to the renderer state.
sourceA handle to the source buffer to copy data from.
source_offsetThe offset in bytes from the beginning of the source buffer.
destA pointer to the destination buffer to copy data to.
dest_offsetThe offset in bytes from the beginning of the destination buffer.
sizeThe size of the data in bytes to be copied.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_create()

KAPI krenderbuffer renderer_renderbuffer_create ( struct renderer_system_state *  state,
kname  name,
renderbuffer_type  type,
u64  total_size,
renderbuffer_track_type  track_type,
renderbuffer_flags   
)

Creates a new renderbuffer to hold data for a given purpose/use. Backed by a renderer-backend-specific buffer resource.

Parameters
stateA pointer to the renderer state.
nameThe name of the renderbuffer.
typeThe type of buffer, indicating it's use (i.e. vertex/index data, uniforms, etc.)
total_sizeThe total size in bytes of the buffer.
track_typeIndicates what type of allocation tracking should be used.
Returns
out_buffer A handle to hold the newly created buffer.

◆ renderer_renderbuffer_destroy()

KAPI void renderer_renderbuffer_destroy ( struct renderer_system_state *  state,
krenderbuffer  buffer 
)

Destroys the given renderbuffer.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to be destroyed.

◆ renderer_renderbuffer_draw()

KAPI b8 renderer_renderbuffer_draw ( struct renderer_system_state *  state,
krenderbuffer  buffer,
u64  offset,
u32  element_count,
u32  binding_index,
b8  bind_only 
)

Attempts to draw the contents of the provided buffer at the given offset and element count. Only meant to be used with vertex and index buffers.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to be drawn.
offsetThe offset in bytes from the beginning of the buffer.
element_countThe number of elements to be drawn.
binding_indexThe index of which to bind the buffer. Unless using multiple buffers of the same time, pass 0 here.
bind_onlyOnly bind the buffer, but don't draw.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_flush()

KAPI b8 renderer_renderbuffer_flush ( struct renderer_system_state *  state,
krenderbuffer  buffer,
u64  offset,
u64  size 
)

Flushes buffer memory at the given range. Should be done after a write.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to unmap.
offsetThe number of bytes from the beginning of the buffer to flush.
sizeThe amount of memory in the buffer to flush.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_free()

KAPI b8 renderer_renderbuffer_free ( struct renderer_system_state *  state,
krenderbuffer  buffer,
u64  size,
u64  offset 
)

Frees memory from the given buffer.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to be freed from.
sizeThe size in bytes to free.
offsetThe offset in bytes from the beginning of the buffer to free.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_get()

KAPI krenderbuffer renderer_renderbuffer_get ( struct renderer_system_state *  state,
kname  name 
)

Attempts retrieve the renderer's internal buffer of the given name.

Parameters
stateA pointer to the renderer state.
typeThe name of buffer to retrieve. @returnshader A handle to the buffer on success; otherwise 0/null.

◆ renderer_renderbuffer_get_mapped_memory()

KAPI void* renderer_renderbuffer_get_mapped_memory ( struct renderer_system_state *  state,
krenderbuffer  buffer 
)

Obtains the mapped memory of the buffer, if mapped. This memory should be considered invalid once unmapped.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer whose mapped memory is to be obtained.
Returns
A pointer to the mapped memory, if mapped. Otherwise KNULL.

◆ renderer_renderbuffer_load_range()

KAPI b8 renderer_renderbuffer_load_range ( struct renderer_system_state *  state,
krenderbuffer  buffer,
u64  offset,
u64  size,
const void *  data,
b8  include_in_frame_workload 
)

Loads provided data into the specified rage of the given buffer.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to load data into.
offsetThe offset in bytes from the beginning of the buffer.
sizeThe size of the data in bytes to be loaded.
dataThe data to be loaded.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_map_memory()

KAPI void renderer_renderbuffer_map_memory ( struct renderer_system_state *  state,
krenderbuffer  buffer,
u64  offset,
u64  size 
)

Maps memory from the given buffer in the provided range to a block of memory and returns it. This memory should be considered invalid once unmapped.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to map.
offsetThe number of bytes from the beginning of the buffer to map.
sizeThe amount of memory in the buffer to map. Use KWHOLE_SIZE to map the entire buffer.

◆ renderer_renderbuffer_read()

KAPI b8 renderer_renderbuffer_read ( struct renderer_system_state *  state,
krenderbuffer  buffer,
u64  offset,
u64  size,
void **  out_memory 
)

Reads memory from the provided buffer at the given range to the output variable.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to read from.
offsetThe number of bytes from the beginning of the buffer to read.
sizeThe amount of memory in the buffer to read.
out_memoryA pointer to a block of memory to read to. Must be of appropriate size.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_resize()

KAPI b8 renderer_renderbuffer_resize ( struct renderer_system_state *  state,
krenderbuffer  buffer,
u64  new_total_size 
)

Resizes the given buffer to new_total_size. new_total_size must be greater than the current buffer size. Data from the old internal buffer is copied over.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to be resized.
new_total_sizeThe new size in bytes. Must be larger than the current size.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_unbind()

KAPI b8 renderer_renderbuffer_unbind ( struct renderer_system_state *  state,
krenderbuffer  buffer 
)

Unbinds the given buffer.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to be unbound.
Returns
True on success; otherwise false.

◆ renderer_renderbuffer_unmap_memory()

KAPI void renderer_renderbuffer_unmap_memory ( struct renderer_system_state *  state,
krenderbuffer  buffer,
u64  offset,
u64  size 
)

Unmaps memory from the given buffer in the provided range to a block of memory. This memory should be considered invalid once unmapped.

Parameters
stateA pointer to the renderer state.
bufferA handle to the buffer to unmap.
offsetThe number of bytes from the beginning of the buffer to unmap.
sizeThe amount of memory in the buffer to unmap.

◆ renderer_sampler_acquire()

KAPI ksampler_backend renderer_sampler_acquire ( struct renderer_system_state *  state,
kname  name,
texture_filter  filter,
texture_repeat  repeat,
f32  anisotropy 
)

Acquires a internal sampler and returns a handle to it.

Parameters
stateA pointer to the renderer state.
nameThe name of the sampler.
filterThe min/mag filter.
repeatThe repeat mode.
anisotropyThe anisotropy level, if needed; otherwise 0.
Returns
A handle to the sampler on success; otherwise an invalid handle.

◆ renderer_sampler_name_get()

KAPI kname renderer_sampler_name_get ( struct renderer_system_state *  state,
ksampler_backend  sampler 
)

Attempts to obtain the name of a sampler with the given handle. Returns INVALID_KNAME if not found.

Parameters
stateA pointer to the renderer state.
samplerA handle to the sampler whose name to get.
Returns
The name of the sampler on success; otherwise INVALID_KNAME.

◆ renderer_sampler_refresh()

KAPI b8 renderer_sampler_refresh ( struct renderer_system_state *  state,
ksampler_backend sampler,
texture_filter  filter,
texture_repeat  repeat,
f32  anisotropy,
u32  mip_levels 
)

Recreates the internal sampler pointed to by the given handle. Modifies the handle.

Parameters
stateA pointer to the renderer state.
samplerA pointer to the handle of the sampler to be refreshed.
filterThe min/mag filter.
repeatThe repeat mode.
anisotropyThe anisotropy level, if needed; otherwise 0.
mip_levelsThe mip levels, if used; otherwise 0.
Returns
True on success; otherwise false.

◆ renderer_sampler_release()

KAPI void renderer_sampler_release ( struct renderer_system_state *  state,
ksampler_backend sampler 
)

Releases the internal sampler for the given handle.

Parameters
stateA pointer to the renderer state.
mapA pointer to the handle whose sampler is to be released. Handle is invalidated upon release.

◆ renderer_scissor_reset()

KAPI void renderer_scissor_reset ( void  )

Resets the scissor to the default, which matches the application window.

◆ renderer_scissor_set()

KAPI void renderer_scissor_set ( rect_2di  rect)

Sets the renderer scissor to the given rectangle.

Parameters
rectThe scissor rectangle to be set.

◆ renderer_set_depth_bias()

KAPI void renderer_set_depth_bias ( f32  constant_factor,
f32  clamp,
f32  slope_factor 
)

Sets depth bias factors and clamp dynamically.

Parameters
constant_factorA scalar factor controlling the constant depth value added to each fragment.
clampThe maximum (or minimum) depth bias of a fragment.
slope_factorA scalar factor applied to a fragment’s slope in depth bias calculations.

◆ renderer_set_depth_bias_enabled()

KAPI void renderer_set_depth_bias_enabled ( b8  enabled)

Enables/disables depth bias.

Parameters
enabledTrue to enable; otherwise disable.

◆ renderer_set_depth_test_enabled()

KAPI void renderer_set_depth_test_enabled ( b8  enabled)

Set depth testing enabled/disabled.

Parameters
enabledIndicates if depth testing should be enabled/disabled for subsequent draws.

◆ renderer_set_depth_write_enabled()

KAPI void renderer_set_depth_write_enabled ( b8  enabled)

Set depth write enabled/disabled.

Parameters
enabledIndicates if depth write should be enabled/disabled for subsequent draws.

◆ renderer_set_stencil_compare_mask()

KAPI void renderer_set_stencil_compare_mask ( u32  compare_mask)

Set stencil compare mask.

Parameters
compare_maskThe new value to use as the stencil compare mask.

◆ renderer_set_stencil_op()

KAPI void renderer_set_stencil_op ( renderer_stencil_op  fail_op,
renderer_stencil_op  pass_op,
renderer_stencil_op  depth_fail_op,
renderer_compare_op  compare_op 
)

Set stencil operation.

Parameters
fail_opSpecifys the action performed on samples that fail the stencil test.
pass_opSpecifys the action performed on samples that pass both the depth and stencil tests.
depth_fail_opSpecifys the action performed on samples that pass the stencil test and fail the depth test.
compare_opSpecifys the comparison operator used in the stencil test.

◆ renderer_set_stencil_reference()

KAPI void renderer_set_stencil_reference ( u32  reference)

Set the stencil reference for testing.

Parameters
referenceThe reference to use when stencil testing/writing.

◆ renderer_set_stencil_test_enabled()

KAPI void renderer_set_stencil_test_enabled ( b8  enabled)

Set stencil testing enabled/disabled.

Parameters
enabledIndicates if stencil testing should be enabled/disabled for subsequent draws.

◆ renderer_set_stencil_write_mask()

KAPI void renderer_set_stencil_write_mask ( u32  write_mask)

Set stencil write mask.

Parameters
write_maskThe new value to use as the stencil write mask.

◆ renderer_shader_acquire_binding_set_instance()

KAPI u32 renderer_shader_acquire_binding_set_instance ( struct renderer_system_state *  state,
kshader  shader,
u8  binding_set 
)

◆ renderer_shader_apply_binding_set()

KAPI b8 renderer_shader_apply_binding_set ( struct renderer_system_state *  state,
kshader  shader,
u8  binding_set,
u32  instance_id 
)

◆ renderer_shader_binding_set_get_max_instance_count()

KAPI u32 renderer_shader_binding_set_get_max_instance_count ( struct renderer_system_state *  state,
kshader  shader,
u8  binding_set 
)

◆ renderer_shader_create()

KAPI b8 renderer_shader_create ( struct renderer_system_state *  state,
kshader  shader,
kname  name,
shader_flags  flags,
primitive_topology_type_bits  topology_types,
primitive_topology_type  default_topology,
u8  colour_attachment_count,
kpixel_format colour_attachment_formats,
kpixel_format  depth_attachment_format,
kpixel_format  stencil_attachment_format,
u8  pipeline_count,
shader_pipeline_config pipelines,
u8  binding_set_count,
const shader_binding_set_config binding_sets 
)

Creates internal shader resources using the provided parameters.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader.
shader_assetA constant pointer to the shader asset.
Returns
b8 True on success; otherwise false.

◆ renderer_shader_destroy()

KAPI void renderer_shader_destroy ( struct renderer_system_state *  state,
kshader  shader 
)

Destroys the given shader and releases any resources held by it.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be destroyed.

◆ renderer_shader_flag_get()

KAPI b8 renderer_shader_flag_get ( struct renderer_system_state *  state,
kshader  shader,
shader_flags  flag 
)

Indicates if the given shader flag is set.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be used.
flagThe flag to check.
Returns
True if set; otherwise false.

◆ renderer_shader_flag_set()

KAPI void renderer_shader_flag_set ( struct renderer_system_state *  state,
kshader  shader,
shader_flags  flag,
b8  enabled 
)

Sets the given shader flag.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be used.
flagThe flag to set.
enabledIndicates whether the flag should be set or unset.

◆ renderer_shader_release_binding_set_instance()

KAPI void renderer_shader_release_binding_set_instance ( struct renderer_system_state *  state,
kshader  shader,
u8  binding_set,
u32  instance_id 
)

◆ renderer_shader_reload()

KAPI b8 renderer_shader_reload ( struct renderer_system_state *  state,
kshader  shader,
u8  pipeline_count,
shader_pipeline_config pipelines 
)

Reloads the internals of the given shader.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be reloaded.
shader_stage_countThe number of shader stages.
shader_stagesAn array of shader stages configs.
Returns
True on success; otherwise false.

◆ renderer_shader_set_binding_data()

KAPI void renderer_shader_set_binding_data ( struct renderer_system_state *  state,
kshader  shader,
u8  binding_set,
u32  instance_id,
u8  binding_index,
u64  offset,
void *  data,
u64  size 
)

◆ renderer_shader_set_binding_sampler()

KAPI void renderer_shader_set_binding_sampler ( struct renderer_system_state *  state,
kshader  shader,
u8  binding_set,
u32  instance_id,
u8  binding_index,
u8  array_index,
ksampler_backend  sampler 
)

◆ renderer_shader_set_binding_texture()

KAPI void renderer_shader_set_binding_texture ( struct renderer_system_state *  state,
kshader  shader,
u8  binding_set,
u32  instance_id,
u8  binding_index,
u8  array_index,
ktexture  texture 
)

◆ renderer_shader_set_immediate_data()

KAPI void renderer_shader_set_immediate_data ( struct renderer_system_state *  state,
kshader  shader,
const void *  data,
u8  size 
)

◆ renderer_shader_supports_wireframe()

KAPI b8 renderer_shader_supports_wireframe ( struct renderer_system_state *  state,
kshader  shader 
)

Determines if the given shader supports wireframe mode.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be used.
Returns
True on success; otherwise false.

◆ renderer_shader_use()

KAPI b8 renderer_shader_use ( struct renderer_system_state *  state,
kshader  shader,
u8  vertex_layout_index 
)

Uses the given shader, activating it for updates to attributes, uniforms and such, and for use in draw calls. Uses the default topology configured by the shader.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be used.
Returns
True on success; otherwise false.

◆ renderer_shader_use_with_topology()

KAPI b8 renderer_shader_use_with_topology ( struct renderer_system_state *  state,
kshader  shader,
primitive_topology_type  type,
u8  vertex_layout_index 
)

Uses the given shader, activating it for updates to attributes, uniforms and such, and for use in draw calls using the provided topology.

Parameters
stateA pointer to the renderer state.
shaderA handle to the shader to be used.
typeThe primitive topology type to use.
Returns
True on success; otherwise false.

◆ renderer_system_deserialize_config()

b8 renderer_system_deserialize_config ( const char *  config_str,
renderer_system_config out_config 
)

◆ renderer_system_destroy_config()

void renderer_system_destroy_config ( renderer_system_config config)

◆ renderer_system_frame_number_get()

KAPI u16 renderer_system_frame_number_get ( struct renderer_system_state *  state)

◆ renderer_system_initialize()

KAPI b8 renderer_system_initialize ( u64 memory_requirement,
struct renderer_system_state *  state,
const renderer_system_config config 
)

Initializes the renderer frontend/system. Should be called twice - once to obtain the memory requirement (passing state=0), and a second time passing allocated memory to state.

Parameters
memory_requirementA pointer to hold the memory requirement for this system.
stateA block of memory to hold state data, or 0 if obtaining memory requirement.
configA constant pointer to the configuration for the renderer.
Returns
True on success; otherwise false.

◆ renderer_system_shutdown()

KAPI void renderer_system_shutdown ( struct renderer_system_state *  state)

Shuts the renderer system/frontend down.

Parameters
stateA pointer to the state block of memory.

◆ renderer_texture_prepare_for_sampling()

KAPI void renderer_texture_prepare_for_sampling ( struct renderer_system_state *  state,
ktexture  t,
ktexture_flag_bits  flags 
)

Performs operations required on the supplied texture before being used for sampling.

Parameters
stateA pointer to the renderer system state.
tA handle to the texture to prepare for sampling.
flagsTexture flags from the texture itself, used to determine format/layout, etc.

◆ renderer_texture_read_data()

KAPI b8 renderer_texture_read_data ( struct renderer_system_state *  state,
ktexture  t,
u32  offset,
u32  size,
u8 **  out_memory 
)

Reads the given data from the provided texture.

Parameters
stateA pointer to the renderer system state.
tA handle to the texture to be read from.
offsetThe offset in bytes from the beginning of the data to be read.
sizeThe number of bytes to be read.
out_pixelshaderA handle to a block of memory to write the read data to.
Returns
True on success; otherwise false.

◆ renderer_texture_read_pixel()

KAPI b8 renderer_texture_read_pixel ( struct renderer_system_state *  state,
ktexture  t,
u32  x,
u32  y,
u8 **  out_rgba 
)

Reads a pixel from the provided texture at the given x/y coordinate.

Parameters
stateA pointer to the renderer system state.
tA handle to the texture to be read from.
xThe pixel x-coordinate.
yThe pixel y-coordinate.
out_rgbaA pointer to an array of u8s to hold the pixel data (should be sizeof(u8) * 4)
Returns
True on success; otherwise false.

◆ renderer_texture_resize()

KAPI b8 renderer_texture_resize ( struct renderer_system_state *  state,
ktexture  t,
u32  new_width,
u32  new_height 
)

Resizes a texture. There is no check at this level to see if the texture is writeable. Internal resources are destroyed and re-created at the new resolution. Data is lost and would need to be reloaded.

Parameters
stateA pointer to the renderer system state.
tA handle to the texture to be resized.
new_widthThe new width in pixels.
new_heightThe new height in pixels.
Returns
True on success; otherwise false.

◆ renderer_texture_resources_acquire()

KAPI b8 renderer_texture_resources_acquire ( struct renderer_system_state *  state,
ktexture  t,
kname  name,
ktexture_type  type,
u32  width,
u32  height,
u8  channel_count,
u8  mip_levels,
u16  array_size,
ktexture_flag_bits  flags 
)

Attempts to acquire renderer-specific resources to back a texture.

Parameters
stateA pointer to the renderer system state.
tThe texture handle which also points to the backing resource(s) of the texture.
nameThe name of the texture.
typeThe type of texture.
widthThe texture width in pixels.
heightThe texture height in pixels.
channel_countThe number of channels in the texture (i.e. RGBA = 4)
mip_levelsThe number of mip maps the internal texture has. Must always be at least 1.
array_sizeFor arrayed textures, how many "layers" there are. Otherwise this is 1.
flagsVarious property flags to be used in creating this texture.
Returns
True on success, otherwise false;

◆ renderer_texture_resources_release()

KAPI void renderer_texture_resources_release ( struct renderer_system_state *  state,
ktexture  t 
)

Releases backing renderer-specific resources for the given texture.

Parameters
stateA pointer to the renderer system state.
tA handle to the renderer texture whose resources are to be released.

◆ renderer_texture_write_data()

KAPI b8 renderer_texture_write_data ( struct renderer_system_state *  state,
ktexture  t,
u32  offset,
u32  size,
const u8 pixels 
)

Writes the given data to the provided texture.

Parameters
stateA pointer to the renderer system state.
tA handle to the texture to be written to. NOTE: Must be a writeable texture.
offsetThe offset in bytes from the beginning of the data to be written.
sizeThe number of bytes to be written.
pixelsThe raw image data to be written.
Returns
True on success; otherwise false.

◆ renderer_viewport_reset()

KAPI void renderer_viewport_reset ( void  )

Resets the viewport to the default, which matches the application window.

◆ renderer_viewport_set()

KAPI void renderer_viewport_set ( rect_2di  rect)

Sets the renderer viewport to the given rectangle.

Parameters
rectThe viewport rectangle to be set.

◆ renderer_wait_for_idle()

KAPI void renderer_wait_for_idle ( void  )

Waits for the renderer backend to be completely idle of work before returning. NOTE: This incurs a lot of overhead/waits, and should be used sparingly.

◆ renderer_winding_set()

KAPI void renderer_winding_set ( renderer_winding  winding)

Set the renderer to use the given winding direction.

Parameters
windingThe winding direction.