Save and restore SDL renderer state after transforming triangles to rect
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
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 53e694c..123c3a7 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -3427,6 +3427,12 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer,
const int debug = 0;
int prev[3]; /* Previous triangle vertex indices */
int texw = 0, texh = 0;
+ SDL_BlendMode blendMode;
+ Uint8 r, g, b, a;
+
+ /* Save */
+ SDL_GetRenderDrawBlendMode(renderer, &blendMode);
+ SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a);
if (texture) {
SDL_QueryTexture(texture, NULL, NULL, &texw, &texh);
@@ -3646,7 +3652,7 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer,
xy, xy_stride, color, color_stride, uv, uv_stride,
num_vertices, prev, 3, 4, renderer->scale.x, renderer->scale.y);
if (retval < 0) {
- return retval;
+ goto end;
} else {
FlushRenderCommandsIfNotBatching(renderer);
}
@@ -3667,12 +3673,17 @@ SDL_SW_RenderGeometryRaw(SDL_Renderer *renderer,
xy, xy_stride, color, color_stride, uv, uv_stride,
num_vertices, prev, 3, 4, renderer->scale.x, renderer->scale.y);
if (retval < 0) {
- return retval;
+ goto end;
} else {
FlushRenderCommandsIfNotBatching(renderer);
}
}
+end:
+ /* Restore */
+ SDL_SetRenderDrawBlendMode(renderer, blendMode);
+ SDL_SetRenderDrawColor(renderer, r, g, b, a);
+
return retval;
}