[AD] Line clipping bug found

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


Hello,

I have found a problem with line clipping in WIP
4.1.12.  Some code to demonstrate:

/*
 *    Program showing line drawing problem
 *
 *    Different pixels are drawn for a given line
depending on clipping.
 *    This is shown by drawing a line, changing the
clipping and then
 *    drawing the same line again.  The clipping
region should be blank.
 *
 *    The bug is in 4.1.12 but not in 4.1.11
 *
 *    Doug Eleveld
 */


#include "allegro.h"



int main(int argc, char *argv[])
{
   int i;
   PALETTE the_palette;

   if (allegro_init() != 0)
      return 1;
   install_keyboard();

   set_color_depth(16);
   if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) !=
0) {
      if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0)
{
         set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
	     allegro_message("Unable to set any graphic
mode\n%s\n", allegro_error);
	     return 1;
      }
   }

   generate_332_palette(the_palette);
   set_palette(the_palette);

   clear_to_color(screen, makecol(0,0,0));

   for (i=0; i<100; i++) {
       int x1 = rand() % SCREEN_W;
       int y1 = rand() % SCREEN_H;
       int x2 = rand() % SCREEN_W;
       int y2 = rand() % SCREEN_H;

       set_clip(screen, 0, 0, SCREEN_W, SCREEN_H);
       drawing_mode(DRAW_MODE_SOLID, screen, 0, 0);
       line(screen, x1, y1, x2, y2,
makecol(255,255,255));

       set_clip(screen, 50, 50, 150, 150);
       drawing_mode(DRAW_MODE_XOR, screen, 0, 0);
       line(screen, x1, y1, x2, y2,
makecol(255,255,255));
   }
   
   set_clip(screen, 0, 0, SCREEN_W, SCREEN_H);
   drawing_mode(DRAW_MODE_SOLID, screen, 0, 0);
   rect(screen, 49, 49, 151, 151, makecol(0,255,0));
   textout_ex(screen, font, ALLEGRO_VERSION_STR, 0, 0,
makecol(255,255,255), makecol(0,0,0));
   textout_ex(screen, font, "Box should be empty", 0,
16, makecol(255,255,255), makecol(0,0,0));

   readkey();
   return 0;
}

END_OF_MAIN();


__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus




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