Re: [AD] al_convert_bitmap

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


On Thu, Jun 9, 2011 at 6:00 PM, Elias Pschernig
<elias.pschernig@xxxxxxxxxx> wrote:
> My line of thought is, why would I ever call al_load_bitmap or
> al_create_bitmap if I don't want a bitmap? The use cases I'm thinking of
> whenever I use the VIDEO flag if it fails I would then repeat whatever I
> did with MEMORY anyway (so could have used ANY right away).
>
The current implementation bothers me because sometimes the VIDEO flag
falls back to a memory (no display exists) and other times it does not
(display exists).

I also think the name is a misnomer if it falls back to memory
bitmaps, which is why I prefer the flags ANY, MEMORY, VIDEO. Now if
you don't like messing with backward compatibility, it could be
implemented with:

VIDEO: falls back to memory bitmap on failure, even if display exists
(changed behavior)
MEMORY: always returns memory (same as current behavior)
REQUIRE_VIDEO: always returns video (new flag)

I don't really like the above names, but the important bit to me is
that there is an option that always falls back. That currently is
missing.

Regarding your preference of fall back code, my suggestion doesn't
exclude you from picking an option that falls back to memory
automatically. In fact, right now, you cannot write it that way since
Allegro will fail if you try to load a video bitmap that is too large.

But I agree that generally the "require video" would not be very
useful. But to me, this makes the most sense from a naming convention:

set_new_bitmap_flags(0); // will try video first or memory as a fall back
set_new_bitmap_flags(ALLEGRO_ANY_BITMAP); // same as above
set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); // only return video
set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); // only return memory

The documentation says "Creates a bitmap that resides in the video
card memory." The silent conversion to memory bitmaps when no display
is present is not mentioned. So to me, changing the behavior to work
like above will not be surprising to most people.

> Actually, another use for tags could be fonts. If I load a bitmap font
> in another thread there currently is no way to convert it
>
The "convert all bitmaps" would convert them, right?

But shouldn't the font addon always try to use video bitmaps
regardless? I don't think the programmer should have to be aware of
how the fonts are implemented. That is, to me, I don't even know if
the font addon should respect the bitmap flags.

And doesn't there need to be a clone_font() if you want to use the
same font on multiple displays?

--
Matthew Leverton




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