Limiting frames per second + FSAA-buffers

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
User avatar
Helvecta
Party member
Posts: 167
Joined: Wed Sep 26, 2012 6:35 pm

Limiting frames per second + FSAA-buffers

Post by Helvecta »

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!
"Bump." -CMFIend420
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Limiting frames per second + FSAA-buffers

Post by micha »

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.
User avatar
pk
Citizen
Posts: 67
Joined: Wed Dec 14, 2011 2:13 am
Location: Texas, United States
Contact:

Re: Limiting frames per second + FSAA-buffers

Post by pk »

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.
User avatar
Helvecta
Party member
Posts: 167
Joined: Wed Sep 26, 2012 6:35 pm

Re: Limiting frames per second + FSAA-buffers

Post by Helvecta »

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! :nyu:
"Bump." -CMFIend420
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: Limiting frames per second + FSAA-buffers

Post by Kadoba »

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.
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/

Here's an example based on it.
Timestep.love
(13.58 KiB) Downloaded 141 times
User avatar
Helvecta
Party member
Posts: 167
Joined: Wed Sep 26, 2012 6:35 pm

Re: Limiting frames per second + FSAA-buffers

Post by Helvecta »

^ 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:

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.
[ 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. ]
"Bump." -CMFIend420
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Limiting frames per second + FSAA-buffers

Post by Inny »

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:

Code: Select all

local MAX_DT = 1 / 30
function love.update(dt)
  if dt > MAX_DT then dt = MAX_DT end
  ...
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.
User avatar
Helvecta
Party member
Posts: 167
Joined: Wed Sep 26, 2012 6:35 pm

Re: Limiting frames per second + FSAA-buffers

Post by Helvecta »

Man, you guys are incredible! :ultraglee:

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! :ultrashocked:

Thanks again, everyone!

*stops bumping my own thread*
"Bump." -CMFIend420
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Limiting frames per second + FSAA-buffers

Post by micha »

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/
Interesting. I learned something new. Thanks for sharing.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Limiting frames per second + FSAA-buffers

Post by Ref »

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.
Attachments
love_run.lua
love.run replacement
(2.69 KiB) Downloaded 110 times
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 218 guests