Fixed line drawing for D3D
authorSam Lantinga <slouken@libsdl.org>
Sat, 12 Dec 2009 20:31:28 +0000
changeset 35514a39f28cd935
parent 3550 6b69c5def097
child 3552 3889325ca987
Fixed line drawing for D3D
src/video/win32/SDL_d3drender.c
     1.1 --- a/src/video/win32/SDL_d3drender.c	Sat Dec 12 20:30:25 2009 +0000
     1.2 +++ b/src/video/win32/SDL_d3drender.c	Sat Dec 12 20:31:28 2009 +0000
     1.3 @@ -1012,8 +1012,17 @@
     1.4          vertices[i].v = 0.0f;
     1.5      }
     1.6      result =
     1.7 -        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count,
     1.8 +        IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count-1,
     1.9                                           vertices, sizeof(*vertices));
    1.10 +
    1.11 +    /* DirectX 9 has the same line rasterization semantics as GDI,
    1.12 +       so we need to close the endpoint of the line */
    1.13 +    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
    1.14 +        vertices[0].x = (float) points[count-1].x;
    1.15 +        vertices[0].y = (float) points[count-1].y;
    1.16 +        result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices));
    1.17 +    }
    1.18 +
    1.19      SDL_stack_free(vertices);
    1.20      if (FAILED(result)) {
    1.21          D3D_SetError("DrawPrimitiveUP()", result);