Fixed 4669 - Using the software SDL_Renderer on Android leads to GL errors & black screen when window resizes Sylvain I think what happening with the software renderer is: * you're somehow in background (so texture creation is not possible) * it resizes and wants to push a SDL_WINDOWEVENT_SIZE_CHANGED It call: https://hg.libsdl.org/SDL/file/a010811d40dd/src/render/SDL_render.c#l683 * GetOutputSize * SW_GetOutputSize * SW_ActivateRenderer * SDL_GetWindowSurface * SDL_CreateWindowFramebuffer which is mapped to SDL_CreateWindowTexture and it ends up re-creating the surface/a texture, while being in background
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
diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c
index 088a0a5..0c191c2 100644
--- a/src/render/software/SDL_render_sw.c
+++ b/src/render/software/SDL_render_sw.c
@@ -82,20 +82,25 @@ SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
static int
SW_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
{
- SDL_Surface *surface = SW_ActivateRenderer(renderer);
+ SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
- if (surface) {
+ if (data->surface) {
if (w) {
- *w = surface->w;
+ *w = data->surface->w;
}
if (h) {
- *h = surface->h;
+ *h = data->surface->h;
}
return 0;
- } else {
- SDL_SetError("Software renderer doesn't have an output surface");
- return -1;
}
+
+ if (renderer->window) {
+ SDL_GetWindowSize(renderer->window, w, h);
+ return 0;
+ }
+
+ SDL_SetError("Software renderer doesn't have an output surface");
+ return -1;
}
static int
@@ -179,7 +184,7 @@ SW_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
{
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
- if (texture ) {
+ if (texture) {
data->surface = (SDL_Surface *) texture->driverdata;
} else {
data->surface = data->window;