-
-
Notifications
You must be signed in to change notification settings - Fork 65
Description
Hi,
Currently, the monitor refresh rate seems to be a u32, fetched like this:
foundMode.refreshRate = (u32)XRRConfigCurrentRate(conf);On my system, when I print it I get 120. But there are use cases where you need the accurate refresh rate, which is never exactly 60/120/240...
Again on my system, the accurate value 119.95334291146037, computed as a double.
On X11, you would need to use slightly different API to get the value (see the answer here). Windows and macOS can also give you similar float/double value.
If you want perfect frame pacing on a non-vsync system, you have to do a bunch of maths/stats on frame times, but for that, you need the accurate value of the refresh rate, not the rounded int value.
This is why SDL3 moved from int to float:
typedef struct SDL_DisplayMode
{
SDL_DisplayID displayID; /**< the display this mode is associated with */
SDL_PixelFormat format; /**< pixel format */
int w; /**< width */
int h; /**< height */
float pixel_density; /**< scale converting size to pixels (e.g. a 1920x1080 mode with 2.0 scale would have 3840x2160 pixels) */
float refresh_rate; /**< refresh rate (or 0.0f for unspecified) */
int refresh_rate_numerator; /**< precise refresh rate numerator (or 0 for unspecified) */
int refresh_rate_denominator; /**< precise refresh rate denominator */
SDL_DisplayModeData *internal; /**< Private */
} SDL_DisplayMode;Maybe float gives enough precision? I don´t know.
This would be a API breaking change, so can wait. I maintain my own fork so I'm not stuck.