From 09c6ba034bcb4475206afc0fe38295e69ebab824 Mon Sep 17 00:00:00 2001 From: Nikos Kastellanos Date: Thu, 16 May 2024 11:08:13 +0300 Subject: [PATCH] replace _glContextAvailable --- .../Platform/Android/AndroidSurfaceView.cs | 14 +++++--------- .../Platform/Cardboard/AndroidSurfaceView.cs | 11 ++++------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs b/MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs index bea56db85f9..44cdb942599 100644 --- a/MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs +++ b/MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs @@ -48,7 +48,6 @@ enum AppState bool _androidSurfaceAvailable = false; bool _glSurfaceAvailable; - bool _glContextAvailable; bool _lostglContext; DateTime _prevTickTime; @@ -190,7 +189,7 @@ void Java.Lang.IRunnable.Run() _glSurfaceAvailable = false; } - if (_glContextAvailable) + if (_eglContext != null) { if (_eglContext != null) DestroyGLContext(); @@ -199,7 +198,6 @@ void Java.Lang.IRunnable.Run() DestroyGLDisplay(); _eglDisplay = null; - _glContextAvailable = false; if (_game.GraphicsDevice != null) { @@ -257,7 +255,7 @@ void processStateResuming() if (_androidSurfaceAvailable) { // create surface if context is available - if (_glContextAvailable && !_lostglContext) + if (_eglContext != null && !_lostglContext) { try { @@ -272,7 +270,7 @@ void processStateResuming() } // create context if not available - if (!_glContextAvailable || _lostglContext) + if (_eglContext == null || _lostglContext) { // Start or Restart due to context loss bool contextLost = false; @@ -288,7 +286,6 @@ void processStateResuming() DestroyGLDisplay(); _eglDisplay = null; - _glContextAvailable = false; contextLost = true; if (_game.GraphicsDevice != null) @@ -301,7 +298,6 @@ void processStateResuming() OGL_DROID.Initialize(); CreateGLContext(); - _glContextAvailable = true; if (!_glSurfaceAvailable) CreateGLSurface(); @@ -310,7 +306,7 @@ void processStateResuming() if (OGL_DROID.Current.Extensions == null) OGL_DROID.Current.InitExtensions(); - if (_glContextAvailable && contextLost) + if (_eglContext != null && contextLost) { // we lost the gl context, we need to let the programmer // know so they can re-create textures etc. @@ -337,7 +333,7 @@ void processStateResuming() void ForceSurfaceRecreation() { // needed at app start - if (_glContextAvailable && _androidSurfaceAvailable) + if (_eglContext != null && _androidSurfaceAvailable) { if (_eglSurface != null && _eglSurface != EGL10.EglNoSurface) { diff --git a/MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs b/MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs index 1cd8b9b8578..1e9daa034c0 100644 --- a/MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs +++ b/MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs @@ -47,7 +47,6 @@ enum AppState bool _androidSurfaceAvailable = false; bool _glSurfaceAvailable; - bool _glContextAvailable; bool _lostglContext; DateTime _prevTickTime; @@ -207,7 +206,7 @@ void processStateResuming() if (_androidSurfaceAvailable) { // create surface if context is available - if (_glContextAvailable && !_lostglContext) + if (_eglContext != null && !_lostglContext) { try { @@ -222,7 +221,7 @@ void processStateResuming() } // create context if not available - if (!_glContextAvailable || _lostglContext) + if (_eglContext == null || _lostglContext) { // Start or Restart due to context loss bool contextLost = false; @@ -238,7 +237,6 @@ void processStateResuming() DestroyGLDisplay(); _eglDisplay = null; - _glContextAvailable = false; contextLost = true; if (_game.GraphicsDevice != null) @@ -251,7 +249,6 @@ void processStateResuming() OGL_DROID.Initialize(); //CreateGLContext(); - _glContextAvailable = true; if (!_glSurfaceAvailable) CreateGLSurface(); @@ -260,7 +257,7 @@ void processStateResuming() if (OGL_DROID.Current.Extensions == null) OGL_DROID.Current.InitExtensions(); - if (_glContextAvailable && contextLost) + if (_eglContext != null && contextLost) { // we lost the gl context, we need to let the programmer // know so they can re-create textures etc. @@ -287,7 +284,7 @@ void processStateResuming() void ForceSurfaceRecreation() { // needed at app start - if (_glContextAvailable && _androidSurfaceAvailable) + if (_eglContext != null && _androidSurfaceAvailable) { if (_eglSurface != null && _eglSurface != EGL10.EglNoSurface) {