SDL_srand(3)

πŸ’– SDL_srand πŸ’–

okay bestie, welcome to the SDL_srand(3) page from the SDL3 FUNCTIONS collection πŸŽ€ this is your lil' corner of SDL_stdinc.h where you get to plant a seed and grow a whole garden of fake-random numbers 🌱✨


✨ NAME ✨

SDL_srand β€” seeds the pseudo-random number generator. that's it, that's the whole job, and she does it flawlessly πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

void SDL_srand(Uint64 seed);

like, look at her. one include, one function call, no drama 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: if you reuse the same seed number, SDL_rand() will repeat the exact same stream of 'random' numbers πŸ”βœ¨ not a different stream, not a "similar" stream β€” the same one, in the same order, every single time. lowkey iconic behavior for reproducibility, highkey a jumpscare if you thought you were getting true chaos πŸ’€


πŸ“ FUNCTION PARAMETERS πŸ“

  • seed β€” the value to use as a random number seed, or 0 to use SDL_GetPerformanceCounter() instead πŸŽ€ (yes, passing 0 means she'll go grab her own entropy-ish number for you, no cap)

🧚 THREAD SAFETY 🧚

this should be called on the same thread that calls SDL_rand() ⚠️ like, keep them together, they're a package deal, do not separate them πŸ™ˆ

bestie please respect this one. different thread = not the vibe you want.

⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0 🌈 (so if you're on something older, she's simply not there yet, sorry babes 😭)


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, mwah πŸ’‹ go forth and seed responsibly ✨

Simple Directmedia Layer made this one, and this particular copy is from SDL 3.4.18 🌸 stay random, stay seeded, and ty for reading my lil' manpage bestie πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from