Page 1 of 1

Mouse delay?

Posted: Tue Jul 17, 2012 8:28 am
by kirbunkle
I've noticed that there is a small delay between when the actual mouse moves and when I draw my custom mouse. I draw it as just an image using the mouse.getPosition() coordinates to find out where to put it, but it always seems to be just a split second behind. It is noticeable.

It seems to be an issue with how love gets the mouse position, presumably only once every iteration of the game loop. But by the time it is displayed on the screen, the mouse has already moved to a different position.

I was wondering if there was a solution or some kind of work-around. Any help is greatly appreciated.

Re: Mouse delay?

Posted: Tue Jul 17, 2012 5:35 pm
by juno
Maybe take the mouse positioning code out of the game loop and have it at the start of the update function?

Re: Mouse delay?

Posted: Tue Jul 17, 2012 5:47 pm
by Santos
You may or may not want to turn vsync off using love.graphics.setMode or conf.lua (discussed further here: viewtopic.php?f=4&t=9098)

Re: Mouse delay?

Posted: Tue Jul 17, 2012 6:15 pm
by kirbunkle
Santos wrote:You may or may not want to turn vsync off using love.graphics.setMode or conf.lua (discussed further here: viewtopic.php?f=4&t=9098)
Amazing, it works. The delay is gone.

But I noticed that the fps shot up to like 500.

Are there any reasons why I would want to leave vsync on? Does a game require more CPU with it off? Should I try to reduce the update rate (have a check and update only 60 times a second) to compensate for the high frame rate? Lol, lots of questions, sorry. :P

Thanks for the help. :D

Re: Mouse delay?

Posted: Tue Jul 17, 2012 6:26 pm
by Santos
I'm glad I could help! :D

It's there to prevent screen tearing.

I have no idea about CPU usage sorry. :D

Using dt properly inside love.update means the framerate won't affect the speed of things in game.

Re: Mouse delay?

Posted: Tue Jul 17, 2012 6:38 pm
by kirbunkle
Santos wrote:I'm glad I could help! :D

It's there to prevent screen tearing.

I have no idea about CPU usage sorry. :D

Using dt properly inside love.update means the framerate won't affect the speed of things in game.
Maybe I'll play with it to see if there's any negative effects. Now that I know what I can do about it, I might be able to come up with some work-around if I do see some problems.

Thanks!

Re: Mouse delay?

Posted: Tue Jul 17, 2012 6:59 pm
by Nixola
If the video drivers are good, playing with vsync on is faster than playing without it (it depends on the framerate difference). If the video drivers are bad, it's slow in both cases.

Re: Mouse delay?

Posted: Tue Jul 17, 2012 7:05 pm
by josefnpat
The next time you have problems, please check the forums.

Here is another thread on the subject: viewtopic.php?f=4&t=2780

Re: Mouse delay?

Posted: Wed Jul 18, 2012 1:47 am
by dreadkillz
This is a well known issue in video games, especially if you've played counter strike or any shooters a lot in the past. Vsync is just nasty cause it's artifically delaying frames to sync with your refresh rate, so it looks like your video is lagging. (at least that's how I recall researching this many many years ago).

Re: Mouse delay?

Posted: Fri Jul 20, 2012 5:52 pm
by bartbes
dreadkillz wrote:Vsync is just nasty cause it's artifically delaying frames to sync with your refresh rate
It's awesome! It prevents screen tear, it prevents me from having more fps than I'll ever need (because my monitor wouldn't be able to display it), and it's nice on my cpu too (YMMV). That said, for really responsive controls you'll need to have it off, in general though, it's good enough with it on.