Sign in to follow this  

How to show mouse in a flipping chain?

This topic is 4483 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 there! This is my first post here, just found out about this game programming forum. I love when a game finally becomes alive and starts to kick your butt and for this feeling I've learned programming from the old BASIC, Pascal, C, a few ASM and now, finally, C++ and DirectX stuff, which seems to be enough to make a great game. If there is something else I should know about, please let me know... I know there is a mouse support in DirectX SDK 9.0, but I'm not realy up-to-date with this new DirectX version. I've started something in 7.0, but there is no mouse support. I am currently displaying the mouse as a sprite just before the page flip, but when rendering heavy stuff and the FPS drops, the mouse becomes "ellastic", you probably know what I mean... So, any better ideas?

Share this post


Link to post
Share on other sites
Well, I made it run in both windowed and fullscreen:
- when in window mode, mouse data is read from the system;
- when in fullscreen, mouse data is read from buffered DirectInput (I don't use immediate data because I don't wanna miss something).

I use windowed mode especially for debugging, but the game is intended to work only in fullscreen. In both cases I display mouse in the same way, except that when windowed I hide system cursor when hovers over my client area of the window.

Share this post


Link to post
Share on other sites
I know what you mean - the "elastic mouse" can even happen at high frame,
if the videocard has the next x frames in memory, ready to render.

I think sth like this will help, so it will flush all frames:

pEventQuery->Issue(D3DISSUE_END);
while(pEventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH) == S_FALSE)
{
// avoid being bored while waiting for the GPU,
// so let another thread do something usefull
Sleep(0);
}

... or maybe someone else has a better solution?

PS: If you are using an older dx-version, try locking a 1-pixel rectangle
of the screenbuffer - that might also help.

Share this post


Link to post
Share on other sites
All I need is a cursor display solution.

Should I better display the mouse cursor on the primary surface instead of the backbuffer? In fact, I need the mouse to be independent of the frame display cycle... I thought of using overlays to do that, but I don't know... I mean overlays are nice and strange but not every video card supports them (at least not in the same matter) so...

Share this post


Link to post
Share on other sites
There's just no easy solution to this problem. You have to draw the mouse cursor as a sprite of some sort, and that is tied to the framerate. I imagine you need some multi-threaded trickery (out of my ballpark) to draw the cursor independently and I assure you it would not be easy. All kinds of potential problems come to mind.

This issue is extremely important to me... I just did a beta test of my game and the #1 complaint was "sloppy mouse" and "mouse all over the place" type comments which I know are coming from people who are getting relatively poor framerates.

Share this post


Link to post
Share on other sites
I haven't done this myself - so don't know where to turn. But in principle Windows handles its own mouse pointer blitting, provided you don't turn of the mouse display for Windows. Furthermore you can specify an (alpha'ed) bitmap for the Windows mouse that will be used on a per frame basis without you doing anything specific.

Except - I haven't done this myself yet, so I don't know how to enforce all of that...

Share this post


Link to post
Share on other sites

This topic is 4483 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this