[AD] Re: Line clipping bug found

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


Sorry, I dont know how to 'reply' to keep everything
in the same'thread...

From: Jon Rafkind <workmin@xxxxxxxxxx...>  
>I dont see a bug here. When you draw the first line
>you have chosen coordinates x1, y1, x2, y2. When you 
...snip...

This new clipping behaviour breaks (at least my) guis
which rely on drawing a line several times with
different clipping areas to simulate layered windows. 
I dont know it it would break other often used
patterns.

The problem does not lie with the cohen-southerland
line clipping.  Its the line-end transformations done
change the line in the sense that the slope gets
changed.  Its not the same line anymore.

My personal approach, which I thought allegro actually
did, was to use cohen-southerland to clip trivial
lines, and then use what I call split-bresenham for
the drawing the lines.  This means once we get a line
that might have visible pixels, have a bresenham loop
without a putpixel that runs until we reach the edge
of the clipping area, and then another bresenham loop
with a putpixel that runs until the other edge of the
clipping area gets reached.  This way you can use an
unclipped putpixel for speed and your only loss is the
first bresenham loop.  But that has no putpixel in it
so it should be quite fast.

I have implemented this method for my own GFX lib (not
released yet) and it shouldn't be too much to do it
for allegro too.  Although I am an occasional allegro
user, and certianly not an allegro expert.

This approach might be faster than using a clipped
pixel function in the inner loop, but I am not sure. 
I was under the impression that (previous WIP versions
of) allegro actually did this but looking at the
recent sources maybe I am wrong.

I was also under the impression that X-Windows uses a
pixel-correct line clipping method maybe it is
possible to look into how they do it.  Maybe they have
some other even more clever way to do it.

Doug Eleveld




__________________________________
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/