Re: [AD] Runtime Gfx Mode Info - Submission for A4.3.11+

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


Are there any objections to adding the get_gfx_mode_type and get_gfx_mode functions and documentation I wrote to A4.3.11+? It's been ten days or so, so I am wondering if everyone is okay with it. The diff file for them is attached.

Thanks,
Edgar

Index: docs/src/allegro._tx
===================================================================
--- docs/src/allegro._tx	(revision 11621)
+++ docs/src/allegro._tx	(working copy)
@@ -4389,6 +4389,52 @@
    it is a fullscreen mode. You should not call this function if you are not
    in graphics mode.
 
+@@int @get_gfx_mode_type(int graphics_card);
+@xref gfx_mode_select_filter, get_gfx_mode, set_gfx_mode, is_windowed_mode
+@shortdesc Retrieves type information for a specific graphics card.
+   This function lets you determine the types of operating modes that a
+   specific graphics card driver operates in. It will tell you whether it is
+   a windowed, fullscreen, definitely windowed or fullscreen, and/or a magic
+   driver.
+   
+   The value returned is a bitfield consisting of these fields :
+   GFX_TYPE_UNKNOWN
+   GFX_TYPE_WINDOWED
+   GFX_TYPE_FULLSCREEN
+   GFX_TYPE_DEFINITE
+   GFX_TYPE_MAGIC
+   
+   The return value will only be equivalent to GFX_TYPE_UNKNOWN when it is
+   a driver unrecognized on that platform, or it is a bogus value. Test for
+   the other types by using a bitwise AND. If the driver is windowed or
+   fullscreen, it will also have the definite flag set. 
+   For example, get_gfx_mode_type(GFX_AUTODETECT_WINDOWED) would have the
+   flags GFX_TYPE_WINDOWED, GFX_TYPE_DEFINITE, and GFX_TYPE_MAGIC set.
+   
+   Allegro needs to be initialized first.
+   
+   Example :
+<codeblock>
+   /* Accept the use of only windowed drivers in our selection dialog */
+   int accept_windowed(int card , int w , int h , int color_depth) {
+      if (get_gfx_mode_type(card) & GFX_TYPE_WINDOWED) {return 0;}
+      return 1;
+   }
+   /* In main : */
+   gfx_mode_select_filter(&card , &w , &h , &color_depth , accept_windowed);
+<endblock>
+@retval Bitfield describing graphics mode type.
+
+@@int @get_gfx_mode();
+@xref set_gfx_mode, is_windowed_mode
+@shortdesc Returns the id of the current graphics driver.
+   This function will let you determine which graphics driver is currently
+   set by allegro. If no graphics driver is set, it will return GFX_NONE.
+   
+@retval
+   The id of the current graphics driver if there is one, or
+   GFX_NONE if none is set.
+
 @@extern int @gfx_capabilities;
 @xref screen, create_video_bitmap, scroll_screen, request_scroll, show_mouse
 @xref enable_triple_buffer
Index: include/allegro/gfx.h
===================================================================
--- include/allegro/gfx.h	(revision 11621)
+++ include/allegro/gfx.h	(working copy)
@@ -428,7 +428,17 @@
 AL_FUNC(void, vsync, (void));
 
 
+/* Bitfield for relaying graphics driver type information */
+#define GFX_TYPE_UNKNOWN     0
+#define GFX_TYPE_WINDOWED    1
+#define GFX_TYPE_FULLSCREEN  2
+#define GFX_TYPE_DEFINITE    4
+#define GFX_TYPE_MAGIC       8
 
+AL_FUNC(int , get_gfx_mode_type , (int graphics_card));
+AL_FUNC(int , get_gfx_mode , (void));
+
+
 #define SWITCH_NONE           0
 #define SWITCH_PAUSE          1
 #define SWITCH_AMNESIA        2
Index: src/graphics.c
===================================================================
--- src/graphics.c	(revision 11621)
+++ src/graphics.c	(working copy)
@@ -1750,3 +1750,76 @@
 }
 
 
+
+/* get_gfx_mode_type:
+ *  Evaluates the type of the graphics driver card
+ *  and tells you whether it is a windowed, fullscreen,
+ *  definitely windowed or fullscreen, and/or a magic driver.
+ *  See gfx.h for the GFX_TYPE_* defines.
+ */
+int get_gfx_mode_type(int graphics_card)
+{
+   int gfx_type = GFX_TYPE_UNKNOWN;
+   _DRIVER_INFO* gfx_driver_info;
+   GFX_DRIVER*   gfx_driver_entry;
+
+   ASSERT(system_driver);
+
+   /* Ask the system driver for a list of graphics hardware drivers */
+   if (system_driver->gfx_drivers) {
+      gfx_driver_info = system_driver->gfx_drivers();
+   }
+   else {
+      gfx_driver_info = _gfx_driver_list;
+   }
+
+   ASSERT(gfx_driver_info);
+
+   while(gfx_driver_info->driver) {
+      if (gfx_driver_info->id == graphics_card) {
+         gfx_driver_entry = (GFX_DRIVER*)gfx_driver_info->driver;
+         if (gfx_driver_entry->windowed) {
+            gfx_type |= (GFX_TYPE_WINDOWED   | GFX_TYPE_DEFINITE);
+         }
+         else {
+            gfx_type |= (GFX_TYPE_FULLSCREEN | GFX_TYPE_DEFINITE);
+         }
+         break;
+      }
+      ++gfx_driver_info;
+   }
+
+   switch (graphics_card) {
+      case GFX_AUTODETECT:
+         gfx_type |= GFX_TYPE_MAGIC;
+         break;
+      case GFX_AUTODETECT_FULLSCREEN:
+         gfx_type |= (GFX_TYPE_MAGIC | GFX_TYPE_FULLSCREEN | GFX_TYPE_DEFINITE);
+         break;
+      case GFX_AUTODETECT_WINDOWED:
+         gfx_type |= (GFX_TYPE_MAGIC | GFX_TYPE_WINDOWED   | GFX_TYPE_DEFINITE);
+         break;
+      case GFX_SAFE:
+         gfx_type |= GFX_TYPE_MAGIC;
+         break;
+      case GFX_TEXT:
+         gfx_type |= GFX_TYPE_MAGIC;
+         break;
+   }
+   return gfx_type;
+}
+
+
+
+/* get_gfx_mode:
+ *  Tells you which graphics mode is currently set.
+ *  Useful for determining the actual driver that
+ *  GFX_AUTODETECT* or GFX_SAFE set successfully.
+ */
+int get_gfx_mode(void) {
+   if (!gfx_driver) {return GFX_NONE;}
+   return gfx_driver->id;
+}
+
+
+


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