Re: [AD] Renamed API second draft

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


Bob wrote:
> It's a simple matter of making RLE/compiled sprites be BITMAPs instead
> of RLE_SPRITE and COMPILED_SPRITE. Of course, not every operation on
> those bitmaps will be supported, but it would allow us to add support
> for them later on.

But there is no such thing as a compiled or rle sprite which you can
write to or rotate! A compiled sprite is  naturally only good for being
drawn as it is and you cannot rotate it. Similarly, an RLE sprite can't
be rotated because you can't read from a random position in it (in
constant time).

Moreover, rle sprites and compiled sprites are mutually fundamentally
different: you can draw an rle sprite with clipping and translucency and
perhaps stretch it, but you can't do any of these with a compiled
sprite. A compiled sprite only supports one drawing operation, and it is
the one that it was compiled to do: draw_sprite().

So I think rle sprites, compiled sprites, and bitmaps are (and must be)
too different to be useful to have in the same struct. If you want a
transparent API, why not just do the trivial:

   typedef struct PICTURE {
      void (*draw)(PICTURE *src, BITMAP *dest, int x, int y);
      void *data;
   } PICTURE;

   static void _draw_bmp(PICTURE *src, BITMAP *dest, int x, int y) {
      draw_sprite((BITMAP *)dest->data, src, x, y);
   }
   PICTURE *create_bmp_picture(BITMAP *bmp) {
      PICTURE *result = malloc(sizeof(PICTURE));
      result->draw = _draw_bmp;
      result->data = bmp;
      return result;
   }
   ...
   /* similar for create_rle_picture() and create_compiled_picture */
   ...
   void draw_picture(PICTURE *src, BITMAP *dest, int x, int y) {
      src->draw(src, dest, x, y);
   }

> It would also allow us to add new bitmap types,
> since there's only one set of functions to work with.

So does the mini-api given above, which can easily be extended to an
add-on.

-- 
Sven Sandberg   svsa1977@xxxxxxxxxx   home.student.uu.se/svsa1977



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