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, or0to useSDL_GetPerformanceCounter()instead π (yes, passing0means 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
- 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