Fix Android black screen when paused #974
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When switching away from TIC-80, the OpenGL context is destroyed by the
system and needs to be recreated along with all resources (textures and
shaders).
SDL2 makes an attempt to save and restore the active GL context when
pausing and resuming the activity, but it fails on my device, and the
Android and SDL2 documentation indicate that it's a best-effort feature.
Because the keyboard and gamepad images are lost when the textures are
destroyed, backing buffers are allocated to store them when they are
first filled out.
Additionally, SDL_gpu needs to be fully destroyed and recreated to
resolve the problem on my Pixel 3a XL. Just recreating the textures and
shader and calling GPU_ResetRenderState is not enough.
(Ideally, this entire problem is something that would be handled by
the SDL_gpu library, but it has no provisions for it)