summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineOpenGL
diff options
context:
space:
mode:
authorEgor <egor.yusov@gmail.com>2018-02-11 18:58:51 +0000
committerEgor <egor.yusov@gmail.com>2018-02-11 18:58:51 +0000
commit6d6f17ccfbd439d1eb6247b816c445de91852e98 (patch)
tree5b2ab9e4ccd40db40f224256fb1b46b1f47b41c0 /Graphics/GraphicsEngineOpenGL
parentMinor updates to readme (diff)
downloadDiligentCore-6d6f17ccfbd439d1eb6247b816c445de91852e98.tar.gz
DiligentCore-6d6f17ccfbd439d1eb6247b816c445de91852e98.zip
Fixed Android crash when SwapBuffers() is called after Suspend()
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
-rw-r--r--Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp
index 09ed4f9f..0dce35d3 100644
--- a/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp
+++ b/Graphics/GraphicsEngineOpenGL/src/GLContextAndroid.cpp
@@ -281,13 +281,19 @@ namespace Diligent
void GLContext::SwapBuffers()
{
+ if(surface_ == EGL_NO_SURFACE)
+ {
+ LOG_WARNING_MESSAGE("No EGL surface when swapping buffers. This happens when SwapBuffers() is called after Suspend(). The operation will be ignored.");
+ return;
+ }
+
bool b = eglSwapBuffers( display_, surface_ );
if( !b )
{
EGLint err = eglGetError();
if( err == EGL_BAD_SURFACE )
{
- //Recreate surface
+ LOG_INFO_MESSAGE("EGL surface has been lost. Attempting to recreate");
InitEGLSurface();
//return EGL_SUCCESS; //Still consider glContext is valid
}
@@ -329,13 +335,14 @@ namespace Diligent
EGLint GLContext::Resume( ANativeWindow* window )
{
+ LOG_INFO_MESSAGE( "Resuming gl context\n" );
+
if( egl_context_initialized_ == false )
{
Init( window );
return EGL_SUCCESS;
}
-
//Create surface
window_ = window;
surface_ = eglCreateWindowSurface( display_, config_, window_, NULL );
@@ -365,19 +372,21 @@ namespace Diligent
else
{
//Recreate surface
+ LOG_INFO_MESSAGE( "Re-creating egl context and surface\n" );
Terminate();
InitEGLSurface();
InitEGLContext();
}
return err;
-
}
void GLContext::Suspend()
{
+ LOG_INFO_MESSAGE( "Suspending gl context\n" );
if( surface_ != EGL_NO_SURFACE )
{
+ LOG_INFO_MESSAGE( "Destroying egl surface\n" );
eglDestroySurface( display_, surface_ );
surface_ = EGL_NO_SURFACE;
}
@@ -385,6 +394,7 @@ namespace Diligent
bool GLContext::Invalidate()
{
+ LOG_INFO_MESSAGE( "Invalidating gl context\n" );
Terminate();
egl_context_initialized_ = false;