Re: [AD] Bug with transparent ellipses |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: Coordination of admins/developers of the game programming library Allegro <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] Bug with transparent ellipses
- From: Jon Rafkind <workmin@xxxxxxxxxx>
- Date: Sun, 03 Sep 2006 22:24:15 -0400
Jon Rafkind wrote:
> Elias Pschernig wrote:
>
>> On Sun, 2006-09-03 at 19:08 -0400, Jon Rafkind wrote:
>>
>>
>>> Ok, but with your patch doesnt it automatically use al_assert whereas
>>> al_assert is only turned on when DEBUGMODE is enabled?
>>>
>>> #ifdef DEBUGMODE
>>> #define ASSERT(condition) { if (!(condition)) al_assert(__FILE__,
>>> __LINE__); }
>>> #define TRACE al_trace
>>> #else
>>> #define ASSERT(condition)
>>> #define TRACE 1 ? (void) 0 : al_trace
>>> #endif
>>>
>>> so the code would somehow have to use ASSERT(color_map), right?
>>>
>>>
>>>
>> I added an #ifdef DEBUGMODE with the patch, so without DEBUGMODE, the
>> old macro should get used.
>>
>>
>>
> You are right, I missed that the first time around. As we talked about
> in #allegro I think its safer to have defaults for color_map and the
> blenders. Also maybe a default rgb_map. I think Allegro should try as
> hard as possible not to crash. This could be accomplished by something like
>
> 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.
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,20 @@
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 ){
+ 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;