Slick Forums

Discuss the Slick 2D Library
It is currently Fri May 24, 2013 10:21 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Mouse Input lag?
PostPosted: Wed Sep 12, 2012 3:39 am 
Offline

Joined: Sat Aug 20, 2011 3:39 pm
Posts: 20
Can someone explain the big input lag difference when running:

TWL Demo (Java Webstart)
and for example
TWL Inventory Demo (Java Webstart)

If you grab and drag a frame in TWL Demo the mouse input lag is none, the mouse pointer does not wander.

Grab the frame in the Inventory Demo and drag and the rendering is way behind the actual mouse position. You can see the mouse wander around.

I can't understand why one works so well and the other doesn't.


Top
 Profile  
 
 Post subject: Re: Mouse Input lag?
PostPosted: Wed Sep 12, 2012 7:11 am 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1173
That's because the TWL Demo calls
Code:
TestUtils.reduceInputLag()
in it's main loop and the inventory demo does not. You can see the code for reduceInputLag() for details.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
 Post subject: Re: Mouse Input lag?
PostPosted: Wed Sep 12, 2012 12:56 pm 
Offline

Joined: Sat Aug 20, 2011 3:39 pm
Posts: 20
Yeah I noticed that piece of code and did add it to my main loop but could not get rid of the input lag so wasn't sure that was the only reason for the difference.

My app is running with vsync on. I'll investigate some more.


Top
 Profile  
 
 Post subject: Re: Mouse Input lag?
PostPosted: Wed Sep 12, 2012 3:13 pm 
Offline

Joined: Sat Aug 20, 2011 3:39 pm
Posts: 20
No matter what I do I get the input lag.

But if I use SWCursors like in TWLDemo it will seem solid. The mouse pointer will not wander but stick to the things I am dragging around.

But since the HWCursor is so much ahead this latency will exist even if it looks good with SWCursors?
It's like the application is several frames behind. I guess this might be more of a LWJGL issue.


Top
 Profile  
 
 Post subject: Re: Mouse Input lag?
PostPosted: Wed Sep 12, 2012 4:40 pm 
Offline
Slick Zombie

Joined: Fri Jan 29, 2010 7:02 pm
Posts: 1173
It's not really an LWJGL issue - more like an OpenGL issue.

The reduceInputLag() method tries to force a sync between OpenGL and the application and polls for additional input after that sync. This helps when you enable Vsync. Basically it tries to force the waiting time before polling the input, and it will mostly half the lag (in my tests, but depends on the OpenGL driver).

The other source of latency is basically that the input events will affect the rendering, and this will be shown at next redraw.
The SW cursor avoids all these issues because it is based on the same input events as used for the application and is rendered via OpenGL. While the HW cursor is most likely an overlay drawn by the GPU itself and the position is updated directly by the mouse driver.

_________________
TWL - The Themable Widget Library


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group