Resize renderer after [re]init

Fixes crash on Android when app is brought back to the foreground
Issue #228
This commit is contained in:
Flyinghead 2021-04-22 10:59:40 +02:00
parent 5f665fb82a
commit 805dac3039
6 changed files with 17 additions and 11 deletions

View File

@ -46,6 +46,7 @@ bool dc_is_load_done();
void dc_cancel_load(); void dc_cancel_load();
void dc_get_load_status(); void dc_get_load_status();
bool dc_is_running(); bool dc_is_running();
void dc_resize_renderer();
enum class Event { enum class Event {
Start, Start,

View File

@ -735,10 +735,8 @@ void SaveSettings()
#endif #endif
} }
void dc_resume() void dc_resize_renderer()
{ {
SetMemoryHandlers();
settings.aica.NoBatch = config::ForceWindowsCE || config::DSPEnabled;
int hres; int hres;
int vres = config::RenderResolution; int vres = config::RenderResolution;
if (config::Widescreen && !config::Rotate90) if (config::Widescreen && !config::Rotate90)
@ -759,6 +757,13 @@ void dc_resume()
} }
if (renderer != nullptr) if (renderer != nullptr)
renderer->Resize(hres, vres); renderer->Resize(hres, vres);
}
void dc_resume()
{
SetMemoryHandlers();
settings.aica.NoBatch = config::ForceWindowsCE || config::DSPEnabled;
dc_resize_renderer();
EventManager::event(Event::Resume); EventManager::event(Event::Resume);
if (!emu_thread.thread.joinable()) if (!emu_thread.thread.joinable())

View File

@ -712,15 +712,11 @@ static bool RenderFrame(int width, int height)
//setup render target first //setup render target first
if (is_rtt) if (is_rtt)
{
output_fbo = BindRTT(false); output_fbo = BindRTT(false);
if (output_fbo == 0)
return false;
}
else else
{
output_fbo = init_output_framebuffer(rendering_width, rendering_height); output_fbo = init_output_framebuffer(rendering_width, rendering_height);
} if (output_fbo == 0)
return false;
glcache.Disable(GL_SCISSOR_TEST); glcache.Disable(GL_SCISSOR_TEST);

View File

@ -1099,7 +1099,8 @@ bool RenderFrame(int width, int height)
} }
else else
{ {
init_output_framebuffer(width, height); if (init_output_framebuffer(width, height) == 0)
return false;
} }
bool wide_screen_on = !is_rtt && config::Widescreen && !matrices.IsClipped() && !config::Rotate90; bool wide_screen_on = !is_rtt && config::Widescreen && !matrices.IsClipped() && !config::Rotate90;

View File

@ -523,7 +523,8 @@ GLuint init_output_framebuffer(int width, int height)
// Check that our FBO creation was successful // Check that our FBO creation was successful
GLuint uStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); GLuint uStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
verify(uStatus == GL_FRAMEBUFFER_COMPLETE); if (uStatus != GL_FRAMEBUFFER_COMPLETE)
return 0;
glcache.Disable(GL_SCISSOR_TEST); glcache.Disable(GL_SCISSOR_TEST);
glcache.ClearColor(0.f, 0.f, 0.f, 0.f); glcache.ClearColor(0.f, 0.f, 0.f, 0.f);

View File

@ -24,6 +24,7 @@
#include "oslib/oslib.h" #include "oslib/oslib.h"
#include "wsi/context.h" #include "wsi/context.h"
#include "cfg/option.h" #include "cfg/option.h"
#include "emulator.h"
bool mainui_enabled; bool mainui_enabled;
u32 MainFrameCount; u32 MainFrameCount;
@ -59,6 +60,7 @@ bool mainui_rend_frame()
void mainui_init() void mainui_init()
{ {
rend_init_renderer(); rend_init_renderer();
dc_resize_renderer();
} }
void mainui_term() void mainui_term()