[SDL] Best way to display bitmaped mouse pointer
citrouille at wanadoo.fr
Mon Aug 23 11:38:58 PDT 2004
I want an app that needs a colored mouse cursor. Seeing that the
SDL_SetCursor function doesn't provide colored pointer, I think that
the only way to do that is blitting to the screen a small bitmap (32x32 for example)
in each mousemotion event.
Now my problem is simple, I find my way to display the mouse cursor
very very slow, because I redraw whole screen before displaying
the mouse pointer...
like this :
SDL_Surface *screen; //video's framebuffer surface
SDL_Surface *mouse; // mouse surface loaded from PNG file with pink
/*... video init stuff in 800x600x16 and double buffered ..*/
mouse = IMG_Load("cursor.png");
mouse = SDL_DisplayFormat(mouse);
mousepos.x = ev.motion.x;
mousepos.y = ev.motion.y;
SDL_FillRect(screen, NULL, 0x0000);
SDL_BlitSurface(mouse, NULL, screen, &mousepos);
This small program, when heavily charged with graphics may be more slow,
because I need to redraw all.
Is there a best way to display a mouse pointer like this very quickly
More information about the SDL