Hi,
I've noticed that in several areas, DirectX seems to get basic math wrong by one pixel, and I'd like to be reassured that this is some sort of design decision or something. For example, if I have a simple right triangle with transformed vertices defined as such:
int x = 0;int y = 0;
int width = 10;
int height = 10;
verts[0].X = x;
verts[0].Y = y;
verts[0].Z = 0;
verts[0].Rhw = 1.0f;
verts[1].X = x + width - 1;
verts[1].Y = y;
verts[1].Z = 0;
verts[1].Rhw = 1.0f;
verts[2].X = x;
verts[2].Y = y + height - 1;
verts[2].Z = 0;
verts[2].Rhw = 1.0f;
I would expect a right triangle to be drawn that is 10 pixels wide and 10 pixels tall. The furthest right vertex (verts[1]) has an x position of x + width - 1 (0 + 10 - 1 = 9), and the furthest left has an x position of 0. So, pixels 0,1,2,3,4,5,6,7,8, and 9 makes 10 pixels.
But instead, a triangle renders that is only 9 pixels wide and 9 pixels tall. Why does this not render the way the programmer would expect
Thanks,Mike Vargas

Dealing with DirectX's infamous off-by-one X,Y and width/height issue
TenTwenty
This is correct behaviour actually.
Consider two triangles with a common edge.
one is (0,0)-(9,0)-(0,9) and the other is (9,0)-(9,9)-(0,9), the common edge is (9,0)-(0,9)
Now which triangle should draw the pixel at (9,0) and (0,9) as well as the other pixels along the edge Acording to the way you think now, both should draw.
When scan line converting, you generally decide to not draw the right most pixel on a scanline if the line ends on an exact pixel position. That is a scanline from 0 to 9 will draw 0,1,2,3,4,5,6,7,8 and a scan line from 9 to 15 will draw 9,10,11,12,13,14
A scanline from 1.2 to 4.9 will draw 2,3,4
It is all a matter of avoiding adjacent faces to overlap along the lines. You need to be able to tell exactly which face draws the pixel along the edge. If not then you will have a result dependant of rendering order, and you might end up with flickering edges.
dreamworks