Tricky color cursors

Sam Lantinga slouken at devolution.com
Fri Apr 24 01:00:39 PDT 1998


> I'd say "kill it". I always had a problem fitting automatic handling
> of color mouse cursors into "simple direct media". :)

I would agree, unfortunately X11 DGA and SVGAlib support both require
the application to draw the mouse.  (I forgot about that)
So, color cursors are here to stay. :)

The good news!  I cleaned up the blitting and color cursor code so it's
relatively simple and now completely thread-safe.  You can bypass multiple
levels of the blit code if you know what you're doing, or you can let SDL
do all the work of keeping track of clipping and so on.

The only time you'll run into problems is when you set a color cursor,
and you write directly to the framebuffer, and you don't call SDL_UpdateRects()
All other times, the cursor is flawlessly updated.

A very nice side effect of the new cursor code is you can now have cursors
with special effects... like alpha blending  *grin*

> For the category of applications that rebuild their display from sratch 
> every frame (like mine:), SDL can't possibly manage the cursor more
> efficiently than the application programmer. Basically, the cursor is
> just another blit, then.

True.  And if you call SDL_UpdateRect(0,0,0,0) once per frame, then the
cursor will be blitted at the end of the update.  How more efficient can
you get? :)  The blit also takes advantage of any hardware acceleration
available.  .. this isn't tested yet as the DirectX layer still has to
be brought up to speed.

Then again, if you want to handle the cursor yourself, go for it! :)
Don't forget that if you set a mouse motion callback for smooth cursor
position updates that it will run in a separate thread, and you'll have
to deal with the gnarly locking and coordination that SDL takes care of.

> Then again, I'm sure there are other applications where having the
> library handle the cursor for you saves some (complex, boring?) work.

Yep.

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

--
Author of Simple DirectMedia Layer -
	http://www.devolution.com/~slouken/SDL/
--



More information about the SDL mailing list