SDL_RenderGeometryRaw(3)

πŸ’… SDL_RenderGeometryRaw(3) β€” SDL3 FUNCTIONS πŸ’…

okay bestie, sit down, hydrate, and let me tell you about SDL_RenderGeometryRaw β€” it's the SDL3 function that renders a whole list of triangles, and you can throw a texture at it, and you can use indices into the vertex arrays. no cap. ✨

the vibe here is per-vertex color and alpha modulation β€” meaning that for this function, SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are literally ignored. they don't get a seat at this table, they're not in the group chat, they're on read. πŸ’€ the per-vertex stuff is doing all the work instead.


✨ SYNOPSIS ✨

#include <SDL3/SDL_render.h>

bool SDL_RenderGeometryRaw(SDL_Renderer *renderer,
                   SDL_Texture *texture,
                   const float *xy, int xy_stride,
                   const SDL_FColor *color, int color_stride,
                   const float *uv, int uv_stride,
                   int num_vertices,
                   const void *indices, int num_indices, int size_indices);

like, look at that signature. she's long, she's detailed, she knows exactly what she wants. πŸŽ€


🫢 FUNCTION PARAMETERS 🫢

  • renderer β€” the rendering context. this is the main character you're drawing into, the whole stage fr fr. πŸ‘‘
  • texture β€” (optional) the SDL texture to use. optional!! you can absolutely roll up with nothing and just be about the colors. no texture, no problem. πŸ’…
  • xy β€” vertex positions. this is where all your points live, the actual geometry gossip. ✨
  • xy_stride β€” the byte size to move from one element to the next element. yes, bytes. it's telling you how to hop from one entry to the next in your array. πŸ¦‹
  • color β€” vertex colors, and they're SDL_FColor. floaty colors, pretty colors. 🌸
  • color_stride β€” byte size to move from one element to the next element. same deal, but for the colors this time. 🌈
  • uv β€” vertex normalized texture coordinates. this is how your texture knows where it's supposed to land on the triangle. πŸŽ€
  • uv_stride β€” byte size to move from one element to the next element. you already know what this means by now bestie, it's the stride. ⭐
  • num_vertices β€” number of vertices. exactly what it says on the tin, no plot twist. 🧚
  • indices β€” (optional) an array of indices into the 'vertices' arrays. if it's NULL, then all vertices will be rendered in sequential order β€” she'll just go down the list one by one, very organized, very demure. 🫢
  • num_indices β€” number of indices. πŸ’œ
  • size_indices β€” index size: 1 (byte), 2 (short), 4 (int). pick your fighter. πŸ”₯

🌟 RETURN VALUE 🌟

Returns true on success or false on failure. and if it's a false?? call SDL_GetError() for more information, because she WILL tell you what went wrong, you just have to ask. 😭


πŸ”’ THREAD SAFETY πŸ”’

this function should only be called on the main thread. do not pass her around to other threads, she is not built for that kind of chaos, she is monogamous to the main thread. periodt. πŸ™ˆ


πŸ“… AVAILABILITY πŸ“…

this function is available since SDL 3.2.0. so if you're on something older, sorry bestie, you're not getting in. πŸ’€


πŸ‘€ SEE ALSO πŸ‘€

go read those too, they're iconic in their own right. πŸ’–


and that's the whole page!! brought to you by Simple Directmedia Layer, version SDL 3.4.18, and this very manual page SDL_RenderGeometryRaw(3). mwah, love u, go draw some triangles πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from