Skip to main content
GameDev.net gamedev.net
🔒 Locked

Mouse lag under DirectX9

Started by vladic2000x Jul 25, 2007 at 3:33 AM 2 replies 2.6k views
Original Post
vladic2000x
vladic2000x
Hello. The problem: Instead of using Windows cursor, I have decided to render inside DirectX9 application a 2D quad centered at mouse position. The problem begins at low frame rates. I call GetCursorPos() and "submit" the mouse quad for rendering. In Directx9 the actual rendering happens later at "Present()" call and at that time the Windows (real) mouse pointer is already in another place. So it looks like the "custom" quad pointer is trailing behind, the real mouse movement. At high frame rates that is almost unnoticeable. Any ideas or suggestions on how could I make the "custom" quad mouse pointer be displayed as closer as possible to real mouse position? Thank you!
Aardvajk
Aardvajk
Direct3D supports hardware mouse cursors. Search for "mouse cursors" in the DXSDK help.

I was skimming this the other night. It looks like you submit one surface level of a D3D texture to the method that then becomes the mouse cursor, but handled in hardware so you don't get the lag.

You appear to lose alpha blending though - alpha values for each pixel in the surface have to be 0.0 or 1.0, like Windows cursors.
jollyjeffers
jollyjeffers
EasilyConfused covered it nicely, but just to add - this sort of problem crops up fairly regularly. I've heard a lot of cases where the input handling code was split out to a seperate thread so as not to get stalled by the graphics (or other gameplay) code...

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
vladic2000x
vladic2000x
Fixed.

The thing causing the lag was the presentation interval. I've switched from INTERVAL_IMEMDIATE to INTERVAL_ONE, and no problems!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.