13 {
16 return 1;
18
23
25 { { 0, 16383, 0, 32767 }, 0xFF0000FF, 0 },
26 { { -16383, -16383, 0, 32767 }, 0xFFFF0000, 0 },
27 { { 16383, -16383, 0, 32767 }, 0xFF00FF00, 0 }
28 };
29
31
35 };
36
38 .fragmentShader = frag,
39 .vertexLayout = {
sizeof(
sbgl_Vertex), 2, attributes } };
40
43
44 printf("--- Triangle Controls ---\n");
45 printf("ESC: Exit\n");
46 printf("-------------------------\n");
47
51
54
55 int width, height;
57
59 .mousePos = { (float)input->
mouseX / (
float)width, (float)input->
mouseY / (
float)height },
61 };
62
67
69 }
70
72
78
79 return 0;
80}
sbgl_InitResult sbgl_Init(int w, int h, const char *title)
Initializes the engine and opens a window.
void sbgl_GetWindowSize(sbgl_Context *ctx, int *w, int *h)
Retrieves the current window dimensions.
bool sbgl_WindowShouldClose(sbgl_Context *ctx)
Checks if the user or OS has requested to close the window.
const sbgl_InputState * sbgl_GetInputState(sbgl_Context *ctx)
Retrieves the input state for the current frame.
sbgl_Pipeline sbgl_CreatePipeline(sbgl_Context *ctx, const sbgl_PipelineConfig *config)
Creates a graphics pipeline.
void sbgl_DestroyShader(sbgl_Context *ctx, sbgl_Shader shader)
Destroys a shader module.
sbgl_Shader sbgl_LoadShader(sbgl_Context *ctx, sbgl_ShaderStage stage, const uint32_t *bytecode, size_t size)
Loads a shader from SPIR-V bytecode.
void sbgl_PushConstants(sbgl_Context *ctx, size_t size, const void *data)
Updates push constants for the currently bound pipeline.
void sbgl_EndDrawing(sbgl_Context *ctx)
Finalizes the current frame and presents it to the screen.
void sbgl_BindPipeline(sbgl_Context *ctx, sbgl_Pipeline pipeline)
Binds a graphics pipeline for subsequent draw calls.
#define sbgl_Clear
Backward compatibility alias for sbgl_SetClearColor.
void sbgl_DestroyBuffer(sbgl_Context *ctx, sbgl_Buffer buffer)
Destroys a GPU buffer.
void sbgl_DeviceWaitIdle(sbgl_Context *ctx)
Synchronizes the CPU with the GPU, waiting for all commands to complete.
double sbgl_GetTime(sbgl_Context *ctx)
Retrieves the current monotonic system time in seconds.
void sbgl_Draw(sbgl_Context *ctx, uint32_t vertexCount, uint32_t firstVertex, uint32_t instanceCount)
Submits a non-indexed draw command.
void sbgl_Shutdown(sbgl_Context *ctx)
Gracefully shuts down the engine and releases all resources.
void sbgl_BeginDrawing(sbgl_Context *ctx)
Prepares the engine for a new frame of drawing.
void sbgl_BindBuffer(sbgl_Context *ctx, sbgl_Buffer buffer, sbgl_BufferUsage usage)
Binds a buffer to the pipeline.
void sbgl_DestroyPipeline(sbgl_Context *ctx, sbgl_Pipeline pipeline)
Destroys a graphics pipeline.
sbgl_Buffer sbgl_CreateBuffer(sbgl_Context *ctx, sbgl_BufferUsage usage, size_t size, const void *data)
Creates a GPU buffer.
@ SBGL_BUFFER_USAGE_VERTEX
@ SBGL_FORMAT_R8G8B8A8_UNORM
@ SBGL_FORMAT_R16G16B16A16_SNORM
uint32_t sbgl_Buffer
Handle for a GPU-side buffer.
uint32_t sbgl_Shader
Handle for a shader module.
@ SBGL_SHADER_STAGE_FRAGMENT
@ SBGL_SHADER_STAGE_VERTEX
uint32_t sbgl_Pipeline
Handle for a graphics pipeline.
Result structure for initialization.
Configuration for creating a graphics pipeline.
Vertex attribute definition.
Standard vertex structure for basic geometry rendering. Optimized for cache density (16 bytes).