Re: [AD] Line clipping bug found

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


I dont see a bug here. When you draw the first line, you have chosen
coordinates x1, y1, x2, y2. When you set the clipping rectangle and draw
the same line, the line algorithm adjusts the line so that it fits
within the clipping rectangle instead of drawing the entire line and
wasting alot of cycles figuring out whether or not to put a pixel that
doesnt belong. What should happen is the second line you draw erases the
first line, becuase of DRAW_XOR_MODE, but only a few pixels are getting
erased. I assume( although I havent verified ) that this is becuase the
clipped line has different x1, y1, x2, y2 coordinates. 

Anyone think something can be done about this?

On Thu, 8 Jan 2004 04:10:49 -0800 (PST)
Doug Eleveld <djeleveld@xxxxxxxxxx> wrote:

> 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
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: Perforce Software.
> Perforce is the Fast Software Configuration Management System offering
> advanced branching capabilities and atomic changes on 50+ platforms.
> Free Eval! http://www.perforce.com/perforce/loadprog.html
> -- 
> https://lists.sourceforge.net/lists/listinfo/alleg-developers
> 




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