Mouse lag... on Linux and OpenGL????

BlitzMax Forums/OpenGL Module/Mouse lag... on Linux and OpenGL????

SLotman(Posted 2009) [#1]
Before posting this on the bug-report forum, I believe it will be better to first confirm this, with everyone. I'm trying the most simple thing of all:

SetGraphicsDriver GLMax2DDriver()
Graphics 1024, 768, 0
SetBlend SOLIDBLEND
Local XPos:Int, YPos:Int

While Not KeyDown(KEY_ESCAPE)

SetColor 0,0,0
DrawRect 0,0,GraphicsWidth(),GraphicsHeight()

SetColor 255,255,255
XPos = MouseX()
YPos = MouseY()
DrawRect(XPos, YPos, 32, 32)

Flip 1
'GrabPixmap 0,0,1,1

Wend

End


Move the mouse around quickly, if the white rectangle lags behind, you're seeing the problem.

I ran the above code, and both in window mode or fullscreen, the mouse lags. If I increase the resolution, the mouse lags even more - still the FPS is pretty solid (always above 60fps).

If I uncomment the grabpixmap line, the lag disappears from fullscreen - but it still happens on windowed mode.

I know this was a long known bug of DX module, and I don't think it happens on OGL - windows... can anyone confirm this? (I'm on BMax 1.32 btw)

Update: It also happens on Windows, fullscreen AND windowed mode - but the Grabpixmap seems to fix both on Windows, not only fullscreen...
I'm on a ATI Radeon X1300, on XP btw.

Update2: On Windows 98, Geforce 4 MX4000 - it doesnt happen. On Vista 64, Geforce 9300 it happens both fullscreen and windowed, and grabpixmap fixes fullscreen only.


QuickSilva(Posted 2009) [#2]
I get the same thing in both OpenGL and DirectX on Vista 32-bit. I have always had this in all versions of BMax.

Jason.


TaskMaster(Posted 2009) [#3]
I am not so sure this is a bug.

If you are using Flip 1, you are telling the program not to do a flip until the next screen refresh. The problem is, you grab the mouse position and plot the square. But the mouse keeps moving. Then you draw the screen and the square appears where the mouse "was".

The only way you are going to avoid this, is to also draw the mouse cursor yourself.


SLotman(Posted 2009) [#4]
Flip 0 does no difference at all.

I first noticed that drawing the mouse cursor, I was moving it, and I was feeling it "a little sluggish".

Note that with the DX9 driver this doesn't happen at all...


TaskMaster(Posted 2009) [#5]
I get no lag with Flip 0.


Ked(Posted 2009) [#6]
With Flip 0 there is no lag. Actually, the windows cursor is behind the rect. (Windows XP)


RupeB(Posted 2015) [#7]
This is because the Operating System doesn't sync mouse coordinate and vertical blanking nicely through whatever APIīs and mechanisms BlitzMax uses.

Itīs not that uncommon or weird.

I think Itīs because of BMax does not use the same double buffering the OSīs has for itself, BMax has itīs own ontop (behind in time) of that.

So thereīs a 12millisec / 60fps lag.
Thatīs why throwing the flip makes away for it.
Itīs the same on all OS Linux, Windows, and Mac's.


RupeB(Posted 2015) [#8]
I remember the exact same thing happened on the old Commodoreīs even.

There was an old BlitzBASIC competitor called AMOS BASIC and it had a fix for this called "AMAL DIRECT",
it was a very odd thing that did not reveal anything about how it did its business. It just worked,
I remember its description "Function that allows things to happen before a vertical blanking", so it was I guess kind of a API hook.

Allowing to be part of the OS itself and get those mouse coordinates and fast as the OS itself,
and not wait a whole frame for the new coordinates.