diff --git a/ios/RetroArch/RAGameView.m b/ios/RetroArch/RAGameView.m index 2f1c680543..4343e78f94 100644 --- a/ios/RetroArch/RAGameView.m +++ b/ios/RetroArch/RAGameView.m @@ -105,6 +105,18 @@ static UIView* g_pause_indicator_view; ]; } +- (void)suspend +{ + g_view.context = nil; + [EAGLContext setCurrentContext:nil]; +} + +- (void)resume +{ + g_view.context = g_context; + [EAGLContext setCurrentContext:g_context]; +} + @end bool ios_init_game_view() @@ -169,7 +181,8 @@ void ios_get_game_view_size(unsigned *width, unsigned *height) void ios_bind_game_view_fbo() { dispatch_sync(dispatch_get_main_queue(), ^{ - [g_view bindDrawable]; + if (g_context) + [g_view display]; }); } diff --git a/ios/RetroArch/RetroArch_iOS.m b/ios/RetroArch/RetroArch_iOS.m index d784dcdd09..68dda336b2 100644 --- a/ios/RetroArch/RetroArch_iOS.m +++ b/ios/RetroArch/RetroArch_iOS.m @@ -52,16 +52,6 @@ static void event_set_state_slot(void* userdata) g_extern.state_slot = (uint32_t)userdata; } -static void event_init_drivers(void* userdata) -{ - init_drivers(); -} - -static void event_uninit_drivers(void* userdata) -{ - uninit_drivers(); -} - static void event_reload_config(void* userdata) { // Need to clear these otherwise stale versions may be used! @@ -114,14 +104,12 @@ static void event_reload_config(void* userdata) - (void)applicationWillEnterForeground:(UIApplication *)application { - if (_isRunning) - ios_frontend_post_event(&event_init_drivers, 0); + [RAGameView.get resume]; } - (void)applicationDidEnterBackground:(UIApplication *)application { - if (_isRunning) - ios_frontend_post_event(&event_uninit_drivers, 0); + [RAGameView.get suspend]; } // UINavigationControllerDelegate diff --git a/ios/RetroArch/views.h b/ios/RetroArch/views.h index cc619d5c6b..13a819eaf8 100644 --- a/ios/RetroArch/views.h +++ b/ios/RetroArch/views.h @@ -22,6 +22,9 @@ + (RAGameView*)get; - (void)openPauseMenu; - (void)closePauseMenu; + +- (void)suspend; +- (void)resume; @end @interface RALogView : UITableViewController