SDL_DrawGPUPrimitives(3)
π SDL_DrawGPUPrimitives π
okay bestie, so this is a page from the SDL3 FUNCTIONS corner of the SDL_DrawGPUPrimitives(3) manual, and it is literally about drawing data using bound graphics state. slay. let's get into it π
β¨ NAME β¨
SDL_DrawGPUPrimitives β Draws data using bound graphics state. that's it, that's the whole job π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_gpu.h>
void SDL_DrawGPUPrimitives(
SDL_GPURenderPass *render_pass,
Uint32 num_vertices,
Uint32 num_instances,
Uint32 first_vertex,
Uint32 first_instance);
copy that include and that signature exactly, no improvising, iykyk π¦
π DESCRIPTION π
first things first, and this is the big one: you must not call this function before binding a graphics pipeline. like, not even a little. bind first, draw second, periodt. π
now the tea β β first_vertex and first_instance are NOT compatible with the built-in vertex/instance ID variables in shaders (think SV_VertexID and friends). why? because GPU APIs and shader languages do not define these built-in variables consistently across the board. so if your shader depends on them, the only way to keep behavior consistent and portable is to always pass 0 for the correlating parameter in the draw calls. no cap, that's the move. π
π«Ά FUNCTION PARAMETERS π«Ά
render_passβ a render pass handle. your lil ticket to the render party ποΈnum_verticesβ the number of vertices to draw. count 'em πnum_instancesβ the number of instances that will be drawn. yes, instances, plural, we're fancy β¨first_vertexβ the index of the first vertex to draw. where the vertex party starts πfirst_instanceβ the ID of the first instance to draw. where the instance party starts π¦
β AVAILABILITY β
this function is available since SDL 3.2.0. if you're on anything older, bestie, it's giving β¨not yetβ¨ π
quick vibe check: bind your graphics pipeline first, and if your shader leans on built-in vertex/instance IDs, pass 0 for the correlating parameter. that's the whole portability survival kit π§
and that's the page!! brought to you by Simple Directmedia Layer, running on SDL 3.4.18 β mwah, go draw some primitives, you absolute icon πππ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms