Re: [AD] Don't use Devpaks

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


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





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/