My game is fixed-timestep based. 60 updates per second. Some players with old GPUs / cheap laptops have an issue where the framerate is above 60, completely uncapped, causing it to speed up, even though I have vsync enabled in conf.lua and added cases for higher hz monitors. I don't *need* a 60fps lock, just a 60hz timestep lock where love.update() is only called up to 60 times per second or something, doesn't matter how many times love.draw() is called. How can I force only 60 updates per second without the power of vsync?
Note: I know about deltatime and I'm not planning to use it, the game is already coded for a fixed update rate, deltatime is for variable update rates.
Limiting framerate / timestep when player's GPU doesn't support vsync?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Limiting framerate / timestep when player's GPU doesn't support vsync?
while true do end;
Re: Limiting framerate / timestep when player's GPU doesn't support vsync?
I don't think there is an easy way to decouple the number of calls to update() and draw(), they're all done in the same loop by default.
You could love.timer.sleep in each frame for the remainder of the time slice. A good way to do this would probably be to supply our own love.run, with a dynamic sleep duration to match your 60 Hz maximum.
You could love.timer.sleep in each frame for the remainder of the time slice. A good way to do this would probably be to supply our own love.run, with a dynamic sleep duration to match your 60 Hz maximum.
Last edited by grump on Thu Oct 19, 2017 12:57 am, edited 1 time in total.
Re: Limiting framerate / timestep when player's GPU doesn't support vsync?
Here's some interesting insight on the topic https://www.factorio.com/blog/post/fff-70
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Limiting framerate / timestep when player's GPU doesn't support vsync?
How about you do use deltatime in the following (or similar) way:
Edit: edited, thanks grump!
Code: Select all
local accum = 0.0
love.update = function(dt)
accum = accum + dt
if accum >= timestep then
-- do actual update stuff here
accum = accum - timestep
end
end
Last edited by zorg on Thu Oct 19, 2017 2:57 am, edited 2 times in total.
Me and my stuff True 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.
Re: Limiting framerate / timestep when player's GPU doesn't support vsync?
accum >= timestep?
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests