Tricky color cursors

Sam Lantinga slouken at devolution.com
Fri Apr 24 01:25:05 PDT 1998


> Seems like DirectX is causing you a great deal of trouble. Is it just
> bad luck, or was there more evil in there than you'd expected?

My debugger works under X11. :)
I prefer to get as much of the code working using X11 and gdb as possible,
until I start having to do fprintf under DirectX.

It trains you to look long and carefully at your code, most of the time. :)

> Hm... That's a good reason to think twice about handling the mouse
> myself. :) I still haven't gotten around to thinking that dealing
> with the down side of concurrency is much fun... :( But, hey, I could
> just poll the mouse position every frame, right? Perhaps not so
> smooth, but simpler.

Great idea. :)

What you would end up doing is:

	if ( SDL_MUSTLOCK(screen) ) {
		if ( SDL_LockSurface(screen) < 0 )
			return;
	}
	write write write a frame
	if ( SDL_MUSTLOCK(screen) ) {
		SDL_UnlockSurface(screen);
	}
	SDL_GetMouseState(&x, &y);
	blit mouse sprite
	SDL_UpdateRect(0, 0, 0, 0);

Actually, it would be faster just to let SDL handle it.
You either have to clip the cursor yourself or let SDL clip it in which
case it's just as easy to let SDL do the work.  I dunno.  The gains don't
seem very high, especially when SDL can do it for you, and the codepaths
are designed to do so.  

If you have a black and white cursor, the window manager cursor is used 
whenever possible, though in constant-refresh conditions there's usually 
a lot of flicker.

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