SDL_DrawGPUIndexedPrimitives(3)

πŸ’… SDL_DrawGPUIndexedPrimitives(3) πŸ’…

okay bestie, welcome to the SDL3 FUNCTIONS section of the manual, and today's main character is SDL_DrawGPUIndexedPrimitives β€” she draws stuff with an index buffer AND instancing on, like the overachiever she is ✨


🌸 NAME 🌸

SDL_DrawGPUIndexedPrimitives β€” draws data using bound graphics state with an index buffer and instancing enabled. no cap, that's literally the whole job description πŸŽ€


✨ SYNOPSIS ✨

#include <SDL3/SDL_gpu.h>

void SDL_DrawGPUIndexedPrimitives(
    SDL_GPURenderPass *render_pass,
    Uint32 num_indices,
    Uint32 num_instances,
    Uint32 first_index,
    Sint32 vertex_offset,
    Uint32 first_instance);

she's a void, she returns nothing, she simply serves 🫢


πŸ’– DESCRIPTION πŸ’–

okay so first things first, and this is important: you must NOT call this function before binding a graphics pipeline. like, pipeline first, bestie. the vibe check happens in that order, always. πŸ™ˆ

now for the tea β˜• β€” the first_vertex and first_instance parameters are NOT compatible with the built-in vertex/instance ID variables in shaders (think SV_VertexID, that kind of thing). and it's not her fault! GPU APIs and shader languages simply do not define these built-in variables consistently, so they're all out here doing their own thing 😭

so if your shader depends on those built-ins, the only way to keep behavior consistent and portable is to always pass 0 for the correlating parameter in the draw calls. that's it. that's the rule. periodt πŸ’…


🌈 FUNCTION PARAMETERS 🌈

  • render_pass β€” a render pass handle. your backstage pass, your VIP wristband, the whole vibe 🎟️
  • num_indices β€” the number of indices to draw per instance.
  • num_instances β€” the number of instances to draw. how many copies we're serving today πŸ‘‘
  • first_index β€” the starting index within the index buffer. where we begin, babes ⭐
  • vertex_offset β€” a value added to the vertex index before indexing into the vertex buffer. a little nudge, a little offset, we love her for it.
  • first_instance β€” the ID of the first instance to draw.

πŸ¦‹ AVAILABILITY πŸ¦‹

this function is available since SDL 3.2.0 ✨ so if you're on 3.2.0 or later, you're good, you're golden, you're glowing 🌟


and that's the whole page, bestie!! no SEE ALSO section on this one, she's short and sweet and she knows it πŸ’œ

kisses, and remember: pipeline bound first, 0 for the correlating param, and always, always slay πŸŽ€

Simple Directmedia Layer Β· SDL 3.4.18 Β· SDL_DrawGPUIndexedPrimitives(3) β€” mwah, bye!! πŸ’…πŸŒΈπŸ«Ά

πŸ“¦ where this page comes from