![]() |
|
hardware enabled custom cursors |
curriguy
Member #6,162
August 2005
|
hi. I was wondering how one would go about using enable_hardware_cursor() AND having the OS draw my custom sprite as a cursor? is this even possible? I tried fiddling with enable_hardware_cursor(); but that didn't have the results I wanted. besides it was kindova random stab at solving the problem. It'd be helpful if anyone knew how to do this. |
Tobias Dammers
Member #2,604
August 2002
![]() |
TFM said: Allegro offers three ways to display the mouse cursor: * Standard Allegro cursor (emphasis mine) --- |
miran
Member #2,407
June 2002
|
I think you also need to call set_mouse_sprite() somewhere, but I'm not 100% sure. Anyway, if you want some special kind of custom cursor, you can kiss hardware enabled cursros goodbye. Like for example if you want a cursor that's translucent, has a shadow, a glow, or something like that... -- |
curriguy
Member #6,162
August 2005
|
hmm okay yeah I should have read that more carefully, I guess my system just can't handle it. And even if it could, I think what you've bolded is more than enough reason to not use this system in general. I guess I'll hack out a sluggish reduce mouse-flicker hack like everyone else. |
miran
Member #2,407
June 2002
|
Quote: I guess I'll hack out a sluggish reduce mouse-flicker hack like everyone else.
Hack? Sluggish? -- |
Tobias Dammers
Member #2,604
August 2002
![]() |
Have you implemented a screen buffering system yet? If so, then all you need to do is draw any sprite you like onto the back buffer, at the current mouse position, after rendering a frame, but before flipping / blitting. You might want to add a "hotspot" offset, though. --- |
curriguy
Member #6,162
August 2005
|
Tobias, actually that's exactly what I'm doing. And That's what I meant by "sluggish" because the mouse is less responsive when using this method. It seems to be working fine. What exactly do you mean by the "hot spot" effect? thanks for the info everyone |
Tobias Dammers
Member #2,604
August 2002
![]() |
Offset, not effect. Quite simple. With a standard "arrow" type mouse pointer, the click position is at the tip of the arrow, which is the top-left corner of the sprite. For other cursors, though (e.g. a cross), it's not. To compensate for that, you define a "hotspot", that is, an x- and y-offset to add to (or rather subtract from) the mouse position before blitting. For example, if your "hotspot" is at position )(4, 8) on the mouse sprite, then you'd draw your sprite at mouse_x-4 and mouse_y-8. And it's always as responsive as your game. If your frame rate drops, so does the mouse responsiveness. --- |
Evert
Member #794
November 2000
![]() |
Quote: I guess my system just can't handle it. As far as I know, all graphics drivers except for fullscreen Windows DirectX can do hardware cursors (you can complain to Microsoft). Quote: And even if it could, I think what you've bolded is more than enough reason to not use this system in general.
If you don't need mouse mickeys when the cursor is outside of your window (and the hardware cursor is available), then it is the best way to show the cursor. enable_hardware_cursor(); set_mouse_sprite(some_sprite); show_mouse(screen); if (gfx_capabilities & GFX_HW_CURSOR) { celebrate(); } else { cry(); }
|
|