Kohi Game Engine
|
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 "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 | |
KAPI b8 | renderer_system_initialize (u64 *memory_requirement, void *state, void *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 (void *state) |
Shuts the renderer system/frontend down. More... | |
KAPI void | renderer_on_resized (u16 width, u16 height) |
Handles resize events. More... | |
KAPI b8 | renderer_frame_prepare (struct frame_data *p_frame_data) |
Performs setup routines required at the start of a frame. More... | |
KAPI b8 | renderer_begin (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_end (struct frame_data *p_frame_data) |
Ends a render. More... | |
KAPI b8 | renderer_present (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 (vec4 rect) |
Sets the renderer viewport to the given rectangle. Must be done within a renderpass. More... | |
KAPI void | renderer_viewport_reset (void) |
Resets the viewport to the default, which matches the application window. Must be done within a renderpass. More... | |
KAPI void | renderer_scissor_set (vec4 rect) |
Sets the renderer scissor to the given rectangle. Must be done within a renderpass. More... | |
KAPI void | renderer_scissor_reset (void) |
Resets the scissor to the default, which matches the application window. Must be done within a renderpass. More... | |
KAPI void | renderer_winding_set (renderer_winding winding) |
Set the renderer to use the given winding direction. More... | |
KAPI void | renderer_texture_create (const u8 *pixels, struct texture *texture) |
Creates a new texture. More... | |
KAPI void | renderer_texture_destroy (struct texture *texture) |
Destroys the given texture, releasing internal resources from the GPU. More... | |
KAPI void | renderer_texture_create_writeable (texture *t) |
Creates a new writeable texture with no data written to it. More... | |
KAPI void | renderer_texture_resize (texture *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 void | renderer_texture_write_data (texture *t, u32 offset, u32 size, const u8 *pixels) |
Writes the given data to the provided texture. More... | |
KAPI void | renderer_texture_read_data (texture *t, u32 offset, u32 size, void **out_memory) |
Reads the given data from the provided texture. More... | |
KAPI void | renderer_texture_read_pixel (texture *t, u32 x, u32 y, u8 **out_rgba) |
Reads a pixel from the provided texture at the given x/y coordinate. More... | |
KAPI b8 | renderer_geometry_create (geometry *geometry, u32 vertex_size, u32 vertex_count, const void *vertices, u32 index_size, u32 index_count, const void *indices) |
Creates geometry, taking a copy of the provided data and setting up the data structure. More... | |
KAPI b8 | renderer_geometry_upload (geometry *geometry) |
Acquires GPU resources and uploads geometry data. More... | |
KAPI void | renderer_geometry_vertex_update (geometry *g, u32 offset, u32 vertex_count, void *vertices) |
Updates vertex data in the given geometry with the provided data in the given range. More... | |
KAPI void | renderer_geometry_destroy (geometry *geometry) |
Destroys the given geometry, releasing GPU resources. More... | |
KAPI void | renderer_geometry_draw (geometry_render_data *data) |
Draws the given geometry. Should only be called inside a renderpass, within a frame. More... | |
KAPI b8 | renderer_renderpass_begin (renderpass *pass, render_target *target) |
Begins the given renderpass. More... | |
KAPI b8 | renderer_renderpass_end (renderpass *pass) |
Ends the given renderpass. More... | |
KAPI b8 | renderer_shader_create (struct shader *s, const shader_config *config, renderpass *pass, u8 stage_count, const char **stage_filenames, shader_stage *stages) |
Creates internal shader resources using the provided parameters. More... | |
KAPI void | renderer_shader_destroy (struct shader *s) |
Destroys the given shader and releases any resources held by it. More... | |
KAPI b8 | renderer_shader_initialize (struct shader *s) |
Initializes a configured shader. Will be automatically destroyed if this step fails. Must be done after vulkan_shader_create(). More... | |
KAPI b8 | renderer_shader_use (struct shader *s) |
Uses the given shader, activating it for updates to attributes, uniforms and such, and for use in draw calls. More... | |
KAPI b8 | renderer_shader_bind_globals (struct shader *s) |
Binds global resources for use and updating. More... | |
KAPI b8 | renderer_shader_bind_instance (struct shader *s, u32 instance_id) |
Binds instance resources for use and updating. More... | |
KAPI b8 | renderer_shader_apply_globals (struct shader *s, b8 needs_update) |
Applies global data to the uniform buffer. More... | |
KAPI b8 | renderer_shader_apply_instance (struct shader *s, b8 needs_update) |
Applies data for the currently bound instance. More... | |
KAPI b8 | renderer_shader_instance_resources_acquire (struct shader *s, u32 texture_map_count, texture_map **maps, u32 *out_instance_id) |
Acquires internal instance-level resources and provides an instance id. More... | |
KAPI b8 | renderer_shader_instance_resources_release (struct shader *s, u32 instance_id) |
Releases internal instance-level resources for the given instance id. More... | |
KAPI b8 | renderer_shader_uniform_set (struct shader *s, struct shader_uniform *uniform, const void *value) |
Sets the uniform of the given shader to the provided value. More... | |
KAPI b8 | renderer_texture_map_resources_acquire (struct texture_map *map) |
Acquires internal resources for the given texture map. More... | |
KAPI void | renderer_texture_map_resources_release (struct texture_map *map) |
Releases internal resources for the given texture map. More... | |
KAPI void | renderer_render_target_create (u8 attachment_count, render_target_attachment *attachments, renderpass *pass, u32 width, u32 height, render_target *out_target) |
Creates a new render target using the provided data. More... | |
KAPI void | renderer_render_target_destroy (render_target *target, b8 free_internal_memory) |
Destroys the provided render target. More... | |
KAPI texture * | renderer_window_attachment_get (u8 index) |
Attempts to get the window render target at the given index. More... | |
KAPI texture * | renderer_depth_attachment_get (u8 index) |
Returns a pointer to the main depth texture target. More... | |
KAPI u8 | renderer_window_attachment_index_get (void) |
Returns the current window attachment index. More... | |
KAPI u8 | renderer_window_attachment_count_get (void) |
Returns the number of attachments required for window-based render targets. More... | |
KAPI b8 | renderer_renderpass_create (const renderpass_config *config, renderpass *out_renderpass) |
Creates a new renderpass. More... | |
KAPI void | renderer_renderpass_destroy (renderpass *pass) |
Destroys the given renderpass. 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 b8 | renderer_renderbuffer_create (const char *name, renderbuffer_type type, u64 total_size, renderbuffer_track_type track_type, renderbuffer *out_buffer) |
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 (renderbuffer *buffer) |
Destroys the given renderbuffer. More... | |
KAPI b8 | renderer_renderbuffer_bind (renderbuffer *buffer, u64 offset) |
Binds the given buffer at the provided offset. More... | |
KAPI b8 | renderer_renderbuffer_unbind (renderbuffer *buffer) |
Unbinds the given buffer. More... | |
KAPI void * | renderer_renderbuffer_map_memory (renderbuffer *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 (renderbuffer *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 b8 | renderer_renderbuffer_flush (renderbuffer *buffer, u64 offset, u64 size) |
Flushes buffer memory at the given range. Should be done after a write. More... | |
KAPI b8 | renderer_renderbuffer_read (renderbuffer *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 (renderbuffer *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 (renderbuffer *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 (renderbuffer *buffer, u64 size, u64 offset) |
Frees memory from the given buffer. More... | |
KAPI b8 | renderer_renderbuffer_clear (renderbuffer *buffer, b8 zero_memory) |
Clears the given buffer. Internally, resets the free list if one is used. More... | |
KAPI b8 | renderer_renderbuffer_load_range (renderbuffer *buffer, u64 offset, u64 size, const void *data) |
Loads provided data into the specified rage of the given buffer. More... | |
KAPI b8 | renderer_renderbuffer_copy_range (renderbuffer *source, u64 source_offset, renderbuffer *dest, u64 dest_offset, u64 size) |
Copies data in the specified rage fron the source to the destination buffer. More... | |
KAPI b8 | renderer_renderbuffer_draw (renderbuffer *buffer, u64 offset, u32 element_count, 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 struct viewport * | renderer_active_viewport_get (void) |
Returns a pointer to the currently active viewport. More... | |
KAPI void | renderer_active_viewport_set (struct viewport *v) |
Sets the currently active viewport. More... | |
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.
typedef struct renderer_system_config renderer_system_config |
Returns a pointer to the currently active viewport.
Sets the currently active viewport.
viewport | A pointer to the viewport to be set. |
KAPI b8 renderer_begin | ( | struct frame_data * | p_frame_data | ) |
Begins a render. There must be at least one of these and a matching end per frame.
p_frame_data | A pointer to the current frame's data. |
Returns a pointer to the main depth texture target.
index | The index of the attachment to get. Must be within the range of window render target count. |
KAPI b8 renderer_end | ( | struct frame_data * | p_frame_data | ) |
Ends a render.
p_frame_data | A pointer to the current frame's data. |
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.
flag | The flag to be checked. |
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.
flag | The flag to be checked. |
enabled | Indicates whether or not to enable the flag(s). |
KAPI b8 renderer_frame_prepare | ( | struct frame_data * | p_frame_data | ) |
Performs setup routines required at the start of a frame.
p_frame_data | A pointer to the current frame's data. |
KAPI b8 renderer_geometry_create | ( | geometry * | geometry, |
u32 | vertex_size, | ||
u32 | vertex_count, | ||
const void * | vertices, | ||
u32 | index_size, | ||
u32 | index_count, | ||
const void * | indices | ||
) |
Creates geometry, taking a copy of the provided data and setting up the data structure.
geometry | A pointer to the geometry to create. |
vertex_size | The size of each vertex. |
vertex_count | The number of vertices. |
vertices | The vertex array. |
index_size | The size of each index. |
index_count | The number of indices. |
indices | The index array. |
Destroys the given geometry, releasing GPU resources.
geometry | A pointer to the geometry to be destroyed. |
KAPI void renderer_geometry_draw | ( | geometry_render_data * | data | ) |
Draws the given geometry. Should only be called inside a renderpass, within a frame.
data | The render data of the geometry to be drawn. |
Acquires GPU resources and uploads geometry data.
geometry | A pointer to the geometry to upload. |
KAPI void renderer_geometry_vertex_update | ( | geometry * | g, |
u32 | offset, | ||
u32 | vertex_count, | ||
void * | vertices | ||
) |
Updates vertex data in the given geometry with the provided data in the given range.
g | A pointer to the geometry to be created. |
offset | The offset in bytes to update. 0 if updating from the beginning. |
vertex_count | The number of vertices which will be updated. |
vertices | The vertex data. |
Handles resize events.
width | The new window width. |
height | The new window height. |
KAPI b8 renderer_present | ( | 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.
p_frame_data | A constant pointer to the current frame's data. |
KAPI void renderer_render_target_create | ( | u8 | attachment_count, |
render_target_attachment * | attachments, | ||
renderpass * | pass, | ||
u32 | width, | ||
u32 | height, | ||
render_target * | out_target | ||
) |
Creates a new render target using the provided data.
attachment_count | The number of attachments. |
attachments | An array of attachments. |
renderpass | A pointer to the renderpass the render target is associated with. |
width | The width of the render target in pixels. |
height | The height of the render target in pixels. |
out_target | A pointer to hold the newly created render target. |
KAPI void renderer_render_target_destroy | ( | render_target * | target, |
b8 | free_internal_memory | ||
) |
Destroys the provided render target.
target | A pointer to the render target to be destroyed. |
free_internal_memory | Indicates if internal memory should be freed. |
KAPI b8 renderer_renderbuffer_allocate | ( | renderbuffer * | 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.
buffer | A pointer to the buffer to be allocated from. |
size | The size in bytes to allocate. |
out_offset | A pointer to hold the offset in bytes of the allocation from the beginning of the buffer. |
KAPI b8 renderer_renderbuffer_bind | ( | renderbuffer * | buffer, |
u64 | offset | ||
) |
Binds the given buffer at the provided offset.
buffer | A pointer to the buffer to bind. |
offset | The offset in bytes from the beginning of the buffer. |
KAPI b8 renderer_renderbuffer_clear | ( | renderbuffer * | buffer, |
b8 | zero_memory | ||
) |
Clears the given buffer. Internally, resets the free list if one is used.
buffer | A pointer to the buffer to be freed from. |
zero_memory | True if memory should be zeroed; otherwise false. NOTE: this can be an expensive operation on large sums of memory. |
KAPI b8 renderer_renderbuffer_copy_range | ( | renderbuffer * | source, |
u64 | source_offset, | ||
renderbuffer * | dest, | ||
u64 | dest_offset, | ||
u64 | size | ||
) |
Copies data in the specified rage fron the source to the destination buffer.
source | A pointer to the source buffer to copy data from. |
source_offset | The offset in bytes from the beginning of the source buffer. |
dest | A pointer to the destination buffer to copy data to. |
dest_offset | The offset in bytes from the beginning of the destination buffer. |
size | The size of the data in bytes to be copied. |
KAPI b8 renderer_renderbuffer_create | ( | const char * | name, |
renderbuffer_type | type, | ||
u64 | total_size, | ||
renderbuffer_track_type | track_type, | ||
renderbuffer * | out_buffer | ||
) |
Creates a new renderbuffer to hold data for a given purpose/use. Backed by a renderer-backend-specific buffer resource.
name | The name of the renderbuffer, used for debugging purposes. |
type | The type of buffer, indicating it's use (i.e. vertex/index data, uniforms, etc.) |
total_size | The total size in bytes of the buffer. |
track_type | Indicates what type of allocation tracking should be used. |
out_buffer | A pointer to hold the newly created buffer. |
KAPI void renderer_renderbuffer_destroy | ( | renderbuffer * | buffer | ) |
Destroys the given renderbuffer.
buffer | A pointer to the buffer to be destroyed. |
KAPI b8 renderer_renderbuffer_draw | ( | renderbuffer * | buffer, |
u64 | offset, | ||
u32 | element_count, | ||
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.
buffer | A pointer to the buffer to be drawn. |
offset | The offset in bytes from the beginning of the buffer. |
element_count | The number of elements to be drawn. |
bind_only | Only bind the buffer, but don't draw. |
KAPI b8 renderer_renderbuffer_flush | ( | renderbuffer * | buffer, |
u64 | offset, | ||
u64 | size | ||
) |
Flushes buffer memory at the given range. Should be done after a write.
buffer | A pointer to the buffer to unmap. |
offset | The number of bytes from the beginning of the buffer to flush. |
size | The amount of memory in the buffer to flush. |
KAPI b8 renderer_renderbuffer_free | ( | renderbuffer * | buffer, |
u64 | size, | ||
u64 | offset | ||
) |
Frees memory from the given buffer.
buffer | A pointer to the buffer to be freed from. |
size | The size in bytes to free. |
offset | The offset in bytes from the beginning of the buffer to free. |
KAPI b8 renderer_renderbuffer_load_range | ( | renderbuffer * | buffer, |
u64 | offset, | ||
u64 | size, | ||
const void * | data | ||
) |
Loads provided data into the specified rage of the given buffer.
buffer | A pointer to the buffer to load data into. |
offset | The offset in bytes from the beginning of the buffer. |
size | The size of the data in bytes to be loaded. |
data | The data to be loaded. |
KAPI void* renderer_renderbuffer_map_memory | ( | renderbuffer * | 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.
buffer | A pointer to the buffer to map. |
offset | The number of bytes from the beginning of the buffer to map. |
size | The amount of memory in the buffer to map. |
KAPI b8 renderer_renderbuffer_read | ( | renderbuffer * | buffer, |
u64 | offset, | ||
u64 | size, | ||
void ** | out_memory | ||
) |
Reads memory from the provided buffer at the given range to the output variable.
buffer | A pointer to the buffer to read from. |
offset | The number of bytes from the beginning of the buffer to read. |
size | The amount of memory in the buffer to read. |
out_memory | A pointer to a block of memory to read to. Must be of appropriate size. |
KAPI b8 renderer_renderbuffer_resize | ( | renderbuffer * | 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.
buffer | A pointer to the buffer to be resized. |
new_total_size | The new size in bytes. Must be larger than the current size. |
KAPI b8 renderer_renderbuffer_unbind | ( | renderbuffer * | buffer | ) |
Unbinds the given buffer.
buffer | A pointer to the buffer to be unbound. |
KAPI void renderer_renderbuffer_unmap_memory | ( | renderbuffer * | 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.
buffer | A pointer to the buffer to unmap. |
offset | The number of bytes from the beginning of the buffer to unmap. |
size | The amount of memory in the buffer to unmap. |
KAPI b8 renderer_renderpass_begin | ( | renderpass * | pass, |
render_target * | target | ||
) |
Begins the given renderpass.
pass | A pointer to the renderpass to begin. |
target | A pointer to the render target to be used. |
KAPI b8 renderer_renderpass_create | ( | const renderpass_config * | config, |
renderpass * | out_renderpass | ||
) |
Creates a new renderpass.
config | A constant pointer to the configuration to be used when creating the renderpass. |
out_renderpass | A pointer to the generic renderpass. |
KAPI void renderer_renderpass_destroy | ( | renderpass * | pass | ) |
Destroys the given renderpass.
pass | A pointer to the renderpass to be destroyed. |
KAPI b8 renderer_renderpass_end | ( | renderpass * | pass | ) |
Ends the given renderpass.
pass | A pointer to the renderpass to end. |
KAPI void renderer_scissor_reset | ( | void | ) |
Resets the scissor to the default, which matches the application window. Must be done within a renderpass.
Sets the renderer scissor to the given rectangle. Must be done within a renderpass.
rect | The scissor rectangle to be set. |
Applies global data to the uniform buffer.
s | A pointer to the shader to apply the global data for. |
needs_update | Indicates if the shader uniforms need to be updated or just bound. |
Applies data for the currently bound instance.
s | A pointer to the shader to apply the instance data for. |
needs_update | Indicates if the shader uniforms need to be updated or just bound. |
Binds global resources for use and updating.
s | A pointer to the shader whose globals are to be bound. |
Binds instance resources for use and updating.
s | A pointer to the shader whose instance resources are to be bound. |
instance_id | The identifier of the instance to be bound. |
KAPI b8 renderer_shader_create | ( | struct shader * | s, |
const shader_config * | config, | ||
renderpass * | pass, | ||
u8 | stage_count, | ||
const char ** | stage_filenames, | ||
shader_stage * | stages | ||
) |
Creates internal shader resources using the provided parameters.
s | A pointer to the shader. |
config | A constant pointer to the shader config. |
pass | A pointer to the renderpass to be associated with the shader. |
stage_count | The total number of stages. |
stage_filenames | An array of shader stage filenames to be loaded. Should align with stages array. |
stages | A array of shader_stages indicating what render stages (vertex, fragment, etc.) used in this shader. |
Destroys the given shader and releases any resources held by it.
s | A pointer to the shader to be destroyed. |
Initializes a configured shader. Will be automatically destroyed if this step fails. Must be done after vulkan_shader_create().
s | A pointer to the shader to be initialized. |
KAPI b8 renderer_shader_instance_resources_acquire | ( | struct shader * | s, |
u32 | texture_map_count, | ||
texture_map ** | maps, | ||
u32 * | out_instance_id | ||
) |
Acquires internal instance-level resources and provides an instance id.
s | A pointer to the shader to acquire resources from. |
texture_map_count | The number of texture maps used. |
maps | An array of texture map pointers. Must be one per texture in the instance. |
out_instance_id | A pointer to hold the new instance identifier. |
Releases internal instance-level resources for the given instance id.
s | A pointer to the shader to release resources from. |
instance_id | The instance identifier whose resources are to be released. |
KAPI b8 renderer_shader_uniform_set | ( | struct shader * | s, |
struct shader_uniform * | uniform, | ||
const void * | value | ||
) |
Sets the uniform of the given shader to the provided value.
s | A ponter to the shader. |
uniform | A constant pointer to the uniform. |
value | A pointer to the value to be set. |
Uses the given shader, activating it for updates to attributes, uniforms and such, and for use in draw calls.
s | A pointer to the shader to be used. |
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.
memory_requirement | A pointer to hold the memory requirement for this system. |
state | A block of memory to hold state data, or 0 if obtaining memory requirement. |
config | The configuration (renderer_system_config) for the renderer. |
KAPI void renderer_system_shutdown | ( | void * | state | ) |
Shuts the renderer system/frontend down.
state | A pointer to the state block of memory. |
Creates a new texture.
pixels | The raw image data to be uploaded to the GPU. |
texture | A pointer to the texture to be loaded. |
Creates a new writeable texture with no data written to it.
t | A pointer to the texture to hold the resources. |
Destroys the given texture, releasing internal resources from the GPU.
texture | A pointer to the texture to be destroyed. |
KAPI b8 renderer_texture_map_resources_acquire | ( | struct texture_map * | map | ) |
Acquires internal resources for the given texture map.
map | A pointer to the texture map to obtain resources for. |
KAPI void renderer_texture_map_resources_release | ( | struct texture_map * | map | ) |
Releases internal resources for the given texture map.
map | A pointer to the texture map to release resources from. |
Reads the given data from the provided texture.
t | A pointer to the texture to be read from. |
offset | The offset in bytes from the beginning of the data to be read. |
size | The number of bytes to be read. |
out_memory | A pointer to a block of memory to write the read data to. |
Reads a pixel from the provided texture at the given x/y coordinate.
t | A pointer to the texture to be read from. |
x | The pixel x-coordinate. |
y | The pixel y-coordinate. |
out_rgba | A pointer to an array of u8s to hold the pixel data (should be sizeof(u8) * 4) |
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.
t | A pointer to the texture to be resized. |
new_width | The new width in pixels. |
new_height | The new height in pixels. |
Writes the given data to the provided texture.
t | A pointer to the texture to be written to. NOTE: Must be a writeable texture. |
offset | The offset in bytes from the beginning of the data to be written. |
size | The number of bytes to be written. |
pixels | The raw image data to be written. |
KAPI void renderer_viewport_reset | ( | void | ) |
Resets the viewport to the default, which matches the application window. Must be done within a renderpass.
Sets the renderer viewport to the given rectangle. Must be done within a renderpass.
rect | The viewport rectangle to be set. |
KAPI void renderer_winding_set | ( | renderer_winding | winding | ) |
Set the renderer to use the given winding direction.
winding | The winding direction. |
Returns the number of attachments required for window-based render targets.
Attempts to get the window render target at the given index.
index | The index of the attachment to get. Must be within the range of window render target count. |