Closed HomineLudens closed 6 years ago
This isn't a bug with clipLine
.
The purpose of clipLine
is:
/* Clip line with screen boundaries, returns 0 if whole line is out of bounds /
And the line is never completely out of bounds, so clipLine
is doing its job properly.
This is however a bug with drawLine
.
drawLine
is attempting to draw pixels offscreen, which it shouldn't be.
The solution to this is to limit the end point somehow.
Checking before drawing a pixel would be the easiest solution, but I think that might be a bit slow. So the other solution is to force the limit before entering the loop.
I'm not very good at Bresenham's algorithm so it'll probably take me some time to figure out the best way to handle it, but I'll have a look.
Disregard my earlier comment.
I have proof positive that the problem is with clipLine
.
I didn't look properly at what clipLine
was trying to do.
Nice catch. Was biting me from a long time.
Nice catch. Was biting me from a long time.
@Effer For future reference, the PR would have closed this issue automatically when it's merged because I wrote 'Fixes #' and then the issue number.
It seems there are some problems in the Display::clipLine method. This happen on low res mode but it's more evident in Hi-res mode.
Here some test code for convenience