Re: [AD] Line clipping bug found |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Thu, 2004-01-08 at 13:49, Jon Rafkind wrote:
> 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?
>
An easy work-around is:
Replace:
drawing_mode (DRAW_MODE_XOR, screen, 0, 0);
line (screen, x1, y1, x2, y2, makecol (255, 255, 255));
by:
drawing_mode (DRAW_MODE_XOR, screen, 0, 0);
do_line (screen, x1, y1, x2, y2, makecol (255, 255, 255), putpixel);
Of course, this work-around at the same time suggests that it really is
sort of a bug, or at least a regression from previous versions. Since
it's so easy to get the expected behavior thogh, and at the same time I
think I remember the pre-clipping showed to speed up lines with very
huge dimensions - it's probably ok.
Of course, the best solution would be someone who knows a bit about the
Bresenham algorithm to just add the code to also clip the Bresenham
state, when clipping the line.. Shouldn't be too hard..
--
Elias Pschernig <elias@xxxxxxxxxx>