| Summary: | SDL_RenderDrawLine gives different results on different render backends | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Nicolae Berendea <berendeanicolae> |
| Component: | render | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESPONDED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | trivial | ||
| Priority: | P2 | CC: | ant, berendeanicolae, bjornsundin02, ngolbaz, william.quartz, xyzdragon |
| Version: | HG 2.0 | Keywords: | target-2.0.16 |
| Hardware: | All | ||
| OS: | All | ||
| Attachments: |
test.cpp
failed test picture GLES lines slightly off |
||
|
Description
Nicolae Berendea
2014-09-01 16:23:27 UTC
What does this code do? It seems unnecessary.
from D3D_RenderDrawLines:
/* DirectX 9 has the same line rasterization semantics as GDI,
so we need to close the endpoint of the line */
if (count == 2 ||
points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
vertices[0].x = points[count-1].x;
vertices[0].y = points[count-1].y;
result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices));
}
Something similar is used to draw circles by the sdl_gfx library. So when I use aacircleRGBA (function that draws a blended circle), it has points with different color on its circumference. This bug still exists, please fix it. So, I looked into the implementation of SDL_RenderDrawLine. As Nader said, it draws the line from point a to b and then it draws another point at the end of the line (point b). On both of my machines, the line is complete without drawing the last point - so the last point will be drawn twice thus changing color when using alpha channel. On a virtual machine, the line is incomplete (it is missing point b) so it is necessary to draw an additional point as in the code. Is it possible to differentiate between machines so the lines are drawn correctly in both environments? The vm is running windows7x64. One of my machines has windows7x64; the other one windows10x64. Nicolae, I don't know if the fix in Bug #3182 will fix this too, but please test with the latest in revision control when you get a moment and let me know. --ryan. Created attachment 4203 [details]
test.cpp
Created attachment 4204 [details]
failed test picture
I've tested again. Indeed the fix doesn't work for this issue. The issue is in the direct3d renderers. There is a point added at the end of the line. https://hg.libsdl.org/SDL/file/3d991f099f58/src/render/direct3d/SDL_render_d3d.c#l1367 https://hg.libsdl.org/SDL/file/3d991f099f58/src/render/direct3d11/SDL_render_d3d11.c#l2274 Sometimes that point is necessary (e.g. in my vm the line is drawn fine) but not always depending on the hardware (I think). Ryan, I think your fix needs to be extended to the D3D renderers as well. *** Bug 4976 has been marked as a duplicate of this bug. *** *** Bug 3182 has been marked as a duplicate of this bug. *** I've backed out the recent OpenGL fix with this commit: https://hg.libsdl.org/SDL/rev/4ba421b1e88f ...and changed this bug to target-2.0.14. Once 2.0.12 ships, we'll re-merge this patch, decide what every renderer backend _should_ do, and work on making them all work identically. --ryan. Created attachment 4485 [details]
GLES lines slightly off
Ryan, I've just tested the latest GLES line merge on my Windows 10 Intel HD Graphics system and the lines are slightly off. Software renderer is perfect. DX3D is OKish (it draws the last pixel twice - been that way for a while now), GL is perfect, but GLES the lines are off, being drawn 1 pixel too far forward, or too far back. Attached picture demonstrates a box being drawn using SDL_RenderDrawLinesF starting top-left and moving clockwise.
Also tested on Android and the same happens with GLES lines. OpenGL and GLES lines now behave as expected (Tested on Windows & Android), thanks Ryan - I bet you'll be glad to see the back of this topic, lol. All that remains is what the OP posted: DX3D drawing the last pixel twice - it only affects the last line in an array of lines. It's not a deal breaker for me personally, but I can see how it can cause problems for some. (In reply to Anthony @ POW Games from comment #15) > All that remains is what the OP posted: DX3D drawing the last pixel twice - > it only affects the last line in an array of lines. It's not a deal breaker > for me personally, but I can see how it can cause problems for some. Weird, I thought this was fixed, too. I'll check that again. --ryan. |