Hello!
I was wondering how you could go about limiting the frames per second. I've read and heard that you can enable "vsync", limiting the FPS to the refresh rate of your monitor, but. . eh, I'm not convinced; the application still runs with undesirable speed.
So, I haven't actually tried what I was thinking because I think it is a terrible way of limiting FPS - a method by which you determine how long it takes to refresh the screen, then compare it to the amount of time in a second and force the program to sleep for the appropriate amount of time, creating a variable FPS of sorts. Maybe I'm wrong and this is an okay way of restricting the speed of an application, but I am not sure, so here I am!
On a side-note, can anyone explain to me what FSAA-buffers are? I've heard that it works to make 2D images have a better render quality or some noise.
If anyone can help me out, it would be much appreciated. Thanks!
Limiting frames per second + FSAA-buffers
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Limiting frames per second + FSAA-buffers
"Bump." -CMFIend420
Re: Limiting frames per second + FSAA-buffers
If you really want to slow down your program you can edit the love.run() callback function. You find information here:
https://love2d.org/wiki/love.run
There you can for instance change the value in the love.timer.sleep() function.
However I advice you against doing that. I cannot imagine any good reason for restricting the framerate. If you use dt in you update functions properly, the framerrate shouldn't have any influence on the behavior of the objects in your program.
https://love2d.org/wiki/love.run
There you can for instance change the value in the love.timer.sleep() function.
However I advice you against doing that. I cannot imagine any good reason for restricting the framerate. If you use dt in you update functions properly, the framerrate shouldn't have any influence on the behavior of the objects in your program.
Check out my blog on gamedev
Re: Limiting frames per second + FSAA-buffers
I think FSAA is fullscreen anti-aliasing. For sharp graphics with pixel art, you don't need it. It can lower FPS on crappy gfx cards too.
ALL CREATURE WILL DIE AND ALL THE THINGS WILL BE BROKEN. THAT'S THE LAW OF SAMURAI.
Re: Limiting frames per second + FSAA-buffers
Oh. Oh my.
I did some looking around to understand what you meant by using dt in update functions, and realized that it is something I totally neglected.
Wow, how did I overlook this.
Ah, anyways, thank you, pk and micha! You've both been a tremendous help!
I did some looking around to understand what you meant by using dt in update functions, and realized that it is something I totally neglected.
Wow, how did I overlook this.
Ah, anyways, thank you, pk and micha! You've both been a tremendous help!
"Bump." -CMFIend420
Re: Limiting frames per second + FSAA-buffers
There are instances where you would want to keep your framerate fixed or at least limited (the logic side of it). Fighting games and games with sampled collision detection come to mind. This article explains it really well: http://gafferongames.com/game-physics/f ... -timestep/micha wrote:If you really want to slow down your program you can edit the love.run() callback function. You find information here:
https://love2d.org/wiki/love.run
There you can for instance change the value in the love.timer.sleep() function.
However I advice you against doing that. I cannot imagine any good reason for restricting the framerate. If you use dt in you update functions properly, the framerrate shouldn't have any influence on the behavior of the objects in your program.
Here's an example based on it.
Re: Limiting frames per second + FSAA-buffers
^ I couldn't have asked for a better example of what I need. Many thanks to you too, Kadoba!
EDIT: Hope this doesn't bump, but I just thought this snippet might be useful to someone:
[ The only difference from what Kadoba attached - other than changed variable names - is that it allows you to set the FPS in a more user-friendly way. ]
EDIT: Hope this doesn't bump, but I just thought this snippet might be useful to someone:
Code: Select all
local fps = 60 -- set the FPS!
UPDATE.max = 1 / fps -- when the max is reached, an update occurs. this is in SECONDS.
UPDATE.current = 0 -- current progress to the max.
"Bump." -CMFIend420
Re: Limiting frames per second + FSAA-buffers
The one thing I would advise with using dt is to not allow it to get too large. It may be, in some cases, better to allow slow-down to happen, than to do a large update in one go. That would be done like this:
The reason you would do this has a already been mentioned in this thread by Kadoba: namely that collision detection and other logic tends to work better in fixed steps, rather than wildly differing step sizes.
A more extreme example would be to keep a timer and perform a game logic "Tick" as regular intervals.
Code: Select all
local MAX_DT = 1 / 30
function love.update(dt)
if dt > MAX_DT then dt = MAX_DT end
...
A more extreme example would be to keep a timer and perform a game logic "Tick" as regular intervals.
Re: Limiting frames per second + FSAA-buffers
Man, you guys are incredible!
I was reading Kadoba's link but since it seems to be written in a language other than Lua, the concept went over my head a bit. Thanks for pointing that out, Inny - it's like you're inside my head!
Thanks again, everyone!
*stops bumping my own thread*
I was reading Kadoba's link but since it seems to be written in a language other than Lua, the concept went over my head a bit. Thanks for pointing that out, Inny - it's like you're inside my head!
Thanks again, everyone!
*stops bumping my own thread*
"Bump." -CMFIend420
Re: Limiting frames per second + FSAA-buffers
Interesting. I learned something new. Thanks for sharing.Kadoba wrote:There are instances where you would want to keep your framerate fixed or at least limited (the logic side of it). Fighting games and games with sampled collision detection come to mind. This article explains it really well: http://gafferongames.com/game-physics/f ... -timestep/
Check out my blog on gamedev
Re: Limiting frames per second + FSAA-buffers
I've gone the modify love.run route in some scripts.
I load my love.run by:
require 'love_run'
and then in love.load use:
love.Enable('fps',30)
if I want a constant 30 fps (provided that it doesn't take more than 1/30 seconds to create a frame).
This approach is different than love.sleep in that only the needed delay is added each frame.
Attached is my love_run.lua.
I load my love.run by:
require 'love_run'
and then in love.load use:
love.Enable('fps',30)
if I want a constant 30 fps (provided that it doesn't take more than 1/30 seconds to create a frame).
This approach is different than love.sleep in that only the needed delay is added each frame.
Attached is my love_run.lua.
- Attachments
-
- love_run.lua
- love.run replacement
- (2.69 KiB) Downloaded 110 times
Who is online
Users browsing this forum: Google [Bot] and 218 guests