Re: [AD] 4.9.20

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


On Mon, 2010-05-17 at 10:58 +0200, Elias Pschernig wrote:
> 
> Anyway, I can try making a capabilities patch until the start of the
> weekend - it wouldn't work on all platforms but at least the API would
> be there.
> 

Ok, here is a version which should work for all OpenGL drivers. Also
updates ex_display_options and the documentation.

-- 
Elias Pschernig <elias.pschernig@xxxxxxxxxx>
diff --git a/docs/src/refman/display.txt b/docs/src/refman/display.txt
index 9342779..3726a5c 100644
--- a/docs/src/refman/display.txt
+++ b/docs/src/refman/display.txt
@@ -108,6 +108,25 @@ The supported options are:
     [al_update_display_region] is equivalent to [al_flip_display].
 *   ALLEGRO_VSYNC: Set to 1 to tell the driver to wait for vsync
     in [al_flip_display], or to 2 to force vsync off. 
+*   ALLEGRO_MAX_BITMAP_SIZE: When queried this returns the maximum
+    size (width as well as height) a bitmap can have for this
+    display. Calls to [al_create_bitmap] or [al_load_bitmap] for
+    bitmaps larger than this size will fail. It does not apply to memory
+    bitmaps which always can have arbitrary size (but are slow for
+    drawing).
+*   ALLEGRO_SUPPORT_NPOT_BITMAP: Set to 1 if textures used for bitmaps
+    on this display can have a size which is not a power of two. This
+    is mostly useful if you use Allegro to load textures as otherwise
+    only power-of-two textures will be used internally as bitmap
+    storage.
+*   ALLEGRO_CAN_DRAW_INTO_BITMAP: Set to 1 if you can use
+    [al_set_target_bitmap] on bitmaps of this display to draw into them.
+    If this is not the case software emulation will be used when drawing
+    into display bitmaps (which can be very slow).
+*   ALLEGRO_SUPPORT_SEPARATE_ALPHA: This is set to 1 if the
+    [al_set_separate_blender] function is supported. Otherwise the
+    alpha parameters will be ignored.
+
 
 FIXME: document them all in detail
 
diff --git a/examples/ex_display_options.c b/examples/ex_display_options.c
index 2e3743a..ec01dde 100644
--- a/examples/ex_display_options.c
+++ b/examples/ex_display_options.c
@@ -51,6 +51,10 @@ struct {
     X(SWAP_METHOD, 1),
     X(VSYNC, 1),
     X(COMPATIBLE_DISPLAY, 1),
+    X(MAX_BITMAP_SIZE, 65536),
+    X(SUPPORT_NPOT_BITMAP, 1),
+    X(CAN_DRAW_INTO_BITMAP, 1),
+    X(SUPPORT_SEPARATE_ALPHA, 1),
 };
 
 static void display_options(void)
diff --git a/include/allegro5/display_new.h b/include/allegro5/display_new.h
index 8302dc9..f8530e4 100644
--- a/include/allegro5/display_new.h
+++ b/include/allegro5/display_new.h
@@ -59,6 +59,10 @@ enum ALLEGRO_DISPLAY_OPTIONS {
    ALLEGRO_COMPATIBLE_DISPLAY,
    ALLEGRO_UPDATE_DISPLAY_REGION,
    ALLEGRO_VSYNC,
+   ALLEGRO_MAX_BITMAP_SIZE,
+   ALLEGRO_SUPPORT_NPOT_BITMAP,
+   ALLEGRO_CAN_DRAW_INTO_BITMAP,
+   ALLEGRO_SUPPORT_SEPARATE_ALPHA,
    ALLEGRO_DISPLAY_OPTIONS_COUNT
 };
 
diff --git a/include/allegro5/internal/aintern_display.h b/include/allegro5/internal/aintern_display.h
index 488ba73..64773ee 100644
--- a/include/allegro5/internal/aintern_display.h
+++ b/include/allegro5/internal/aintern_display.h
@@ -91,9 +91,10 @@ typedef struct ALLEGRO_BLENDER
 /* These are settings Allegro itself doesn't really care about on its
  * own, but which users may want to specify for a display anyway.
  */
+ALLEGRO_STATIC_ASSERT(ALLEGRO_DISPLAY_OPTIONS_COUNT <= 32);
 typedef struct
 {
-   int required, suggested;
+   int required, suggested; /* Bitfields. */
    int settings[ALLEGRO_DISPLAY_OPTIONS_COUNT];
 
    /* These are come in handy when creating a context. */
diff --git a/src/opengl/extensions.c b/src/opengl/extensions.c
index 1d43a9b..7969db2 100644
--- a/src/opengl/extensions.c
+++ b/src/opengl/extensions.c
@@ -771,19 +771,32 @@ void _al_ogl_manage_extensions(ALLEGRO_DISPLAY *gl_disp)
          }
       }
    }
+   
+   {
+      int *s = gl_disp->extra_settings.settings;
+      glGetIntegerv(GL_MAX_TEXTURE_SIZE, s + ALLEGRO_MAX_BITMAP_SIZE);
+   
+      if (gl_disp->ogl_extras->ogl_info.version >= 2.0)
+         s[ALLEGRO_SUPPORT_SEPARATE_ALPHA] = 1;
 
+      s[ALLEGRO_SUPPORT_NPOT_BITMAP] =
+         ext_list->ALLEGRO_GL_ARB_texture_non_power_of_two;
    ALLEGRO_INFO("Use of non-power-of-two textures %s.\n",
-      ext_list->ALLEGRO_GL_ARB_texture_non_power_of_two ? "enabled" :
-      "disabled");
+      s[ALLEGRO_SUPPORT_NPOT_BITMAP] ? "enabled" : "disabled");
 #ifdef ALLEGRO_IPHONE
+   s[ALLEGRO_CAN_DRAW_INTO_BITMAP] =
+      ext_list->ALLEGRO_GL_OES_framebuffer_object;
    ALLEGRO_INFO("Use of FBO to draw to textures %s.\n",
-      ext_list->ALLEGRO_GL_OES_framebuffer_object ? "enabled" :
+      s[ALLEGRO_CAN_DRAW_INTO_BITMAP] ? "enabled" :
       "disabled");
 #else
+   s[ALLEGRO_CAN_DRAW_INTO_BITMAP] =
+      ext_list->ALLEGRO_GL_EXT_framebuffer_object;
    ALLEGRO_INFO("Use of FBO to draw to textures %s.\n",
-      ext_list->ALLEGRO_GL_EXT_framebuffer_object ? "enabled" :
+      s[ALLEGRO_CAN_DRAW_INTO_BITMAP] ? "enabled" :
       "disabled");
 #endif
+   }
 }
 
 


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