[AD] negative colour components in primitives addon

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


This is the blinking white dots bug that Thomas reported in ex_prim.

The first part of ex_prim passes colours with slightly negative
components to al_put_pixel and al_draw_pixel, where the colours
have been computed by shader_grad_any_2d_first and shader_grad_any_2d_step.

The following assertions make the problem easy to spot.

diff --git a/src/display_new.c b/src/display_new.c
index e08f284..58f4424 100644
--- a/src/display_new.c
+++ b/src/display_new.c
@@ -193,6 +193,11 @@ void al_draw_pixel(float x, float y, ALLEGRO_COLOR color)
    ASSERT(target);
    ASSERT(display);
 
+   ASSERT(color.r >= 0);
+   ASSERT(color.a >= 0);
+   ASSERT(color.b >= 0);
+   ASSERT(color.a >= 0);
+
    if (target->flags & ALLEGRO_MEMORY_BITMAP || !display->vt->draw_pixel) {
       _al_draw_pixel_memory(target, x, y, &color);
    }
diff --git a/src/pixels.c b/src/pixels.c
index 4afad25..c6b5a5d 100644
--- a/src/pixels.c
+++ b/src/pixels.c
@@ -565,6 +565,10 @@ void _al_put_pixel(ALLEGRO_BITMAP *bitmap, int x, int y, ALLEGRO_COLOR color)
  */
 void al_put_pixel(int x, int y, ALLEGRO_COLOR color)
 {
+   ASSERT(color.r >= 0);
+   ASSERT(color.a >= 0);
+   ASSERT(color.b >= 0);
+   ASSERT(color.a >= 0);
    _al_put_pixel(al_get_target_bitmap(), x, y, color);
 }
 






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