mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-04-29 10:06:28 +00:00
[client] autodetect monitor refresh rate for fps limit
This commit is contained in:
parent
745ba66119
commit
8ad2d5f949
@ -185,10 +185,10 @@ static struct Option options[] =
|
|||||||
{
|
{
|
||||||
.module = "win",
|
.module = "win",
|
||||||
.name = "fpsLimit",
|
.name = "fpsLimit",
|
||||||
.description = "Frame rate limit (0 = disable - not recommended)",
|
.description = "Frame rate limit (0 = disable - not recommended, -1 = auto detect)",
|
||||||
.shortopt = 'K',
|
.shortopt = 'K',
|
||||||
.type = OPTION_TYPE_INT,
|
.type = OPTION_TYPE_INT,
|
||||||
.value.x_int = 200,
|
.value.x_int = -1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.module = "win",
|
.module = "win",
|
||||||
|
@ -1000,7 +1000,6 @@ int run()
|
|||||||
state.running = true;
|
state.running = true;
|
||||||
state.scaleX = 1.0f;
|
state.scaleX = 1.0f;
|
||||||
state.scaleY = 1.0f;
|
state.scaleY = 1.0f;
|
||||||
state.frameTime = 1e9 / params.fpsLimit;
|
|
||||||
|
|
||||||
state.mouseSens = params.mouseSens;
|
state.mouseSens = params.mouseSens;
|
||||||
if (state.mouseSens < -9) state.mouseSens = -9;
|
if (state.mouseSens < -9) state.mouseSens = -9;
|
||||||
@ -1120,6 +1119,26 @@ int run()
|
|||||||
// ensure renderer viewport is aware of the current window size
|
// ensure renderer viewport is aware of the current window size
|
||||||
updatePositionInfo();
|
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();
|
register_key_binds();
|
||||||
|
|
||||||
// set the compositor hint to bypass for low latency
|
// set the compositor hint to bypass for low latency
|
||||||
|
Loading…
x
Reference in New Issue
Block a user