SDL_GetRenderDriver(3)

๐Ÿ’– SDL_GetRenderDriver ๐Ÿ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we're about to meet the function that tells you the name of a built-in 2D rendering driver. yes. that's the whole gig. she's simple, she's iconic, she serves. ๐ŸŽ€


โœจ NAME โœจ

SDL_GetRenderDriver โ€” use this function to get the name of a built in 2D rendering driver. literally that's it, that's her job, and she does it flawlessly. ๐Ÿ’…


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

#include <SDL3/SDL_render.h>

const char * SDL_GetRenderDriver(int index);

no cap, that's the whole signature. one include, one call, one const char * coming your way. ๐Ÿซถ


๐ŸŒธ DESCRIPTION ๐ŸŒธ

okay so here's the tea. the list of rendering drivers is given in the order that they are normally initialized by default โ€” meaning the drivers that seem more reasonable to choose first (as far as the SDL developers believe, and honestly? they know what they're doing) are earlier in the list. so index 0 is like, the main character, and everything after is a supporting role. โœจ

and the names of drivers? they're all simple, low-ASCII identifiers, like "opengl", "direct3d12" or "metal". these never have Unicode characters in them, and they are not meant to be proper names. so don't go expecting "OpenGLยฎ Deluxe Edition ๐Ÿ’–" โ€” it's just the lowercase string, bestie. lowkey perfect that way. ๐Ÿ™ˆ


๐ŸŽ€ FUNCTION PARAMETERS ๐ŸŽ€

  • index โ€” the index of the rendering driver; the value ranges from 0 to SDL_GetNumRenderDrivers() - 1. so like, respect the range or she's gonna have feelings about it (see RETURN VALUE below ๐Ÿ‘€).

๐Ÿ’œ RETURN VALUE ๐Ÿ’œ

returns the name of the rendering driver at the requested index, or NULL if an invalid index was specified. so if you hand her a bad index, you get NULL. no drama, no crash, just NULL. vibe check failed, respectfully. ๐Ÿ’€


๐Ÿ”ฅ THREAD SAFETY ๐Ÿ”ฅ

it is safe to call this function from any thread. any of them. all of them. go absolutely feral, she does not care. ๐Ÿ‘‘


๐ŸŒˆ AVAILABILITY ๐ŸŒˆ

this function is available since SDL 3.2.0. so if you're on something older, girl, it's giving "please update". โญ


๐Ÿฆ„ SEE ALSO ๐Ÿฆ„

  • SDL_GetNumRenderDrivers(3) โ€” the one that tells you how many drivers there even are. your lil partner in crime for staying inside the index range. ๐Ÿ“

and that's the page, bestie! go forth, loop from 0 to SDL_GetNumRenderDrivers() - 1, and collect those driver names like pokรฉmon. periodt. ๐Ÿ’…โœจ

sign-off szn: this lil masterpiece lives in Simple Directmedia Layer, documenting SDL 3.4.18, and its page is SDL_GetRenderDriver(3). mwah. ๐Ÿซถ๐Ÿ’–

๐Ÿ“ฆ where this page comes from