Jump to content
  • Advertisement
Sign in to follow this  
vladic2000x

Mouse lag under DirectX9

This topic is 3983 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Fixed.

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!