SDL: Use correct indices when using RenderGeometry / FillRects (70b10)

From 70b10c753d08fc14afb17d563edd3db4f26b34e6 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Fri, 24 Sep 2021 22:39:49 +0200
Subject: [PATCH] Use correct indices when using RenderGeometry / FillRects

---
 src/render/SDL_render.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index bab938e73a..00cab916b4 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -531,6 +531,7 @@ QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int cou
                 const int num_vertices = 4 * count;
                 const int num_indices = 6 * count;
                 const int size_indices = 4;
+                int cur_indice = 0;
 
                 SDL_GetRenderDrawColor(renderer, &col.r, &col.g, &col.b, &col.a);
                 
@@ -551,12 +552,13 @@ QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int cou
                     *ptr_xy++ = minx;
                     *ptr_xy++ = maxy;
 
-                    *ptr_indices++ = 0;
-                    *ptr_indices++ = 1;
-                    *ptr_indices++ = 2;
-                    *ptr_indices++ = 0;
-                    *ptr_indices++ = 2;
-                    *ptr_indices++ = 3;
+                    *ptr_indices++ = cur_indice + 0;
+                    *ptr_indices++ = cur_indice + 1;
+                    *ptr_indices++ = cur_indice + 2;
+                    *ptr_indices++ = cur_indice + 0;
+                    *ptr_indices++ = cur_indice + 2;
+                    *ptr_indices++ = cur_indice + 3;
+                    cur_indice += 4;
                 }
 
                 retval = renderer->QueueGeometry(renderer, cmd, NULL,