RE: [AD] user data

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


Title: RE: [AD] user data

> Of course. But in the two examples you gave, you could have used the
> wrapper method (derived class for MY_DIALOG and encapsulated
> pointer for
> MY_BITMAP), no ? But I agree that's not the general case.

It could possibly done, but the code would be rather more hairy
than being able to attach info on the structure itself.
Say I want to extend a BITMAP loader, and register its load/save
routines to Allegro. I need to know, after a BITMAP was loaded
using the registered load function, if, say, the image contained
a string (could be used to encode locations in the image where
a given feature is, for instance (eg you have a sprite which
represents a human being, and you want to encode where the hand
lies, say to blit an item's sprite here)). I could create another
structure, with a BITMAP pointer in it, and the data I want to
retrieve, and return this, but this would incur major casting,
since the Allegro framework returns a BITMAP pointer. Attaching
this custom data to a user pointer stored in the BITMAP structure
itself removes this constraint.
Either that, or I didn't spot the possibility you mentionned :)
Cheers

--
Vincent Penquerc'h



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