Skip to content

Commit

Permalink
move InitExtensions after EglMakeCurrent (#1589)
Browse files Browse the repository at this point in the history
* update comments

* InitExtensions after EglMakeCurrent
  • Loading branch information
nkast authored May 21, 2024
1 parent f25510d commit 28462ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
8 changes: 4 additions & 4 deletions MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ void ProcessStateResumed()
if (!GL.Egl.EglMakeCurrent(adapter.EglDisplay, _eglSurface, _eglSurface, _eglContext))
throw new Exception("Could not make EGL current" + GL.GetEglErrorAsString());

// OGL.InitExtensions() must be called while we have a current gl context.
if (OGL_DROID.Current.Extensions == null)
OGL_DROID.Current.InitExtensions();

GraphicsDeviceManager gdm = ((IPlatformGame)_game).GetStrategy<ConcreteGame>().GraphicsDeviceManager;
if (gdm != null)
{
Expand All @@ -291,10 +295,6 @@ void ProcessStateResumed()
}
}

// OGL.InitExtensions() must be called while we have a gl context.
if (OGL_DROID.Current.Extensions == null)
OGL_DROID.Current.InitExtensions();

if (_isGLContextLost)
{
// we lost the gl context, we need to let the programmer
Expand Down
19 changes: 10 additions & 9 deletions MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,15 @@ void ProcessStateResumed()
throw new Exception("Could not create EGL window surface" + GL.GetEglErrorAsString());
*/

/* Cardboard: Surface was created by GLSurfaceView.
/* Cardboard: Context was created by GLSurfaceView.
if (!GL.Egl.EglMakeCurrent(adapter.EglDisplay, _eglSurface, _eglSurface, _eglContext))
throw new Exception("Could not make EGL current" + GL.GetEglErrorAsString());
*/

// OGL.InitExtensions() must be called while we have a current gl context.
if (OGL_DROID.Current.Extensions == null)
OGL_DROID.Current.InitExtensions();

GraphicsDeviceManager gdm = ((IPlatformGame)_game).GetStrategy<ConcreteGame>().GraphicsDeviceManager;
if (gdm != null)
{
Expand All @@ -240,10 +244,6 @@ void ProcessStateResumed()
}
}

// OGL.InitExtensions() must be called while we have a gl context.
if (OGL_DROID.Current.Extensions == null)
OGL_DROID.Current.InitExtensions();

if (_isGLContextLost)
{
// we lost the gl context, we need to let the programmer
Expand All @@ -262,7 +262,7 @@ void ProcessStateResumed()
throw new Exception("Could not create EGL window surface" + GL.GetEglErrorAsString());
*/

/* Cardboard: Surface was created by GLSurfaceView.
/* Cardboard: Context was created by GLSurfaceView.
if (!GL.Egl.EglMakeCurrent(adapter.EglDisplay, _eglSurface, _eglSurface, _eglContext))
throw new Exception("Could not make EGL current" + GL.GetEglErrorAsString());
*/
Expand Down Expand Up @@ -503,10 +503,11 @@ void IRenderer.OnDrawFrame(VRCardboard.HeadTransform headTransform, VRCardboard.
_eglContext = GL.Egl.EglGetCurrentContext();
if (_eglContext == EGL10.EglNoContext)
_eglContext = null;
}

if (OGL_DROID.Current.Extensions == null)
OGL_DROID.Current.InitExtensions();
// OGL.InitExtensions() must be called while we have a current gl context.
if (OGL_DROID.Current.Extensions == null)
OGL_DROID.Current.InitExtensions();
}

if (!_isStarted)
return;
Expand Down

0 comments on commit 28462ff

Please sign in to comment.