Skip to content

Commit

Permalink
replace _glContextAvailable
Browse files Browse the repository at this point in the history
  • Loading branch information
nkast committed May 16, 2024
1 parent b24e1da commit 09c6ba0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
14 changes: 5 additions & 9 deletions MonoGame.Framework/Platform/Android/AndroidSurfaceView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ enum AppState
bool _androidSurfaceAvailable = false;

bool _glSurfaceAvailable;
bool _glContextAvailable;
bool _lostglContext;

DateTime _prevTickTime;
Expand Down Expand Up @@ -190,7 +189,7 @@ void Java.Lang.IRunnable.Run()
_glSurfaceAvailable = false;
}

if (_glContextAvailable)
if (_eglContext != null)
{
if (_eglContext != null)
DestroyGLContext();
Expand All @@ -199,7 +198,6 @@ void Java.Lang.IRunnable.Run()
DestroyGLDisplay();
_eglDisplay = null;

_glContextAvailable = false;

if (_game.GraphicsDevice != null)
{
Expand Down Expand Up @@ -257,7 +255,7 @@ void processStateResuming()
if (_androidSurfaceAvailable)
{
// create surface if context is available
if (_glContextAvailable && !_lostglContext)
if (_eglContext != null && !_lostglContext)
{
try
{
Expand All @@ -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;
Expand All @@ -288,7 +286,6 @@ void processStateResuming()
DestroyGLDisplay();
_eglDisplay = null;

_glContextAvailable = false;
contextLost = true;

if (_game.GraphicsDevice != null)
Expand All @@ -301,7 +298,6 @@ void processStateResuming()
OGL_DROID.Initialize();

CreateGLContext();
_glContextAvailable = true;

if (!_glSurfaceAvailable)
CreateGLSurface();
Expand All @@ -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.
Expand All @@ -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)
{
Expand Down
11 changes: 4 additions & 7 deletions MonoGame.Framework/Platform/Cardboard/AndroidSurfaceView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ enum AppState
bool _androidSurfaceAvailable = false;

bool _glSurfaceAvailable;
bool _glContextAvailable;
bool _lostglContext;

DateTime _prevTickTime;
Expand Down Expand Up @@ -207,7 +206,7 @@ void processStateResuming()
if (_androidSurfaceAvailable)
{
// create surface if context is available
if (_glContextAvailable && !_lostglContext)
if (_eglContext != null && !_lostglContext)
{
try
{
Expand All @@ -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;
Expand All @@ -238,7 +237,6 @@ void processStateResuming()
DestroyGLDisplay();
_eglDisplay = null;

_glContextAvailable = false;
contextLost = true;

if (_game.GraphicsDevice != null)
Expand All @@ -251,7 +249,6 @@ void processStateResuming()
OGL_DROID.Initialize();

//CreateGLContext();
_glContextAvailable = true;

if (!_glSurfaceAvailable)
CreateGLSurface();
Expand All @@ -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.
Expand All @@ -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)
{
Expand Down

0 comments on commit 09c6ba0

Please sign in to comment.