XNA Creators Club Online
Page 1 of 1 (7 items)
Sort Posts: Previous Next

"Hardware" cursor?

Last post 03/10/2007 22:09 by nih. 6 replies.
  • 03/10/2007 10:24

    "Hardware" cursor?

    In many 3D games they offer the option for a "hardware" cursor, usually followed by a second smoothing option. One good example is World of Warcraft. Having both options turned on makes a huge difference to the feel of the cursor and seems to make its responsiveness and redraw independant of the current framerate.

    Whats going on here? Is it some sort of buffer/threading combination? Is this possible in XNA somehow?
    _______________________________________
    www.skull.co.nz
  • 03/10/2007 11:07 In reply to

    Re: "Hardware" cursor?

    It just means using the windows based cursor rather than one drawn by the application.

    By default this is what you use in XNA Framework... unless you are drawing your own cursor its the windows one.

    Show it with IsMouseVisible=true; on the game object

    I admit to not knowing how it works though but its pretty easy to show the lack of responsiveness - draw a sprite at the current mouse position and see how it lags behind. I suspect if has something to do with the way DirectX buffers its display to the mouse coordinates are 1 (or more) frames behind.

    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
  • 03/10/2007 11:39 In reply to

    Re: "Hardware" cursor?

  • 03/10/2007 11:58 In reply to

    Re: "Hardware" cursor?

    Answer
    Reply Quote

    Why use a custom cursor? I assume becuase you want to make it look different. Since you are using the mouse you are already windows only for that code path - so why not use Windows APIs to change the mouse pointer? YOu can have multi coloured cursors (though I don't know how much variation in size you can have).

    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
  • 03/10/2007 14:48 In reply to

    Re: "Hardware" cursor?

    Answer
    Reply Quote

    Couldn't find anything on how to use a custom cursor via windows api apart from some very rudimentary black and white cursors.

    Edit: your reply prompted me to do another search and a found the way to do this. Hurrah! I wonder if I can set the drawmode to additive blending as well..

    In case OP is interested, here is the code:

    // create any bitmap
    Bitmap b = new Bitmap(25, 25);
    Graphics g = Graphics.FromImage(b);
    // do whatever you wish
    g.DrawLine(new Pen(System.Drawing.Color.Red), new PointF(0, 0), new PointF(25, 25));
    g.DrawLine(new Pen(System.Drawing.Color.Red), new PointF(25, 0), new PointF(0, 25));
    // this is the trick!
    IntPtr ptr = b.GetHicon();
    Cursor c = new Cursor(ptr);
    // retrieve the form from this window's handle and attach the cursor:
    Form.FromHandle(this.Window.Handle).Cursor = c;
    this.IsMouseVisible = true;

     

  • 03/10/2007 15:10 In reply to

    Re: "Hardware" cursor?

    Answer
    Reply Quote
  • 03/10/2007 22:09 In reply to

    Re: "Hardware" cursor?

    Nice work gentlemen. I'll give it a whirl. Thanks!
    _______________________________________
    www.skull.co.nz
Page 1 of 1 (7 items) Previous Next