SDL hints as Quake-style cvars
(This is brought on by #6581 finding out SDL_GetVersion now takes 16 milliseconds.)
Idea: the Hint subsystem should work like quake cvars.
Instead of a callback and a generic SDL_GetHint() function, you do something like this:
static SDL_bool support_foobars = SDL_TRUE; SDL_RegisterHintBool("SDL_SUPPORT_FOOBARS", &support_foobars);This adds this to a list or hash for later use, and sets a default if an environment variable is already set. When someone calls SDL_SetHint("SDL_SUPPORT_FOOBARS", "1"), it updates the variable directly. If a hint is set before it's registered, we'll keep track of it and RegisterHint will work out the bookkeeping like it does for environment variables. One can also mark a hint as locked (once we use it, we don't want the value to change)
Now when SDL needs to check a hint, it just looks at a static variable instead of calling a function, and you don't need a callback just to update one. The end result is that hint lookups are always extremely fast and take less effort to maintain individually, as the complexity moves to a single common piece of code (in the set and register functions).
We can still keep an optional callback mechanism if there's work that needs to be done when a variable is set, but I'm more inclined to say there should be a simple "this has changed since the last time you used it" flag that code can check before using the value.
SDL_GetHint() can remain, in case a hint needs to be looked up by name, but internally, SDL can just look at variables internally.
Originally posted by @icculus in https://github.com/libsdl-org/SDL/issues/3519#issuecomment-1324206292