Jump to content
  • Advertisement
Sign in to follow this  
Guest

How to show mouse in a flipping chain?

This topic is 4766 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

Guest
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
Advertisement
Guest
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
Guest
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
Have you tried using the SetCursorPosition call in IDirect3D9? I haven't tried it, but in theory it should give you access to the hardware cursor.

Share this post


Link to post
Share on other sites
Guest
Thanks, Supernat02! I guess that's the best way to do it. However, I've never tried the multithread stuff so it should be fun :)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!