Re: [AD] Bug with transparent ellipses

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


On 2006-09-03, Jon Rafkind <workmin@xxxxxxxxxx> wrote:
> Jon Rafkind wrote:
> > static COLOR_MAP _default_color_map = ..whatever..;
> > color_map = _default_color_map;
> >
> > static int default_blender15( .. ){ .. }
> >
> > _blender_func15 = default_blender15;
> >
> > The only downside would be if users tested the color_map or one of the
> > blenders for null before they are initialized. I see no reason for
> > anyone to do this or that their assumption that color_map is NULL to be
> > valid, so I think its ok for defaults to be used.
> >
> >   
> Attached patch does this.

The same thing with formatting fixed (I editted the patch directly so it
might not apply).

Peter
Index: graphics.c
===================================================================
--- graphics.c	(revision 7521)
+++ graphics.c	(working copy)
@@ -41,9 +41,11 @@
 
 int _safe_gfx_mode_change = 0;         /* are we getting through GFX_SAFE? */
 
-RGB_MAP *rgb_map = NULL;               /* RGB -> palette entry conversion */
+static RGB_MAP _default_rgb_map;
+RGB_MAP *rgb_map = &_default_rgb_map;  /* RGB -> palette entry conversion */
 
-COLOR_MAP *color_map = NULL;           /* translucency/lighting table */
+static COLOR_MAP _default_color_map;
+COLOR_MAP *color_map = &_default_color_map; /* translucency/lighting table */
 
 int _color_depth = 8;                  /* how many bits per pixel? */
 
@@ -64,15 +66,23 @@
 
 int *palette_color = _palette_color8; 
 
-BLENDER_FUNC _blender_func15 = NULL;   /* truecolor pixel blender routines */
-BLENDER_FUNC _blender_func16 = NULL;
-BLENDER_FUNC _blender_func24 = NULL;
-BLENDER_FUNC _blender_func32 = NULL;
+/* the do nothing blender */
+static unsigned long default_blender(unsigned long x, unsigned long y, unsigned long c)
+{
+   (void)x;
+   (void)y;
+   return c;
+}
 
-BLENDER_FUNC _blender_func15x = NULL;
-BLENDER_FUNC _blender_func16x = NULL;
-BLENDER_FUNC _blender_func24x = NULL;
+BLENDER_FUNC _blender_func15 = default_blender;   /* truecolor pixel blender routines */
+BLENDER_FUNC _blender_func16 = default_blender;
+BLENDER_FUNC _blender_func24 = default_blender;
+BLENDER_FUNC _blender_func32 = default_blender;
 
+BLENDER_FUNC _blender_func15x = default_blender;
+BLENDER_FUNC _blender_func16x = default_blender;
+BLENDER_FUNC _blender_func24x = default_blender;
+
 int _blender_col_15 = 0;               /* for truecolor lit sprites */
 int _blender_col_16 = 0;
 int _blender_col_24 = 0;


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