+ RenderSurfaceInterface* currentSurface = nullptr;
+
+ GraphicsInterface& graphics = mAdaptorInterfaces.GetGraphicsInterface();
+ EglGraphics* eglGraphics = static_cast<EglGraphics *>(&graphics);
+
+ // This will only be created once
+ EglInterface* eglInterface = &eglGraphics->GetEglInterface();
+
+ Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( *eglInterface );
+
+ // Try to use OpenGL es 3.0
+ // ChooseConfig returns false here when the device only support gles 2.0.
+ // Because eglChooseConfig with gles 3.0 setting fails when the device only support gles 2.0 and Our default setting is gles 3.0.
+ if( !eglImpl.ChooseConfig( true, COLOR_DEPTH_32 ) )
+ {
+ // Retry to use OpenGL es 2.0
+ eglGraphics->SetGlesVersion( 20 );
+ eglImpl.ChooseConfig( true, COLOR_DEPTH_32 );
+ }
+
+ // Check whether surfaceless context is supported
+ bool isSurfacelessContextSupported = eglImpl.IsSurfacelessContextSupported();
+ eglGraphics->SetIsSurfacelessContextSupported( isSurfacelessContextSupported );
+
+ if ( isSurfacelessContextSupported )
+ {
+ // Create a surfaceless OpenGL context for shared resources
+ eglImpl.CreateContext();
+ eglImpl.MakeContextCurrent( EGL_NO_SURFACE, eglImpl.GetContext() );
+ }
+ else
+ {
+ currentSurface = mAdaptorInterfaces.GetRenderSurfaceInterface();
+ if( currentSurface )
+ {
+ currentSurface->InitializeGraphics();
+ currentSurface->MakeContextCurrent();
+ }
+ }
+
+ eglGraphics->GetGlesInterface().ContextCreated();
+
+ // Tell core it has a context