Try to get default EGL display connection if it fails to get native display connection 56/238156/1
authorRichard Huang <r.huang@samsung.com>
Fri, 26 Jun 2020 10:52:29 +0000 (11:52 +0100)
committerSeungho, Baek <sbsh.baek@samsung.com>
Thu, 9 Jul 2020 04:12:37 +0000 (13:12 +0900)
Change-Id: I1a633fd2244fdafb793eb761caad1887ebca32ae

dali/internal/graphics/gles/egl-implementation.cpp

index 3710dd1..f8149c4 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -104,12 +104,18 @@ bool EglImplementation::InitializeGles( EGLNativeDisplayType display, bool isOwn
   {
     mEglNativeDisplay = display;
 
-    //@todo see if we can just EGL_DEFAULT_DISPLAY instead
-    mEglDisplay = eglGetDisplay(mEglNativeDisplay);
-    EGLint error = eglGetError();
+    // Try to get the display connection for the native display first
+    mEglDisplay = eglGetDisplay( mEglNativeDisplay );
+
+    if( mEglDisplay == EGL_NO_DISPLAY )
+    {
+      // If failed, try to get the default display connection
+      mEglDisplay = eglGetDisplay( EGL_DEFAULT_DISPLAY );
+    }
 
-    if( mEglDisplay == NULL && error != EGL_SUCCESS )
+    if( mEglDisplay == EGL_NO_DISPLAY )
     {
+      // Still failed to get a display connection
       throw Dali::DaliException( "", "OpenGL ES is not supported");
     }