I have had this problem with D3D and OpenGL for years (probably for different reasons!). This happens no matter how I draw it. There is another problem not shown in the gif below, which is the a single pixel of a rectangle not being drawn.
Everything is drawn using triangles in the gif below, the same problem occurs if using lines to draw a rect. I am not sure what code is relevant to this issue, whether is it the shader, viewport, projection matrix, or something else.
The start position of each object is aligned at 0.5 or 0.0, but each line call may not. While I've read that D3D11 fixes this half pixel problem, it seems something is off by half a pixel or should be offset by half a pixel.
Here is my code to draw a line:
void line(float x1, float y1, float x2, float y2) {
float line_width = 0.5f;
auto a = Vector2{ x2 - x1, y2 - y1 }.perp().normalize() * line_width;
put(x1 - a.x, y1 - a.y);
put(x2 - a.x, y2 - a.y);
put(x2 + a.x, y2 + a.y);
put(x1 + a.x, y1 + a.y);
put(x1 - a.x, y1 - a.y);
put(x2 + a.x, y2 + a.y);
}
