mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-22 13:52:57 +00:00
[client] autodetect monitor refresh rate for fps limit
This commit is contained in:
parent
745ba66119
commit
8ad2d5f949
2 changed files with 22 additions and 3 deletions
|
@ -185,10 +185,10 @@ static struct Option options[] =
|
|||
{
|
||||
.module = "win",
|
||||
.name = "fpsLimit",
|
||||
.description = "Frame rate limit (0 = disable - not recommended)",
|
||||
.description = "Frame rate limit (0 = disable - not recommended, -1 = auto detect)",
|
||||
.shortopt = 'K',
|
||||
.type = OPTION_TYPE_INT,
|
||||
.value.x_int = 200,
|
||||
.value.x_int = -1,
|
||||
},
|
||||
{
|
||||
.module = "win",
|
||||
|
|
|
@ -1000,7 +1000,6 @@ int run()
|
|||
state.running = true;
|
||||
state.scaleX = 1.0f;
|
||||
state.scaleY = 1.0f;
|
||||
state.frameTime = 1e9 / params.fpsLimit;
|
||||
|
||||
state.mouseSens = params.mouseSens;
|
||||
if (state.mouseSens < -9) state.mouseSens = -9;
|
||||
|
@ -1120,6 +1119,26 @@ int run()
|
|||
// ensure renderer viewport is aware of the current window size
|
||||
updatePositionInfo();
|
||||
|
||||
//Auto detect active monitor refresh rate for FPS Limit if no FPS Limit was passed.
|
||||
if (params.fpsLimit == -1)
|
||||
{
|
||||
SDL_DisplayMode current;
|
||||
if (SDL_GetCurrentDisplayMode(SDL_GetWindowDisplayIndex(state.window), ¤t) == 0)
|
||||
{
|
||||
state.frameTime = 1e9 / (current.refresh_rate * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_WARN("Unable to capture monitor refresh rate using the default FPS Limit: 200");
|
||||
state.frameTime = 1e9 / 200;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_INFO("Using the FPS Limit from args: %d", params.fpsLimit);
|
||||
state.frameTime = 1e9 / params.fpsLimit;
|
||||
}
|
||||
|
||||
register_key_binds();
|
||||
|
||||
// set the compositor hint to bypass for low latency
|
||||
|
|
Loading…
Reference in a new issue