Re: [AD] Logic in al_load_bitmap |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Patch attached
Pete
On Tue, Feb 26, 2008 at 11:32 PM, Trent Gamblin <trent@xxxxxxxxxx> wrote:
> On Tue, February 26, 2008 2:34 pm, Peter Hull said:
> > I've got a question about this one too. In these lines:
> > /* If it's a display bitmap */
> > if (!(al_get_new_bitmap_flags() & ALLEGRO_MEMORY_BITMAP) &&
> > bitmap) {
> > bitmap->vt->upload_bitmap(bitmap, 0, 0, bitmap->w, bitmap->h);
> > }
> > would it be better to test bitmap->flags rather than
> > al_get_new_bitmap_flags? It doesn't matter except if a display
> > driver
> > doesn't support any accelerated bitmaps and returns a memory bitmap
> > instead. Then the upload_bitmap vtable function is NULL and it
> > crashes.
> >
> > Pete
>
> Yes, I think you're right again. Good eye.
>
>
> Trent
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> --
> https://lists.sourceforge.net/lists/listinfo/alleg-developers
>
Index: src/bitmap_new.c
===================================================================
--- src/bitmap_new.c (revision 10045)
+++ src/bitmap_new.c (working copy)
@@ -73,7 +73,7 @@
memset(bitmap, 0, sizeof *bitmap);
bitmap->format = format;
- bitmap->flags = al_get_new_bitmap_flags();
+ bitmap->flags = al_get_new_bitmap_flags() | ALLEGRO_MEMORY_BITMAP;
bitmap->w = w;
bitmap->h = h;
bitmap->display = NULL;
@@ -113,7 +113,8 @@
{
ALLEGRO_BITMAP *bitmap;
- if (al_get_new_bitmap_flags() & ALLEGRO_MEMORY_BITMAP) {
+ if ((al_get_new_bitmap_flags() & ALLEGRO_MEMORY_BITMAP) ||
+ (_al_current_display->vt->create_bitmap == NULL)) {
return _al_create_memory_bitmap(w, h);
}