Limiting FPS by modifying

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
Posts: 1
Joined: Mon Oct 15, 2018 12:03 am

Limiting FPS by modifying

Post by broccoli » Mon Oct 15, 2018 12:11 am

I'm playing around with deliberately trying to limit the FPS of my game. I've modified to do this, using an accumulator and updating every 1/30th of a second. I believe this should only draw to the screen once every 1/30th of a second, approximately.

Code: Select all

		    if love.timer then dt = love.timer.step() end
		    accumulator = accumulator + dt
		    if accumulator >= tick_rate then
			    accumulator = 0
			    if love.update then love.update() end
			    if and then
				    if love.draw then love.draw() end
		    if love.timer then love.timer.sleep(0.001) end
For some reason, love.timer.getFPS() reports very high FPS (400+) even with vsync on. Why is this?

User avatar
Party member
Posts: 2529
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary

Re: Limiting FPS by modifying

Post by zorg » Tue Oct 16, 2018 12:49 am

Hi and welcome to the forums!

Löve uses its internal timer... internally, to calculate the value you get back with getFPS and with related functions as well; basically, it's all dependent on the love.timer.step() call, which -is- outside your fixed time step function.

getFPS does not do any magic with detecting how fast löve renders frames to the gpu, basically.

You could redefine the function, to return 1 / tick_rate, but... that's kinda pointless if implemented exactly like that.
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.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 9 guests