Improve EGL restore

This commit is contained in:
mittorn 2016-05-07 20:14:09 +00:00
parent 69b11fcf38
commit 2c8b1ee753

View file

@ -165,8 +165,8 @@ public class XashActivity extends Activity {
mSurface.SwapBuffers();
}
public static void restoreEGL() {
mSurface.restoreEGL();
public static void toggleEGL(int toggle) {
mSurface.toggleEGL(toggle);
}
public static void setActivityTitle(String title) {
@ -334,19 +334,6 @@ View.OnKeyListener {
if( mEGL == null )
return;
XashActivity.nativeSetPause(0);
//mEGL = (EGL10)EGLContext.getEGL();
//mEGL.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null);
//mEGL.eglWaitGL();
//mEGL.eglDestroyContext(mEGLDisplay, mEGLContext);
int EGL_CONTEXT_CLIENT_VERSION=0x3098;
int contextAttrs[] = new int[]
{
EGL_CONTEXT_CLIENT_VERSION, 1,
EGL10.EGL_NONE
};
//mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL10.EGL_NO_CONTEXT, contextAttrs);
}
// Called when we lose the surface
@ -354,13 +341,6 @@ View.OnKeyListener {
if( mEGL == null )
return;
XashActivity.nativeSetPause(1);
//mEGL = (EGL10)EGLContext.getEGL();
// mEGL.eglWaitNative(EGL10.EGL_CORE_NATIVE_ENGINE, null);
//mEGL.eglWaitGL();
mEGL.eglMakeCurrent(mEGLDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
mEGL.eglDestroySurface(mEGLDisplay, mEGLSurface);
// mEGLSurface = null;
}
// Called when the surface is resized
@ -530,6 +510,8 @@ View.OnKeyListener {
// EGL buffer flip
public void SwapBuffers() {
if( mEGLSurface == null )
return;
try {
//EGL10 egl = (EGL10)EGLContext.getEGL();
@ -547,11 +529,20 @@ View.OnKeyListener {
}
}
}
public void restoreEGL()
public void toggleEGL(int toggle)
{
if( toggle != 0 )
{
mEGLSurface = mEGL.eglCreateWindowSurface(mEGLDisplay, mEGLConfig, this, null);
mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);
}
else
{
mEGL.eglMakeCurrent(mEGLDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
mEGL.eglDestroySurface(mEGLDisplay, mEGLSurface);
mEGLSurface = null;
}
}
// Key events
public boolean onKey(View v, int keyCode, KeyEvent event) {