Re: [AD] New graphics API, take 2

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


On January 6, 2002 09:37 am, you wrote:
> In reply to Shawn Hargreaves <shargreaves@xxxxxxxxxx>:
> >It would actually be really handy (and would have been in
> >the past for some drivers) if there was a way to attach
> >multiple independent bits of custom data to a bitmap.
>
> Rather than having lots of different structures, why not have one
> structure with a pointer to a variable-sized chunk of data:
>
> struct AL_BITMAP {
>   AL_BITMAP_VTABLE* vtable;
>
>   int w, h;
>   int cl, cr, ct, cp;
>   /* all usual bitmap stuff */
>
>   struct AL_BITMAP_CHUNK* chunk;
> };
>
> struct AL_BITMAP_CHUNK {
>   int id; /* from DAT_ID() equivalent */
>   void* dat;
> };
>
> and have chunk be a dynamically-allocated array, terminated with a { 0,
> 0 } element. Even if it ever needs to be resized, you could use
> realloc().
>
> Bye for now,

Or even just something like:

struct AL_BITMAP_CHUNK {
  int id;
  char thing[0];
};

so 'chunk' can be casted to what ever it really is, but the lib shouldnt care 
what it is nor how to destroy it.

ie:
AL_DISPLAY_INFO *disp_info = (AL_DISPLAY_INFO *)bitmap->chunk;

-- 
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx
http://strangesoft.net



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