From ed05f0ef958d73899a28bf57a1a34b33f01fe9e2 Mon Sep 17 00:00:00 2001 From: Peter Wang Date: Thu, 27 Jan 2011 08:49:52 +1100 Subject: [PATCH] In _al_try_display_format, don't expect the display-under-construction to have a real pixel format yet. This is a followup to the the failing pixel format assertions as reported by Dario ff. --- src/opengl/ogl_bitmap.c | 1 + src/pixels.c | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/opengl/ogl_bitmap.c b/src/opengl/ogl_bitmap.c index 617fa6b..ff27458 100644 --- a/src/opengl/ogl_bitmap.c +++ b/src/opengl/ogl_bitmap.c @@ -1086,6 +1086,7 @@ ALLEGRO_BITMAP *_al_ogl_create_bitmap(ALLEGRO_DISPLAY *d, int w, int h) #endif ALLEGRO_DEBUG("Chose format %s for OpenGL bitmap\n", _al_format_name(format)); + ASSERT(_al_pixel_format_is_real(format)); pitch = true_w * al_get_pixel_size(format); diff --git a/src/pixels.c b/src/pixels.c index 80f72e2..bca478f 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -217,7 +217,7 @@ bool _al_pixel_format_is_real(int format) /* We use al_get_display_format() as a hint for the preferred RGB ordering when * nothing else is specified. */ -static bool _al_try_display_format(ALLEGRO_DISPLAY *display, int *format) +static bool try_display_format(ALLEGRO_DISPLAY *display, int *format) { int best_format; int bytes; @@ -227,7 +227,9 @@ static bool _al_try_display_format(ALLEGRO_DISPLAY *display, int *format) } best_format = al_get_display_format(display); - ASSERT(_al_pixel_format_is_real(best_format)); + if (!_al_pixel_format_is_real(best_format)) + return false; + bytes = al_get_pixel_size(*format); if (bytes && bytes != al_get_pixel_size(best_format)) return false; @@ -257,20 +259,20 @@ int _al_get_real_pixel_format(ALLEGRO_DISPLAY *display, int format) switch (format) { case ALLEGRO_PIXEL_FORMAT_ANY_NO_ALPHA: case ALLEGRO_PIXEL_FORMAT_ANY_32_NO_ALPHA: - if (!_al_try_display_format(display, &format)) + if (!try_display_format(display, &format)) format = ALLEGRO_PIXEL_FORMAT_XRGB_8888; break; case ALLEGRO_PIXEL_FORMAT_ANY: case ALLEGRO_PIXEL_FORMAT_ANY_WITH_ALPHA: case ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA: - if (!_al_try_display_format(display, &format)) + if (!try_display_format(display, &format)) format = ALLEGRO_PIXEL_FORMAT_ARGB_8888; break; case ALLEGRO_PIXEL_FORMAT_ANY_15_NO_ALPHA: format = ALLEGRO_PIXEL_FORMAT_RGB_555; break; case ALLEGRO_PIXEL_FORMAT_ANY_16_NO_ALPHA: - if (!_al_try_display_format(display, &format)) + if (!try_display_format(display, &format)) format = ALLEGRO_PIXEL_FORMAT_RGB_565; break; case ALLEGRO_PIXEL_FORMAT_ANY_16_WITH_ALPHA: -- 1.7.3.2