Page 1 of 1
Turning off VSync
Posted: Fri Nov 29, 2019 12:46 am
by Davoo
I'm sure I'm missing something obvious, but my conf.lua file is as follows:
Code: Select all
function love.conf(t)
t.console = true
t.window.vsync = 0
t.modules.physics = false
end
And yet my FPS remains locked at 60. My conf file definitely works, I can disable the console, for instance.
I even cracked open my own love.run() and commented out the 1,000 FPS cap:
Code: Select all
--if love.timer then love.timer.sleep(0.001) end
Just to see what would happen, and nothing changed at all. I confirmed it's not a limitation of my hardware. I copy+pasted the update function:
Code: Select all
if love.update then
love.update(dt)
love.update(dt)
love.update(dt)
love.update(dt)
end
And the game would run at 4x speed no problem. The computer than runs at 30fps is about the same speed as the one I'm deving in.
I have read several old posts in this forum explaining how to disable VSync, and quintuple-checked the Wiki. I cannot find any further explanation. Thanks in advance for the help
Re: Turning off VSync
Posted: Fri Nov 29, 2019 3:05 am
by raidho36
In Lua, everything except "nil" and "false" resolves to "true". You need to specifically set it to "false".
Check if your GPU settings enforces vsync for all games.
Re: Turning off VSync
Posted: Fri Nov 29, 2019 12:40 pm
by Davoo
Re: resolving to true
I have tried both false (what the Wiki said used to be the way to turn off VSync) and 0 (what the Wiki says to do now)
Re: GPU settings
This turned out to be the source of the problem, thank you! I poked into my Nvidia settings and can now blaze around my game at 500fps (don't know why it's not 1k but w/e.)
Based on what I understand, it doesn't seem like there's any elegant solution to ensure the game runs at 60fps on everyone's computer. I suppose I can use
love.timer.getAverageDelta() to check the FPS. And then if the result hovers around 30, I can run
love.update() a second time. That feels to me like a terribly, horribly Swiss cheese workaround solution, but I guess this is the kind of thing software engineers have to do all the time to cope with environment variables. I guess...?
Re: Turning off VSync
Posted: Fri Nov 29, 2019 1:36 pm
by zorg
Davoo wrote: ↑Fri Nov 29, 2019 12:40 pm
Based on what I understand, it doesn't seem like there's any elegant solution to ensure the game runs at 60fps on everyone's computer. I suppose I can use
love.timer.getAverageDelta() to check the FPS. And then if the result hovers around 30,
I can run love.update() a second time. That feels to me like a terribly, horribly Swiss cheese workaround solution, but I guess this is the kind of thing software engineers have to do all the time to cope with environment variables. I guess...?
No, it is a horrible workaround; the correct way would be to make your logic framerate independent; there are a few writeups people recommend:
https://gafferongames.com/post/fix_your_timestep/ (and don't try to force 60fps render and updates when your gpu throttles that with vsync anyway; all you're doing is skipping a tick each time you'd call love.update again.)
Re: Turning off VSync
Posted: Fri Nov 29, 2019 1:42 pm
by raidho36
In this day and age you really shouldn't make games that run at constant framerate, especially if it's below modern framerates (i.e. 144 and 240). Instead you should use the dt value to advance time-dependent variables (be careful around acceleration though - that requires additional steps). But if you do, look up "fixed time step" solutions.
Re: Turning off VSync
Posted: Sat Nov 30, 2019 8:00 pm
by Davoo
Thank you both very much for the thoughtful replies. I figured everything out, and would love to walk through it all in here but don't know if I'll ever make the time to do so. Until then, I just wanted to throw up a quick thanks before I forgot!