Turning off VSync

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Davoo
Prole
Posts: 3
Joined: Fri Nov 29, 2019 12:37 am

Turning off VSync

Post 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 :ultraglee:
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Turning off VSync

Post 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.
Davoo
Prole
Posts: 3
Joined: Fri Nov 29, 2019 12:37 am

Re: Turning off VSync

Post 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...? :huh:
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Turning off VSync

Post 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...? :huh:
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.)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Turning off VSync

Post 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.
Davoo
Prole
Posts: 3
Joined: Fri Nov 29, 2019 12:37 am

Re: Turning off VSync

Post 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!
Post Reply

Who is online

Users browsing this forum: No registered users and 48 guests