[AD] Logic in al_load_bitmap |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
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
/* Function: al_load_bitmap
*
* Load a bitmap from a file using the bitmap format and flags of
* the current thread.
*
* See Also: <al_set_new_bitmap_format>, <al_set_new_bitmap_flags>
*/
ALLEGRO_BITMAP *al_load_bitmap(char const *filename)
{
ALLEGRO_BITMAP *bitmap;
bitmap = _al_load_memory_bitmap(filename);
/* 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);
}
return bitmap;
}