From c43ba5edd76705e8581841fe1e9a0546b0119675 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 12 Dec 2009 20:31:28 +0000 Subject: [PATCH] Fixed line drawing for D3D --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404299 --- src/video/win32/SDL_d3drender.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/video/win32/SDL_d3drender.c b/src/video/win32/SDL_d3drender.c index a82f93cae..90baf9bd3 100644 --- a/src/video/win32/SDL_d3drender.c +++ b/src/video/win32/SDL_d3drender.c @@ -1012,8 +1012,17 @@ D3D_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count) vertices[i].v = 0.0f; } result = - IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count, + IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count-1, vertices, sizeof(*vertices)); + + /* DirectX 9 has the same line rasterization semantics as GDI, + so we need to close the endpoint of the line */ + if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) { + vertices[0].x = (float) points[count-1].x; + vertices[0].y = (float) points[count-1].y; + result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices)); + } + SDL_stack_free(vertices); if (FAILED(result)) { D3D_SetError("DrawPrimitiveUP()", result);