mouselag

BlitzMax Forums/BlitzMax Programming/mouselag

Robert Cummings(Posted 2006) [#1]
in windowed mode with heavy graphics going on (still really high framerates) the mouse will lag behind somewhat. [edit]It *does* still occur in fullscreen mode.

This stuff happened with blitz3d as well if I recall. Is there a resolution?


Robert Cummings(Posted 2006) [#2]
Ideally I want the mouse updating all the time. I force the mouse to update at a higher logic and it still lags behind. This is incorrect behaviour and baffling.


FlameDuck(Posted 2006) [#3]
Have you tried sticking a PollSystem or Delay in your main loop?


ImaginaryHuman(Posted 2006) [#4]
Since the mouse pointer in windowed mode is managed by the desktop, probably you're not giving it enough CPU time spare to be processes, which I think is what flameduck is getting at.


Robert Cummings(Posted 2006) [#5]
Does not lag in opengl but does in dx.


Robert Cummings(Posted 2006) [#6]
I should be more clearer: it plays "catch up" and remembers my old movements from long ago: I don't want it to do this, I want it to only know the current mouse position. Weird eh?


Luke.H(Posted 2006) [#7]
You game is calling flip to fast, happened to me too

Try putting this (untested) code in you main loop

Tmp=(MilliSecs()-LastTime)
If Tmp<60 Then Delay 60-Tmp
LastTime=MilliSecs()



Robert Cummings(Posted 2006) [#8]
edit: doesn't help issue, sorry


Robert Cummings(Posted 2006) [#9]
The solution would be to flush the mouse queue and only get the most recent item back. Any idea how thats done?


fredborg(Posted 2006) [#10]
Weird, no mouse lag on this:
'SetGraphicsDriver GLMax2DDriver()
Graphics 640,480,0,0

Repeat
	Cls
	For i = 0 To 100000
		SetColor Rand(255),Rand(255),Rand(255)
		DrawRect Rand(0,640),Rand(0,480),10,10
	Next
	Flip
Until KeyHit(KEY_ESCAPE)
If it's because you draw your own mouse pointer to the screen, I don't think it's easy to avoid. Because that will be dependant on how quickly you redraw your graphics.


Robert Cummings(Posted 2006) [#11]
Hi,

to clarify, it only affects mousex() and mousey() results. These return the absolute position of the mouse under opengl graphics but they return the position of the mouse in a drip-fed queue under dx.

So under dx, I will see the mouse values play "catch up" in a queue, whereas using opengl, the mouse values returned will be the last position of the mouse.

This is a clear problem with dx.


Michael Reitzenstein(Posted 2006) [#12]
No, Rob's rendering at 60fps+ but mousex( ) is returning old values. Don't think jerky, thing lagged.


fredborg(Posted 2006) [#13]
There is absolutely no difference between the drivers on my machine:
'SetGraphicsDriver D3D7Max2DDriver()
'SetGraphicsDriver GLMax2DDriver()
'SetGraphicsDriver BufferedD3D7Max2DDriver()
Graphics 640,480,0,0

Repeat
	Cls
	For i = 0 To 100000
		SetColor Rand(55),Rand(55),Rand(55)
		DrawRect Rand(0,640),Rand(0,480),10,10
	Next
	
	'Flip
	
	SetColor 255,255,255
	DrawOval MouseX()-3,MouseY()-3,5,5
	
	Flip
Until KeyHit(KEY_ESCAPE) Or AppTerminate()
So it might be a driver issue, or specific to certain graphics cards?

Try uncommenting the Flip before the mouse drawing to see if that makes a difference for you.


Stuart Morgan(Posted 2006) [#14]
'SetGraphicsDriver D3D7Max2DDriver()
'SetGraphicsDriver GLMax2DDriver()
'SetGraphicsDriver BufferedD3D7Max2DDriver()
Graphics 1024,768,32

While Not KeyHit(KEY_ESCAPE)

	DrawLine MouseX()-5,MouseY()-5,MouseX()+5,MouseY()+5
	DrawLine MouseX()+5,MouseY()-5,MouseX()-5,MouseY()+5

	'Flip 0		' no lag
	Flip 1		' mouse lags
	'Flip -1	' mouse lags
	Cls
Wend

Same problem here in windowed or fullscreen mode. The mouse lags when waiting for the vertical blank.

No difference between the max2d graphics drivers here.


Robert Cummings(Posted 2006) [#15]
Hi stuart, mine lags on all combinations.

It might help to point out at this stage, that I am using a Radeon 9800 PRO, latest drivers.

I don't get this problem in other DX games btw, just in Blitz3D and Blitzmax.


Stuart Morgan(Posted 2006) [#16]
It might help to point out at this stage, that I am using a Radeon 9800 PRO, latest drivers.

Seems to be a graphics card issue then, I also have a Radeon 9800 Pro, custom drivers and it lags.

Doesnt lag at all (on any combination) on my other computer (Radeon X600 Pro)


Dreamora(Posted 2006) [#17]
The latest driver might be a problem ... had some serious issues with the 5.11 generation (not running DX7 and 8 games, blue screen of death with WinXP Pro?!) and reversed to a 5.09 Omega because of that.


Robert Cummings(Posted 2006) [#18]
Tried older driver with the same story.


Perturbatio(Posted 2006) [#19]
It lags for me with flip 1 or -1.


fredborg(Posted 2006) [#20]
Try this then:
'SetGraphicsDriver D3D7Max2DDriver()
'SetGraphicsDriver GLMax2DDriver()
SetGraphicsDriver BufferedD3D7Max2DDriver()
Graphics 1024,768,0

While Not KeyHit(KEY_ESCAPE)

	SetColor 255,255,255
	DrawLine MouseX()-5,MouseY()-5,MouseX()+5,MouseY()+5
	DrawLine MouseX()+5,MouseY()-5,MouseX()-5,MouseY()+5

	While PollEvent()
		If CurrentEvent.id = EVENT_MOUSEMOVE
			x = CurrentEvent.x
			y = CurrentEvent.y
		EndIf
	Wend

	SetColor 255,0,0
	DrawLine x-5,y-5,x+5,y+5
	DrawLine x+5,y-5,x-5,y+5
	
	'Flip 0		' no lag
	Flip 1		' mouse lags
	'Flip -1	' mouse lags
	Cls
Wend
Is there any (significant) difference in the position of the red and the white cross?

It might vary a few pixels once in a while, but that is to be expected.


Stuart Morgan(Posted 2006) [#21]

Is there any (significant) difference in the position of the red and the white cross?

No difference in the position of the two crosses here.


N(Posted 2006) [#22]
I get mouse lag with all drivers regardless of Flip value.

Specs..
AMD64 3000+
Gigabyte Radeon X800 XT PE
1GB o' RAM
Onboard RealTek audio

Can't think of anything else that would have a noticeable effect on it at the moment.


Perturbatio(Posted 2006) [#23]
No difference between the crosses for me either, and no lag between the mouse cursor and the cross.

There is lag between the cursor and the cross in fullscreen mode


Robert Cummings(Posted 2006) [#24]
I get significant lag with all 3 flips on both DX drivers, but -no- lag on the opengl driver.


Michael Reitzenstein(Posted 2006) [#25]
Noel, Stuart, the cross is lagging for you on fredborg's example?


N(Posted 2006) [#26]
Yes. That's what I said.


Michael Reitzenstein(Posted 2006) [#27]
Just making sure. This really needs to be fixed!


Stuart Morgan(Posted 2006) [#28]
Noel, Stuart, the cross is lagging for you on fredborg's example?

Yes, both crosses are lagging.


Michael Reitzenstein(Posted 2006) [#29]
Both crosses are lagging!? You mean they're at the same place, but lagging the windows mouse pointer? That's what I get. But the demo is meant to show difference between 2 different methods of polling mouse position.


Stuart Morgan(Posted 2006) [#30]
You mean they're at the same place, but lagging the windows mouse pointer?

Yes


Michael Reitzenstein(Posted 2006) [#31]
Interesting. If it's noticeable it's probably not a rendering delay.


Robert Cummings(Posted 2006) [#32]
It's definately not a rendering delay... it is proper lag. I can tell how it should be when using ogl (or any commercial mouse driven game)


King Dave(Posted 2006) [#33]
I too have seen this. And I can confirm it happened in Blitz3D too (and still does).


Michael Reitzenstein(Posted 2006) [#34]
I think it would be a good idea to look out how the Popcap Framework does their input.


Damien Sturdy(Posted 2006) [#35]
i get this in AAA games too. GTA, KING KONG, and most games with a 2d-in-3D UI get it.

I fix it by (nvidia here) turning the "Max frames to render ahead" down to 0.


Robert Cummings(Posted 2006) [#36]
I do not get this with commercial games that you mention. It's worth pointing out that the option to render ahead is only available on nvidia cards... and I have an ati card.


Mark Tiffany(Posted 2006) [#37]
All look spot on to me. It's looking like an ATI DX thing...


DredPirateRoberts(Posted 2006) [#38]
i had this same problem in DemonStar and windows version of raptor . when i used the dinput func

GetDeviceData

and was fixed by using

GetDeviceState

instead to read mouse.

Also now that im thinking about this
the problem may have something ( or just made it worse ) by not giving enuf time back to system for the directx background processes.


Stuart Morgan(Posted 2006) [#39]
All look spot on to me. It's looking like an ATI DX thing...

I have two ATI cards and it lags on one and not the other. I think they both have the exact same drivers too.


Eikon(Posted 2006) [#40]
Happens here in DX fullscreen only. Still using 1.10


TartanTangerine (was Indiepath)(Posted 2006) [#41]
I did some "google"ing and it appears that DirectX mouse lag is a know problem and has been around since DirectX6 !!!!


Stuart Morgan(Posted 2006) [#42]
I've noticed that if you disable Triple Buffering it significantly reduces the amount of mouse lag.


Robert Cummings(Posted 2006) [#43]
Not here it doesn't. Mind you, I have a whole game, not just fredborg's example...


FlameDuck(Posted 2006) [#44]
I did some "google"ing and it appears that DirectX mouse lag is a know problem and has been around since DirectX6 !!!!
Remember how we used to have these discussion about which was best, OpenGL or DirectX?

OpenGL won.


Michael Reitzenstein(Posted 2006) [#45]
It sure does, if you want your game running in software.


FlameDuck(Posted 2006) [#46]
It sure does, if you want your game running in software.
How else would you run it?


Robert Cummings(Posted 2006) [#47]
And those two replies are prime examples of how to troll and bring the tone of a forum down, thank you mikkel.


FlameDuck(Posted 2006) [#48]
You're welcome Mr. Kettle.


Michael Reitzenstein(Posted 2006) [#49]
Just got this back from QA:

1) cursor sensitivity is very sluggish. The cursor lags behind user input and behaves as though an anchor is attached to it. This is occuring on several machines in the office, mostly laptops with Radeon Mobility 7500's.