Colorful Mousecursrors with SDL

Hi :slight_smile:

I’m doing a programm in which I like to use my own mousecurosr. I tried to use
the CreateCurosr function and made a black-white curosr. But I want to have a
colorful Curosr.

Can anyone tell, how to do that?

Thanks in advance
Daniel

  1. Hide the system cursor (check SDL API)
  2. When you draw your graphics, also draw a SDL_Surface at the
    location of the mouse cursor. Voila!

/OlofOn Thu, 27 Jan 2005 08:48:20 +0000 (UTC), Daniel Pomrehn wrote:

Hi :slight_smile:

I’m doing a programm in which I like to use my own mousecurosr. I tried to use
the CreateCurosr function and made a black-white curosr. But I want to have a
colorful Curosr.

Can anyone tell, how to do that?

Thanks in advance
Daniel


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi :slight_smile:

  1. Hide the system cursor (check SDL API)
  2. When you draw your graphics, also draw a SDL_Surface at the
    location of the mouse cursor. Voila!

Thank you for the answer. the cursor works now, but there is one problem
with it:
When I move the curosr I must repaint the Place, from which the cursor had
moved. How can I do that? I know, how I can to it theoratically, but there
is the problem, that the background, which has to be repainted can scroll.
So I don’t know, what I have to paint there.

Thanks in advance
Daniel

Hi,

In the case of a scrolling background, the easiest and most efficient
solution is usually to repaint the whole screen each frame.

For the few cases where it isn’t, there is a technique called “Dirty
rects”, which you might try googling for. But it’s a whole lot more
complicated than just repainting everything, and usually not worth the
effort.

-Sebastian

Daniel schrieb:> Hi :slight_smile:

  1. Hide the system cursor (check SDL API)
  2. When you draw your graphics, also draw a SDL_Surface at the
    location of the mouse cursor. Voila!

Thank you for the answer. the cursor works now, but there is one problem
with it:
When I move the curosr I must repaint the Place, from which the cursor had
moved. How can I do that? I know, how I can to it theoratically, but there
is the problem, that the background, which has to be repainted can scroll.
So I don’t know, what I have to paint there.

Thanks in advance
Daniel


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi,

In the case of a scrolling background, the easiest and most
efficient
solution is usually to repaint the whole screen each frame.

Yep. Simple, robust, portable, no problems with unusual buffering
implementations etc.

For the few cases where it isn’t, there is a technique called “Dirty
rects”, which you might try googling for. But it’s a whole lot more
complicated than just repainting everything, and usually not worth
the effort.

I’d say it’s definitely worth the effort (at least if you care one
bit about smooth animation), unless you have a constantly scrolling
background.

Without h/w acceleration, frame rates quickly drop way below 50 FPS
with 24 or 32 bit color and 800x600+ resolutions - but unless you
have an extremely crowded screen (tons of sprites), you can up that
to the hundreds or thousands range, pretty much regardless of
resolution and video backend.

(Of course, this is “free-running” FPS! If you can get retrace sync’ed
page flipping, you should use it whenever you’re not benchmarking.)

Have a look at Fixed Rate Pig:

Site: http://olofson.net/examples.html
Direct: http://olofson.net/download/pig-1.0.tar.gz

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Thursday 27 January 2005 16.55, Sebastian Beschke wrote:

— Daniel escreveu:
Hi there.

There are two easy ways (without h/w accell):

1 - keep a record of your mouse (i.e: oldX, oldY) and
if oldX != x you do a repaint at (oldX, oldY, cursorW,
cursorH)
2 - repaint eveything at every frame.

Hope I helped,

In?cio.> Hi :slight_smile:

  1. Hide the system cursor (check SDL API)
  2. When you draw your graphics, also draw a
    SDL_Surface at the
    location of the mouse cursor. Voila!

Thank you for the answer. the cursor works now, but
there is one problem
with it:
When I move the curosr I must repaint the Place,
from which the cursor had
moved. How can I do that? I know, how I can to it
theoratically, but there
is the problem, that the background, which has to be
repainted can scroll.
So I don’t know, what I have to paint there.

Thanks in advance
Daniel


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Yahoo! Acesso Gr?tis - Instale o discador do Yahoo! agora. http://br.acesso.yahoo.com/ - Internet r?pida e gr?tis

J Inacio wrote:

1 - keep a record of your mouse (i.e: oldX, oldY) and
if oldX != x you do a repaint at (oldX, oldY, cursorW,
cursorH)
2 - repaint eveything at every frame.

3 - backup the rectangle of the screen surface directly under the cursor
before you blit the cursor. befor you start scrolling and repainting the
next frame, blit the backup back to the screen. at last, calculate new
cursor position, do next backup and start over.

clemens