Re-enable line drawing path in render drivers

This is still used for scaled line drawing in RenderDrawLinesWithRects()
This commit is contained in:
Sam Lantinga 2022-01-08 09:02:25 -08:00
parent dca281e810
commit 18e4d9fed1
7 changed files with 301 additions and 12 deletions

View file

@ -1207,8 +1207,30 @@ D3D_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
break;
}
case SDL_RENDERCMD_DRAW_LINES: /* unused */
case SDL_RENDERCMD_DRAW_LINES: {
const size_t count = cmd->data.draw.count;
const size_t first = cmd->data.draw.first;
const Vertex *verts = (Vertex *) (((Uint8 *) vertices) + first);
/* DirectX 9 has the same line rasterization semantics as GDI,
so we need to close the endpoint of the line with a second draw call. */
const SDL_bool close_endpoint = ((count == 2) || (verts[0].x != verts[count-1].x) || (verts[0].y != verts[count-1].y));
SetDrawState(data, cmd);
if (vbo) {
IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_LINESTRIP, (UINT) (first / sizeof (Vertex)), (UINT) (count - 1));
if (close_endpoint) {
IDirect3DDevice9_DrawPrimitive(data->device, D3DPT_POINTLIST, (UINT) ((first / sizeof (Vertex)) + (count - 1)), 1);
}
} else {
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, (UINT) (count - 1), verts, sizeof (Vertex));
if (close_endpoint) {
IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, &verts[count-1], sizeof (Vertex));
}
}
break;
}
case SDL_RENDERCMD_FILL_RECTS: /* unused */
break;
@ -1545,6 +1567,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
renderer->QueueSetViewport = D3D_QueueSetViewport;
renderer->QueueSetDrawColor = D3D_QueueSetViewport; /* SetViewport and SetDrawColor are (currently) no-ops. */
renderer->QueueDrawPoints = D3D_QueueDrawPoints;
renderer->QueueDrawLines = D3D_QueueDrawPoints; /* lines and points queue vertices the same way. */
renderer->QueueGeometry = D3D_QueueGeometry;
renderer->RunCommandQueue = D3D_RunCommandQueue;
renderer->RenderReadPixels = D3D_RenderReadPixels;