Mouse lags on low (medium) fps
Posted: Fri Dec 01, 2017 5:07 pm
Hello everyone! Have a nice day (:
I have some kind of problem here. Noticed that my program cursor in love game lags behind system cursor.
I found 2 topics about this
https://love2d.org/forums/viewtopic.php?f=4&t=2780
https://love2d.org/forums/viewtopic.php?t=10048
But they don't help me. I know abount vsync and what is it for. I know that this problem disappears at high fps (around 200-400). I tried to move love.mouse.getPosition() operator around my code. In the love.update() in the love.draw() at the begin at the end. No matter.
The problem is: on low fps (about 30 and lower) lag is very noticeable.
I made some experiments with vsync and with heavy drawings, both reduces fps and showing that problem.
Here is video file in attachment that I record with OBS (recording is not slowing game frame rate).
White cursor is system. Black is love-program, displaying by this code:
In the first part of video fps is high (300) and lag isn't noticeable.
In the second part I enabled vsync and fps became common 60. Lag is noticeable but not so important for many games.
In the third part I enabled invisible heavy drawings that leds to fps about 30. And here is the problem! I scrolled the video-record frame by frame and count that between real cursor start moving and love cursor follow it passes about 4 game frames (or 8 video frames at 60 fps capture rate on record). So the problem is not only in low game performance because 4 frames is not 1 frame.
Looks like some guy "smooths" mouse movement. Who is he?
I have some kind of problem here. Noticed that my program cursor in love game lags behind system cursor.
I found 2 topics about this
https://love2d.org/forums/viewtopic.php?f=4&t=2780
https://love2d.org/forums/viewtopic.php?t=10048
But they don't help me. I know abount vsync and what is it for. I know that this problem disappears at high fps (around 200-400). I tried to move love.mouse.getPosition() operator around my code. In the love.update() in the love.draw() at the begin at the end. No matter.
The problem is: on low fps (about 30 and lower) lag is very noticeable.
I made some experiments with vsync and with heavy drawings, both reduces fps and showing that problem.
Here is video file in attachment that I record with OBS (recording is not slowing game frame rate).
White cursor is system. Black is love-program, displaying by this code:
Code: Select all
function love.load()
img = love.graphics.newImage("mouse-black.png")
...
end
function love.update(dt)
...
end
function love.draw()
... heavy drawings here
local x, y = love.mouse.getPosition()
love.graphics.draw(img, x, y, 0, 1, 1)
end
In the first part of video fps is high (300) and lag isn't noticeable.
In the second part I enabled vsync and fps became common 60. Lag is noticeable but not so important for many games.
In the third part I enabled invisible heavy drawings that leds to fps about 30. And here is the problem! I scrolled the video-record frame by frame and count that between real cursor start moving and love cursor follow it passes about 4 game frames (or 8 video frames at 60 fps capture rate on record). So the problem is not only in low game performance because 4 frames is not 1 frame.
Looks like some guy "smooths" mouse movement. Who is he?