Color Cursor?

If one wants to use a color cursor, is turning off the SDL cursor and
using Mouse Motion events to blit an image to the location of the mouse
the only way to accomplish this? The only reason I ask is that most
modern hardware supports hw-cursors, right? And I would guess that,
when available, SDL uses hw cursors for SDL_Cursor, right? Do most hw
cursors not support color?

Cheers,

Jeff–
“Message sent by @Jeff_Schmidt

If one wants to use a color cursor, is turning off the SDL cursor and
using Mouse Motion events to blit an image to the location of the mouse
the only way to accomplish this? The only reason I ask is that most
modern hardware supports hw-cursors, right? And I would guess that,
when available, SDL uses hw cursors for SDL_Cursor, right? Do most hw
cursors not support color?

I believe this is correct. I’m pretty positive X11 doesn’t support color
cursors, and I’m kinda sure that Mac doesn’t. Or, does it?

With SDL, we’ve got to be careful not to introduce something that’s too
hardware/OS specific if it can’t be done on all of the other supported OSes.

However, Sam, have you consider supporting color cursor on OS(es) that DO
support it (say, Win32) and for those that don’t support some kind of
color-reduction/dithering to convert the color image to B/W for the OSes that
don’t support color cursors?

Or how about something like:

SDL_Cursor * SDL_CreateColorCursor(Uint32 *color_data, Uint8 *color_mask,
Uint8 *bw_data, Uint8 *bw_mask,
int w, int h, int hot_x, int hot_y);

If the OS supports color, it will, of course, use the color_data and
color_mask information to create a nice, pretty color cursor.

If the OS does NOT support color, it will use the bw_data and bw_mask
information to create a black/white cursor.

However, if the OS doesn’t support color, and bw_data and/or bw_data are
NULL, then the user is asking the function to create a black/white cursor
based on the color_data and color_mask information.

Think it’s doable? (I’d try, but I don’t have Windows or know anything
about using color cursors under it.)

A slightly related question. Why is there no SDL_CreateCursorFromSurface()
function? :slight_smile:

When I converted Gem Drop X from Xlib to SDL, I had to replace one simple
Xlib function call that accepted .xbm data with a for-loop that did a bunch
of bit shifting. (I believe it was an LSbit vs MSbit thing…)

-bill!
Wah! I had to use << and >>! Wah!!
:wink:

However, Sam, have you consider supporting color cursor on OS(es) that DO
support it (say, Win32)

Heheh. SDL did at one time support color cursors. Unfortunately, the app
drawing tended to obscure them and leave artifacts on the screen (you can
still see this by asking for SDL_HWSURFACE and leaving the mouse cursor
visible). This was true even under Win32 where GDI supposedly took care
of things - the cursor flickers.

Applications which do color cursors properly (CivCTP, HOMM3, etc.) do fancy
mixing of the cursor and the graphics updates so that the cursor was smooth
and didn’t flicker. This requires application support to work.

I posted more details on the necessary magic a while ago.

BTW, you are free to write a function to convert an XBM file to the SDL
cursor format. It might come in handy for people, though it won’t go
into the core SDL release.

See ya!
-Sam Lantinga (slouken at devolution.com)

Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec