Commit d62ce9d
ogc, renderer: workaround missing pixels in linestrips
In addition to drawing the last point, we must draw all the other ones,
too.
The reason is that GX rendering of lines is a bit different than how SDL
applications expect it, and there isn't a straightforward way to correct
it in a way that is good for all cases.
The problem is that GX draws a line (let's assume it's a horizontal one)
between coordinates A and B like this:
┌────────────────────────────────────────────────────────┐
A B
└────────────────────────────────────────────────────────┘
That is, the line is made as wide as needed, but the line caps are in
"butt" style (using the HTML terminology), that is the line lenght is
not increased by half width around the points A and B (which is what SDL
seems to be doing on both the software and OpenGL renderer backends on
the desktop).
As a result, when drawing a linestrip as a rectangle with vertices A, B,
C and D, the drawing that GX sets up is this:
┌────────────────────────────────────┐
┌─A─┐ 1 ┌─B─┐
│ ├────────────────────────────────┤ │
│ 4 │ │ 2 │
│ │ │ │
│ ├────────────────────────────────┴─┐ │
└─D─┘ 3 C─┘
└────────────────────────────────────┘
If (like is the case with SDL) lines are only one pixel wide, the corner
pixels will not be drawn if the positioning of the vertex is such that
the GX engine decides the pixel is not covered enough. In practice, as
can be tested with the sdl-subpixel program[1], it very often happens
that at least one corner of the rectangle is not drawn.
Since points are always drawn as a square around the given coordinates,
adding squares at line vertices helps fixing this issue.
[1]: https://github.com/mardy/sdl-subpixel1 parent 0edb424 commit d62ce9d
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
585 | 585 | | |
586 | 586 | | |
587 | 587 | | |
588 | | - | |
589 | | - | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
590 | 592 | | |
591 | 593 | | |
592 | 594 | | |
| |||
0 commit comments