Okay, that helps tremendously. From your description, it appears that
show_mouse() is a mouse driver, which I suspected it was. So show_mouse() is
really an optional function. That makes so much more sense now, since I could
already see and use the mouse pointer before calling show_mouse(). It would be
nice if the Allegro mouse example used show_os_cursor() instead of
show_mouse(), since show_mouse() only seems necessary for DOS apps that don't
support a hardware cursor.

Thanks for the very informative help, Peter.

On 5/11/2016 at 12:53 AM, Peter Hull <[email protected]> wrote: 
I think the docs are fairly clear on what you need to do but maybe not why.
Mostly these days we don't need to worry about the mouse cursor because the
windowing system takes care of it (a 'hardware cursor' in Allegro language).
However Allegro supports platforms where this is not the case. The mouse
cursor is just another sprite that needs drawing on the screen. Allegro gives
you the show_mouse function to help, BUT, all it's doing is:

1. capture a little chunk of the screen or bitmap

2. draw the cursor (using draw_sprite or similar)

3. wait til the mouse moves

4. replace that little chunk at its original position

5. repeat

It's your responsibility to tell the mouse system that you're drawing on the
bitmap - or destroying the bitmap. That's why, in the website tutorial, the
author of the example himself notes that moving the cursor can leave square
blocks on the screen.


As to why it crashes or doesn't crash - that must depend on the order things
happen during Allegro clean-up. If it stops monitoring the mouse before it
destroys the bitmap, you'll get away with it. This is not Allegro specific but
the documentation tells you what is correct - if you don't follow that it may
work (now, and on your platform) but it may not work in the future or on a
different platform.



So, 
If your platform supports hardware cursors, use them.

If you're writing a 'tool' like the grabber which doesn't update the screen
much, use show_bitmap(screen) but make sure to show_bitmap(NULL) before you
update the screen and show_bitmap(screen) after

If you're writing a game with lots of fullscreen updates, just use Allegro to
read the mouse position and draw the cursor yourself like you would any game
sprite.


I wouldn't ever use show_bitmap(buffer).


Hope that helps,

Pete
_______________________________________________
Allegro-developers mailing list
[email protected]
https://mail.gna.org/listinfo/allegro-developers

Reply via email to