|
SBgl 0.1.0
A graphics framework in C99
|
API for the SiputBiru Graphics Library (SBgl). More...
#include "sbgl_types.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "sbgl_input.h"

Go to the source code of this file.
Functions | |
| sbgl_Result | sbgl_GetResult (sbgl_Context *ctx) |
| Retrieves the last result code from the context. | |
| sbgl_ErrorDetail | sbgl_GetErrorDetail (sbgl_Context *ctx) |
| Retrieves detailed error information including backend-specific codes. | |
| void | sbgl_ClearResult (sbgl_Context *ctx) |
| Clears the result code to SBGL_SUCCESS. | |
| sbgl_InitResult | sbgl_InitWithConfig (const sbgl_InitConfig *config) |
| Initializes the engine and opens a window with explicit configuration. | |
| sbgl_InitResult | sbgl_Init (int w, int h, const char *title) |
| Initializes the engine and opens a window. | |
| void | sbgl_Shutdown (sbgl_Context *ctx) |
| Gracefully shuts down the engine and releases all resources. | |
| bool | sbgl_WindowShouldClose (sbgl_Context *ctx) |
| Checks if the user or OS has requested to close the window. | |
| double | sbgl_GetTime (sbgl_Context *ctx) |
| Retrieves the current monotonic system time in seconds. | |
| void | sbgl_GetWindowSize (sbgl_Context *ctx, int *w, int *h) |
| Retrieves the current window dimensions. | |
| void | sbgl_BeginDrawing (sbgl_Context *ctx) |
| Prepares the engine for a new frame of drawing. | |
| void | sbgl_EndDrawing (sbgl_Context *ctx) |
| Finalizes the current frame and presents it to the screen. | |
| void | sbgl_BeginCompute (sbgl_Context *ctx) |
| Prepares the engine for compute operations before the main drawing pass. | |
| void | sbgl_EndCompute (sbgl_Context *ctx) |
| Finalizes the compute phase. | |
| void | sbgl_DeviceWaitIdle (sbgl_Context *ctx) |
| Synchronizes the CPU with the GPU, waiting for all commands to complete. | |
| void | sbgl_SetClearColor (sbgl_Context *ctx, float r, float g, float b, float a) |
| Sets the clear color for the next frame. | |
| const sbgl_InputState * | sbgl_GetInputState (sbgl_Context *ctx) |
| Retrieves the input state for the current frame. | |
| void | sbgl_SetMouseMode (sbgl_Context *ctx, sbgl_MouseMode mode) |
| Sets the cursor behavior and visibility. | |
| sbgl_Telemetry | sbgl_GetTelemetry (sbgl_Context *ctx) |
| Retrieves the performance telemetry data for the previous frame. | |
| sbgl_Buffer | sbgl_CreateBuffer (sbgl_Context *ctx, sbgl_BufferUsage usage, size_t size, const void *data) |
| Creates a GPU buffer. | |
| void | sbgl_DestroyBuffer (sbgl_Context *ctx, sbgl_Buffer buffer) |
| Destroys a GPU buffer. | |
| void | sbgl_FillBuffer (sbgl_Context *ctx, sbgl_Buffer buffer, size_t offset, size_t size, uint32_t value) |
| Fills a region of a GPU buffer with a fixed 32-bit value. | |
| uint32_t | sbgl_GetFrameIndex (sbgl_Context *ctx) |
| Retrieves the current frame index for double/triple buffering. | |
| sbgl_Shader | sbgl_LoadShader (sbgl_Context *ctx, sbgl_ShaderStage stage, const uint32_t *bytecode, size_t size) |
| Loads a shader from SPIR-V bytecode. | |
| sbgl_Shader | sbgl_LoadShaderFromFile (sbgl_Context *ctx, sbgl_ShaderStage stage, const char *filename) |
| Helper function to load a shader directly from a SPIR-V file. | |
| void | sbgl_DestroyShader (sbgl_Context *ctx, sbgl_Shader shader) |
| Destroys a shader module. | |
| void * | sbgl_MapBuffer (sbgl_Context *ctx, sbgl_Buffer buffer) |
| Maps a GPU buffer into the CPU's address space. | |
| void | sbgl_UnmapBuffer (sbgl_Context *ctx, sbgl_Buffer buffer) |
| Unmaps a previously mapped GPU buffer. | |
| sbgl_Pipeline | sbgl_CreatePipeline (sbgl_Context *ctx, const sbgl_PipelineConfig *config) |
| Creates a graphics pipeline. | |
| void | sbgl_DestroyPipeline (sbgl_Context *ctx, sbgl_Pipeline pipeline) |
| Destroys a graphics pipeline. | |
| sbgl_ComputePipeline | sbgl_CreateComputePipeline (sbgl_Context *ctx, sbgl_Shader shader) |
| Creates a compute pipeline. | |
| void | sbgl_DestroyComputePipeline (sbgl_Context *ctx, sbgl_ComputePipeline pipeline) |
| Destroys a compute pipeline. | |
| void | sbgl_BindComputePipeline (sbgl_Context *ctx, sbgl_ComputePipeline pipeline) |
| Binds a compute pipeline for subsequent dispatch calls. | |
| void | sbgl_DispatchCompute (sbgl_Context *ctx, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) |
| Dispatches a compute workload. | |
| void | sbgl_MemoryBarrier (sbgl_Context *ctx, sbgl_BarrierType type) |
| Injects a memory barrier to synchronize compute and graphics operations. | |
| void | sbgl_BindPipeline (sbgl_Context *ctx, sbgl_Pipeline pipeline) |
| Binds a graphics pipeline for subsequent draw calls. | |
| void | sbgl_BindBuffer (sbgl_Context *ctx, sbgl_Buffer buffer, sbgl_BufferUsage usage) |
| Binds a buffer to the pipeline. | |
| uint64_t | sbgl_GetBufferDeviceAddress (sbgl_Context *ctx, sbgl_Buffer buffer) |
| Retrieves the 64-bit GPU virtual address for a buffer. | |
| void | sbgl_Draw (sbgl_Context *ctx, uint32_t vertexCount, uint32_t firstVertex, uint32_t instanceCount) |
| Submits a non-indexed draw command. | |
| void | sbgl_DrawIndexed (sbgl_Context *ctx, uint32_t indexCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t instanceCount) |
| Submits an indexed draw command. | |
| void | sbgl_DrawIndirect (sbgl_Context *ctx, sbgl_Buffer buffer, size_t offset, uint32_t drawCount) |
| Submits a batch of draw calls stored in a GPU buffer. | |
| void | sbgl_PushConstants (sbgl_Context *ctx, size_t size, const void *data) |
| Updates push constants for the currently bound pipeline. | |
| sbgl_RenderQueue * | sbgl_CreateRenderQueue (sbgl_Context *ctx, struct SblArena *arena) |
| Creates a thread-local render queue for collecting draw commands. | |
| void | sbgl_SubmitDraw (sbgl_RenderQueue *queue, uint32_t mesh, uint32_t material, uint32_t blendMode, uint32_t sidedness, uint32_t tags, sbgl_SortKey key, const sbgl_InstanceData *data) |
| Appends a draw command to the render queue. | |
| void | sbgl_RenderQueues (sbgl_Context *ctx, sbgl_RenderQueue **queues, uint32_t queueCount, const sbgl_Mat4 *viewProj) |
| Merges, sorts, and submits pending draw commands to the GPU. | |
| void | sbgl_RenderQueuesEx (sbgl_Context *ctx, sbgl_RenderQueue **queues, uint32_t queueCount, const sbgl_Mat4 *viewProj, uint64_t userAddress) |
| Extended version of sbgl_RenderQueues with user metadata. | |
API for the SiputBiru Graphics Library (SBgl).
This header defines the interface for window management, frame lifecycle, and input handling.
Definition in file sbgl.h.
| #define sbgl_Clear sbgl_SetClearColor |
| #define SBGL_KEY_0 SBGL_SCANCODE_0 |
| #define SBGL_KEY_1 SBGL_SCANCODE_1 |
| #define SBGL_KEY_2 SBGL_SCANCODE_2 |
| #define SBGL_KEY_3 SBGL_SCANCODE_3 |
| #define SBGL_KEY_4 SBGL_SCANCODE_4 |
| #define SBGL_KEY_5 SBGL_SCANCODE_5 |
| #define SBGL_KEY_6 SBGL_SCANCODE_6 |
| #define SBGL_KEY_7 SBGL_SCANCODE_7 |
| #define SBGL_KEY_8 SBGL_SCANCODE_8 |
| #define SBGL_KEY_9 SBGL_SCANCODE_9 |
| #define SBGL_KEY_A SBGL_SCANCODE_A |
| #define SBGL_KEY_B SBGL_SCANCODE_B |
| #define SBGL_KEY_BACKSPACE SBGL_SCANCODE_BACKSPACE |
| #define SBGL_KEY_C SBGL_SCANCODE_C |
| #define SBGL_KEY_D SBGL_SCANCODE_D |
| #define SBGL_KEY_DOWN SBGL_SCANCODE_DOWN |
| #define SBGL_KEY_E SBGL_SCANCODE_E |
| #define SBGL_KEY_EQUAL SBGL_SCANCODE_EQUAL |
| #define SBGL_KEY_ESCAPE SBGL_SCANCODE_ESCAPE |
| #define SBGL_KEY_F SBGL_SCANCODE_F |
| #define SBGL_KEY_G SBGL_SCANCODE_G |
| #define SBGL_KEY_H SBGL_SCANCODE_H |
| #define SBGL_KEY_I SBGL_SCANCODE_I |
| #define SBGL_KEY_J SBGL_SCANCODE_J |
| #define SBGL_KEY_K SBGL_SCANCODE_K |
| #define SBGL_KEY_L SBGL_SCANCODE_L |
| #define SBGL_KEY_LALT SBGL_SCANCODE_LALT |
| #define SBGL_KEY_LCTRL SBGL_SCANCODE_LCTRL |
| #define SBGL_KEY_LEFT SBGL_SCANCODE_LEFT |
| #define SBGL_KEY_LSHIFT SBGL_SCANCODE_LSHIFT |
| #define SBGL_KEY_M SBGL_SCANCODE_M |
| #define SBGL_KEY_MINUS SBGL_SCANCODE_MINUS |
| #define SBGL_KEY_N SBGL_SCANCODE_N |
| #define SBGL_KEY_O SBGL_SCANCODE_O |
| #define SBGL_KEY_P SBGL_SCANCODE_P |
| #define SBGL_KEY_Q SBGL_SCANCODE_Q |
| #define SBGL_KEY_R SBGL_SCANCODE_R |
| #define SBGL_KEY_RETURN SBGL_SCANCODE_RETURN |
| #define SBGL_KEY_RIGHT SBGL_SCANCODE_RIGHT |
| #define SBGL_KEY_S SBGL_SCANCODE_S |
| #define SBGL_KEY_SPACE SBGL_SCANCODE_SPACE |
| #define SBGL_KEY_T SBGL_SCANCODE_T |
| #define SBGL_KEY_TAB SBGL_SCANCODE_TAB |
| #define SBGL_KEY_U SBGL_SCANCODE_U |
| #define SBGL_KEY_UNKNOWN SBGL_SCANCODE_UNKNOWN |
| #define SBGL_KEY_UP SBGL_SCANCODE_UP |
| #define SBGL_KEY_V SBGL_SCANCODE_V |
| #define SBGL_KEY_W SBGL_SCANCODE_W |
| #define SBGL_KEY_X SBGL_SCANCODE_X |
| #define SBGL_KEY_Y SBGL_SCANCODE_Y |
| #define SBGL_KEY_Z SBGL_SCANCODE_Z |
| #define SBGL_MOUSE_LEFT SBGL_MOUSE_BUTTON_LEFT |
| #define SBGL_MOUSE_MIDDLE SBGL_MOUSE_BUTTON_MIDDLE |
| #define SBGL_MOUSE_RIGHT SBGL_MOUSE_BUTTON_RIGHT |
| void sbgl_BeginCompute | ( | sbgl_Context * | ctx | ) |
Prepares the engine for compute operations before the main drawing pass.
If a frame has not yet been started, this function initiates the frame lifecycle, acquiring a swapchain image and starting the command buffer. It must be called outside of a BeginDrawing/EndDrawing block.
| ctx | The engine context. |
Definition at line 344 of file sbgl_core.c.
| void sbgl_BeginDrawing | ( | sbgl_Context * | ctx | ) |
Prepares the engine for a new frame of drawing.
This function handles event polling and Vulkan swapchain image acquisition. It is called before clearing or drawing commands.
| ctx | The engine context. |
Definition at line 262 of file sbgl_core.c.
| void sbgl_BindBuffer | ( | sbgl_Context * | ctx, |
| sbgl_Buffer | buffer, | ||
| sbgl_BufferUsage | usage ) |
Binds a buffer to the pipeline.
| ctx | The engine context. |
| buffer | The buffer handle. |
| usage | The usage to bind it as (Vertex/Index). |
Definition at line 681 of file sbgl_core.c.
| void sbgl_BindComputePipeline | ( | sbgl_Context * | ctx, |
| sbgl_ComputePipeline | pipeline ) |
Binds a compute pipeline for subsequent dispatch calls.
| ctx | The engine context. |
| pipeline | The compute pipeline handle. |
Definition at line 649 of file sbgl_core.c.
| void sbgl_BindPipeline | ( | sbgl_Context * | ctx, |
| sbgl_Pipeline | pipeline ) |
Binds a graphics pipeline for subsequent draw calls.
| ctx | The engine context. |
| pipeline | The pipeline handle. |
Definition at line 673 of file sbgl_core.c.
| void sbgl_ClearResult | ( | sbgl_Context * | ctx | ) |
Clears the result code to SBGL_SUCCESS.
| ctx | The engine context (may be NULL). |
Definition at line 103 of file sbgl_core.c.
| sbgl_Buffer sbgl_CreateBuffer | ( | sbgl_Context * | ctx, |
| sbgl_BufferUsage | usage, | ||
| size_t | size, | ||
| const void * | data ) |
Creates a GPU buffer.
| ctx | The engine context. |
| usage | Intended usage of the buffer (Vertex/Index). |
| size | Size in bytes. |
| data | Optional initial data. If NULL, the buffer is created empty. |
Definition at line 445 of file sbgl_core.c.
| sbgl_ComputePipeline sbgl_CreateComputePipeline | ( | sbgl_Context * | ctx, |
| sbgl_Shader | shader ) |
Creates a compute pipeline.
| ctx | The engine context. |
| shader | The compute shader handle. |
Definition at line 619 of file sbgl_core.c.
| sbgl_Pipeline sbgl_CreatePipeline | ( | sbgl_Context * | ctx, |
| const sbgl_PipelineConfig * | config ) |
Creates a graphics pipeline.
| ctx | The engine context. |
| config | Configuration for the pipeline. |
Definition at line 587 of file sbgl_core.c.
| sbgl_RenderQueue * sbgl_CreateRenderQueue | ( | sbgl_Context * | ctx, |
| struct SblArena * | arena ) |
Creates a thread-local render queue for collecting draw commands.
Draw packets are stored in this queue and submitted to the backend for rendering. Multiple queues enable parallel command recording.
| ctx | The engine context. |
| arena | The arena to use for queue allocations. |
Definition at line 743 of file sbgl_core.c.
| void sbgl_DestroyBuffer | ( | sbgl_Context * | ctx, |
| sbgl_Buffer | buffer ) |
Destroys a GPU buffer.
All submitted GPU commands referencing this buffer must have completed before calling this. Use sbgl_DeviceWaitIdle() to synchronize.
| ctx | The engine context. |
| buffer | The buffer handle. |
Definition at line 457 of file sbgl_core.c.
| void sbgl_DestroyComputePipeline | ( | sbgl_Context * | ctx, |
| sbgl_ComputePipeline | pipeline ) |
Destroys a compute pipeline.
| ctx | The engine context. |
| pipeline | The compute pipeline handle. |
Definition at line 629 of file sbgl_core.c.
| void sbgl_DestroyPipeline | ( | sbgl_Context * | ctx, |
| sbgl_Pipeline | pipeline ) |
Destroys a graphics pipeline.
The pipeline must not be in use by any submitted command buffers. Use sbgl_DeviceWaitIdle() to ensure safe destruction.
| ctx | The engine context. |
| pipeline | The pipeline handle. |
Definition at line 597 of file sbgl_core.c.
| void sbgl_DestroyShader | ( | sbgl_Context * | ctx, |
| sbgl_Shader | shader ) |
Destroys a shader module.
Shaders must not be in use by the GPU. Use sbgl_DeviceWaitIdle() before destruction during shutdown.
| ctx | The engine context. |
| shader | The shader handle. |
Definition at line 565 of file sbgl_core.c.
| void sbgl_DeviceWaitIdle | ( | sbgl_Context * | ctx | ) |
Synchronizes the CPU with the GPU, waiting for all commands to complete.
This is called before destroying resources (Pipelines, Buffers, Shaders) to ensure they are no longer in use by the GPU. Failure to do so results in Vulkan validation errors and instability.
| ctx | The engine context. |
Definition at line 391 of file sbgl_core.c.
| void sbgl_DispatchCompute | ( | sbgl_Context * | ctx, |
| uint32_t | groupCountX, | ||
| uint32_t | groupCountY, | ||
| uint32_t | groupCountZ ) |
Dispatches a compute workload.
| ctx | The engine context. |
| groupCountX | Number of workgroups in X dimension. |
| groupCountY | Number of workgroups in Y dimension. |
| groupCountZ | Number of workgroups in Z dimension. |
Definition at line 657 of file sbgl_core.c.
| void sbgl_Draw | ( | sbgl_Context * | ctx, |
| uint32_t | vertexCount, | ||
| uint32_t | firstVertex, | ||
| uint32_t | instanceCount ) |
Submits a non-indexed draw command.
| ctx | The engine context. |
| vertexCount | Number of vertices to draw. |
| firstVertex | Offset to the first vertex. |
| instanceCount | Number of instances to draw. |
Definition at line 698 of file sbgl_core.c.
| void sbgl_DrawIndexed | ( | sbgl_Context * | ctx, |
| uint32_t | indexCount, | ||
| uint32_t | firstIndex, | ||
| int32_t | vertexOffset, | ||
| uint32_t | instanceCount ) |
Submits an indexed draw command.
| ctx | The engine context. |
| indexCount | Number of indices to draw. |
| firstIndex | Offset to the first index. |
| vertexOffset | Value added to each index before indexing into vertex buffers. |
| instanceCount | Number of instances to draw. |
Definition at line 706 of file sbgl_core.c.
| void sbgl_DrawIndirect | ( | sbgl_Context * | ctx, |
| sbgl_Buffer | buffer, | ||
| size_t | offset, | ||
| uint32_t | drawCount ) |
Submits a batch of draw calls stored in a GPU buffer.
| ctx | The engine context. |
| buffer | Handle to the buffer containing an array of sbgl_IndirectCommand. |
| offset | The byte offset into the buffer where the commands begin. |
| drawCount | The number of commands to execute from the buffer. |
Definition at line 720 of file sbgl_core.c.
| void sbgl_EndCompute | ( | sbgl_Context * | ctx | ) |
Finalizes the compute phase.
This function is semantically symmetrical to sbgl_BeginCompute. It does not submit the frame; that is still handled by sbgl_EndDrawing.
| ctx | The engine context. |
Definition at line 385 of file sbgl_core.c.
| void sbgl_EndDrawing | ( | sbgl_Context * | ctx | ) |
Finalizes the current frame and presents it to the screen.
This function submits the recorded GPU commands and swaps the buffer.
| ctx | The engine context. |
Definition at line 315 of file sbgl_core.c.
| void sbgl_FillBuffer | ( | sbgl_Context * | ctx, |
| sbgl_Buffer | buffer, | ||
| size_t | offset, | ||
| size_t | size, | ||
| uint32_t | value ) |
Fills a region of a GPU buffer with a fixed 32-bit value.
This operation is performed on the GPU and is highly efficient for clearing counters or initializing large memory regions.
| ctx | The engine context. |
| buffer | The buffer handle. |
| offset | Byte offset into the buffer. |
| size | Number of bytes to fill. Must be a multiple of 4. |
| value | The 32-bit value to fill with. |
Definition at line 480 of file sbgl_core.c.
| uint64_t sbgl_GetBufferDeviceAddress | ( | sbgl_Context * | ctx, |
| sbgl_Buffer | buffer ) |
Retrieves the 64-bit GPU virtual address for a buffer.
This address is used for Buffer Device Address (BDA) lookups in shaders.
| ctx | The engine context. |
| buffer | The buffer handle. |
Definition at line 689 of file sbgl_core.c.
| sbgl_ErrorDetail sbgl_GetErrorDetail | ( | sbgl_Context * | ctx | ) |
Retrieves detailed error information including backend-specific codes.
| ctx | The engine context (may be NULL). |
Definition at line 78 of file sbgl_core.c.
| uint32_t sbgl_GetFrameIndex | ( | sbgl_Context * | ctx | ) |
Retrieves the current frame index for double/triple buffering.
| ctx | The engine context. |
Definition at line 489 of file sbgl_core.c.
| const sbgl_InputState * sbgl_GetInputState | ( | sbgl_Context * | ctx | ) |
Retrieves the input state for the current frame.
Adheres to Data-Oriented Design by providing a read-only view of input arrays (keys, mouse) for batch processing.
| ctx | The engine context. |
Definition at line 413 of file sbgl_core.c.
| sbgl_Result sbgl_GetResult | ( | sbgl_Context * | ctx | ) |
Retrieves the last result code from the context.
| ctx | The engine context (may be NULL). |
Definition at line 71 of file sbgl_core.c.
| sbgl_Telemetry sbgl_GetTelemetry | ( | sbgl_Context * | ctx | ) |
Retrieves the performance telemetry data for the previous frame.
| ctx | The active engine context. |
Definition at line 436 of file sbgl_core.c.
| double sbgl_GetTime | ( | sbgl_Context * | ctx | ) |
Retrieves the current monotonic system time in seconds.
This timer is high-resolution and suitable for frame-time calculation.
| ctx | The active engine context. |
Definition at line 245 of file sbgl_core.c.
| void sbgl_GetWindowSize | ( | sbgl_Context * | ctx, |
| int * | w, | ||
| int * | h ) |
Retrieves the current window dimensions.
| ctx | The active engine context. |
| w | Pointer to store the width. |
| h | Pointer to store the height. |
Definition at line 252 of file sbgl_core.c.
| sbgl_InitResult sbgl_Init | ( | int | w, |
| int | h, | ||
| const char * | title ) |
Initializes the engine and opens a window.
This function sets up the internal HALs and the Vulkan 1.3 backend. It is a convenience wrapper around sbgl_InitWithConfig() that uses default resource limits and enables validation in debug builds.
| w | Desired width of the window. |
| h | Desired height of the window. |
| title | Title displayed in the OS window manager. |
Definition at line 193 of file sbgl_core.c.
| sbgl_InitResult sbgl_InitWithConfig | ( | const sbgl_InitConfig * | config | ) |
Initializes the engine and opens a window with explicit configuration.
This function sets up the internal HALs and the Vulkan 1.3 backend using the provided configuration. This allows fine-grained control over resource limits and validation settings.
| config | Pointer to the initialization configuration. |
Definition at line 112 of file sbgl_core.c.
| sbgl_Shader sbgl_LoadShader | ( | sbgl_Context * | ctx, |
| sbgl_ShaderStage | stage, | ||
| const uint32_t * | bytecode, | ||
| size_t | size ) |
Loads a shader from SPIR-V bytecode.
| ctx | The engine context. |
| stage | The shader stage (Vertex/Fragment). |
| bytecode | Pointer to the SPIR-V bytecode. |
| size | Size of the bytecode in bytes. |
Definition at line 523 of file sbgl_core.c.
| sbgl_Shader sbgl_LoadShaderFromFile | ( | sbgl_Context * | ctx, |
| sbgl_ShaderStage | stage, | ||
| const char * | filename ) |
Helper function to load a shader directly from a SPIR-V file.
| ctx | The engine context. |
| stage | The shader stage (Vertex/Fragment). |
| filename | Path to the SPIR-V file. |
Definition at line 534 of file sbgl_core.c.
| void * sbgl_MapBuffer | ( | sbgl_Context * | ctx, |
| sbgl_Buffer | buffer ) |
Maps a GPU buffer into the CPU's address space.
This allows for direct reading from and writing to GPU memory. SBgl buffers are created as host-visible and coherent by default.
| ctx | The engine context. |
| buffer | The buffer handle. |
Definition at line 497 of file sbgl_core.c.
| void sbgl_MemoryBarrier | ( | sbgl_Context * | ctx, |
| sbgl_BarrierType | type ) |
Injects a memory barrier to synchronize compute and graphics operations.
| ctx | The engine context. |
| type | The type of barrier to inject. |
Definition at line 665 of file sbgl_core.c.
| void sbgl_PushConstants | ( | sbgl_Context * | ctx, |
| size_t | size, | ||
| const void * | data ) |
Updates push constants for the currently bound pipeline.
| ctx | The engine context. |
| size | Size of the data to push. |
| data | Pointer to the data. |
Definition at line 733 of file sbgl_core.c.
| void sbgl_RenderQueues | ( | sbgl_Context * | ctx, |
| sbgl_RenderQueue ** | queues, | ||
| uint32_t | queueCount, | ||
| const sbgl_Mat4 * | viewProj ) |
Merges, sorts, and submits pending draw commands to the GPU.
This function processes render queues in a batching operation. A stable radix sort is performed on the packets to minimize state transitions, followed by baking them into indirect draw commands.
| ctx | The engine context. |
| queues | Array of pointers to the render queues to be processed. |
| queueCount | Number of queues in the array. |
| viewProj | Pointer to the view-projection matrix for the frame. |
Definition at line 808 of file sbgl_core.c.
| void sbgl_RenderQueuesEx | ( | sbgl_Context * | ctx, |
| sbgl_RenderQueue ** | queues, | ||
| uint32_t | queueCount, | ||
| const sbgl_Mat4 * | viewProj, | ||
| uint64_t | userAddress ) |
Extended version of sbgl_RenderQueues with user metadata.
| ctx | The engine context. |
| queues | Array of render queues. |
| queueCount | Number of queues. |
| viewProj | View-projection matrix. |
| userAddress | A 64-bit GPU address for user-defined data (e.g., SSBO heightmap). |
Definition at line 817 of file sbgl_core.c.
| void sbgl_SetClearColor | ( | sbgl_Context * | ctx, |
| float | r, | ||
| float | g, | ||
| float | b, | ||
| float | a ) |
Sets the clear color for the next frame.
| ctx | The engine context. |
| r | Red component (0.0 to 1.0). |
| g | Green component (0.0 to 1.0). |
| b | Blue component (0.0 to 1.0). |
| a | Alpha component (0.0 to 1.0). |
Definition at line 401 of file sbgl_core.c.
| void sbgl_SetMouseMode | ( | sbgl_Context * | ctx, |
| sbgl_MouseMode | mode ) |
Sets the cursor behavior and visibility.
| ctx | The engine context. |
| mode | The desired mouse mode. |
Definition at line 422 of file sbgl_core.c.
| void sbgl_Shutdown | ( | sbgl_Context * | ctx | ) |
Gracefully shuts down the engine and releases all resources.
| ctx | The context to destroy. |
Definition at line 204 of file sbgl_core.c.
| void sbgl_SubmitDraw | ( | sbgl_RenderQueue * | queue, |
| uint32_t | mesh, | ||
| uint32_t | material, | ||
| uint32_t | blendMode, | ||
| uint32_t | sidedness, | ||
| uint32_t | tags, | ||
| sbgl_SortKey | key, | ||
| const sbgl_InstanceData * | data ) |
Appends a draw command to the render queue.
The packets are cached in the queue until the next frame.
| queue | The render queue to append to. |
| mesh | The mesh identifier. |
| material | The material identifier. |
| blendMode | The blend mode identifier. |
| sidedness | The sidedness flag (e.g., single/double sided). |
| tags | Custom user tags for filtering. |
| key | The sort key for minimizing state changes. |
| data | Pointer to the per-instance data (transform, color, etc). |
Definition at line 772 of file sbgl_core.c.
| void sbgl_UnmapBuffer | ( | sbgl_Context * | ctx, |
| sbgl_Buffer | buffer ) |
Unmaps a previously mapped GPU buffer.
| ctx | The engine context. |
| buffer | The buffer handle. |
Definition at line 511 of file sbgl_core.c.
| bool sbgl_WindowShouldClose | ( | sbgl_Context * | ctx | ) |
Checks if the user or OS has requested to close the window.
This flag is set by the OS (for instance, clicking the 'X' button or Alt+F4). The application polls this flag in the main loop and manually initiates shutdown by calling sbgl_Shutdown() when it returns true.
| ctx | The active engine context. |
Definition at line 238 of file sbgl_core.c.