Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android app switch front and back EGL is broken #1537

Closed
luorentong opened this issue Apr 14, 2020 · 4 comments
Closed

Android app switch front and back EGL is broken #1537

luorentong opened this issue Apr 14, 2020 · 4 comments

Comments

@luorentong
Copy link

Hi Pavel Rojtberg:
Using glSurfaceView on Android to switch between the front and background causes a black screen to appear because glSurfaceView will recreate the Surface by slicing back to the Ogre body from the background. My solution suggests fixing this problem by resetting the Surface on Ogre with Java onSurfaceChanged.

@Override
public void onSurfaceChanged(GL10 gl, int width, int height) 
{

	if (JNI != null) 
	{
	    lastSurface = mGlSurfaceView.getHolder().getSurface();
	    if (lastSurface.isValid()) 
	    {
		JNI.changeSurface(lastSurface);
	    }
	}
}

my.cpp
void changeSurface(ANativeWindow *window) 
{
   mRenderWindow->_changeSurface(window);
}

OgreRenderWindow.h
virtual void _changeSurface(void* nativeWindow) = 0;

OgreAndroidEGLWindow.h
void _changeSurface(void* window);

OgreAndroidEGLWindow.cpp
void AndroidEGLWindow::_changeSurface(void* window)
{
	mWindow = reinterpret_cast<EGLNativeWindowType>(window);
	mContext->changeCurrent();
}

OgreEGLContext.h
void changeCurrent();

void EGLContext::changeCurrent()
{
   mContext = eglGetCurrentContext();
   EGL_CHECK_ERROR
}
@paroj
Copy link
Member

paroj commented Apr 14, 2020

does calling _notifySurfaceDestroyed & _notifySurfaceCreated also work?

@luorentong
Copy link
Author

miscParams ["externalGLControl"] = "true" ,I tested that using _notifySurfaceCreated() would cause problems because createSurfaceFromWindow(), using the eglCreateWindowSurface method.

@paroj
Copy link
Member

paroj commented Apr 16, 2020

there is the mIsExternal flag, which you can use to call eglGetCurrentSurface instead of createSurfaceFromWindow

@paroj
Copy link
Member

paroj commented Apr 29, 2021

fixed in latest 1.12

@paroj paroj closed this as completed Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants