Framerate increases when window is not in focus
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Framerate increases when window is not in focus
I don't know if this is a bug with Zerobrane, or if it's something that happens with any LOVE file that's tested. When I run my program (whether running as 'scratchpad' or running regularly), if the game window is not in focus, then the framerate will increase significantly. I noticed this because I have a continuous scrolling background that is supposed to scroll very slow, but if the window is not in focus, then the background scrolls really fast. How do I prevent the framerate from increasing? Has anyone else had this problem?
Re: Framerate increases when window is not in focus
Well its quite oposite...
Wten the window gets out of focus the FPS may drop to less than 1, and the lower the FPS, the larger the dt gets, so if you sue the dt it may seam that the stuff is moving faster...
The solution is to lomit the dt like this:
Wten the window gets out of focus the FPS may drop to less than 1, and the lower the FPS, the larger the dt gets, so if you sue the dt it may seam that the stuff is moving faster...
The solution is to lomit the dt like this:
Code: Select all
dt = math.min(dt, 0.09)
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Framerate increases when window is not in focus
Then you're using dt completely wrong.Wojak wrote:so if you sue the dt it may seam that the stuff is moving faster...
The answer is probably that you've got an os that kind of knows what it's doing, and optimizing out the draws to whatever's not on-screen, however, if framerate influences the speed at which your game runs, you should be using dt.
Re: Framerate increases when window is not in focus
If your game window loses focus then it's usually a good idea to pause the gameplay, especially for action-oriented games.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Re: Framerate increases when window is not in focus
Note that we are talking about FPS below 1 (0.5 or so), and this happens on widows (at least vista and 7) when you drag the love window while the game is running (this is undetected by love.focus)...bartbes wrote:Then you're using dt completely wrong.Wojak wrote:so if you sue the dt it may seam that the stuff is moving faster...
The answer is probably that you've got an os that kind of knows what it's doing, and optimizing out the draws to whatever's not on-screen, however, if framerate influences the speed at which your game runs, you should be using dt.
Limiting dt solves the problem (the code from my previous post), but the game will slow down when the fps drops (with 0.09 if will start sloing down below 11 FPS witch is way bellow playability level)
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Framerate increases when window is not in focus
That still shouldn't speed up your game, it will make things happen extremely fast for a single frame, but the actual average speed is correct. It does tend to mess with physics simulations and stuff, but again it still doesn't mean it's faster.
Re: Framerate increases when window is not in focus
Sorry, I meant the frame rate decreases, meaning everything is getting super fast when the window isn't in focus.
So would it just make sense to halt the entire game when the window is not in focus, like Lafolie's suggestion? Or is there any way to keep the framerate consistent whether it's in focus or not? Does pausing/halting a LOVE game reduce the amount of CPU resources being used? Or does it use more resources?
So would it just make sense to halt the entire game when the window is not in focus, like Lafolie's suggestion? Or is there any way to keep the framerate consistent whether it's in focus or not? Does pausing/halting a LOVE game reduce the amount of CPU resources being used? Or does it use more resources?
Re: Framerate increases when window is not in focus
You should post a .love where this can be observed/checked by someone - it sounds like you aren't using dt correctly, as bartbes suggested. When you vary things by time you should have a factor of dt in there.
Code: Select all
function love.update(dt)
x = x + 7 * dt -- dt is the amount of time in seconds that has passed since the last update, so x will increase by 7 each second
end
Re: Framerate increases when window is not in focus
There's a love file in my previous topic: http://love2d.org/forums/viewtopic.php? ... 8&start=10
But I don't understand how the dt increases just because the window is not in focus. If I make the window back in focus again, then everything is normal.
But I don't understand how the dt increases just because the window is not in focus. If I make the window back in focus again, then everything is normal.
- substitute541
- Party member
- Posts: 484
- Joined: Fri Aug 24, 2012 9:04 am
- Location: Southern Leyte, Visayas, Philippines
- Contact:
Re: Framerate increases when window is not in focus
There's a reason why DT is there; so that things can run and look pretty much the same and any framerate. So when FPS decreases, DT increases, and it still looks the same. Even when FPS is some value less than 1.
Currently designing themes for WordPress.
Sometimes lurks around the forum.
Sometimes lurks around the forum.
Who is online
Users browsing this forum: No registered users and 20 guests