Use RenderGeometry for drawing lines at all scales
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 0119c6c..1819f1f 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -2904,13 +2904,13 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer,
}
#endif
- use_rendergeometry = (renderer->QueueDrawLines == NULL);
+ use_rendergeometry = 1;
- if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
- retval = RenderDrawLinesWithRectsF(renderer, points, count);
- } else if (use_rendergeometry) {
+ if (use_rendergeometry) {
SDL_bool isstack1;
SDL_bool isstack2;
+ const float scale_x = renderer->scale.x;
+ const float scale_y = renderer->scale.y;
float *xy = SDL_small_alloc(float, 4 * 2 * count, &isstack1);
int *indices = SDL_small_alloc(int,
(4) * 3 * (count - 1)
@@ -2939,14 +2939,17 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer,
for (i = 0; i < count; ++i) {
SDL_FPoint q = points[i]; /* current point */
+ q.x *= scale_x;
+ q.y *= scale_y;
+
*ptr_xy++ = q.x;
*ptr_xy++ = q.y;
- *ptr_xy++ = q.x + 1.0f;
+ *ptr_xy++ = q.x + scale_x;
*ptr_xy++ = q.y;
- *ptr_xy++ = q.x + 1.0f;
- *ptr_xy++ = q.y + 1.0f;
+ *ptr_xy++ = q.x + scale_x;
+ *ptr_xy++ = q.y + scale_y;
*ptr_xy++ = q.x;
- *ptr_xy++ = q.y + 1.0f;
+ *ptr_xy++ = q.y + scale_y;
#define ADD_TRIANGLE(i1, i2, i3) \
*ptr_indices++ = cur_indice + i1; \
@@ -3025,6 +3028,8 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer,
SDL_small_free(indices, isstack2);
}
+ } else if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) {
+ retval = RenderDrawLinesWithRectsF(renderer, points, count);
} else {
retval = QueueCmdDrawLines(renderer, points, count);
}