From 874509d5dff6fbd63e29625b7ccb57a2c8a822e1 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 1 Aug 2019 17:28:02 +1000 Subject: [PATCH] Fix egl backend not behaving properly after resize --- src/Graphics.c | 9 ++++----- src/Window.c | 15 ++++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Graphics.c b/src/Graphics.c index 4a4de7113..5635d527b 100644 --- a/src/Graphics.c +++ b/src/Graphics.c @@ -994,13 +994,12 @@ static FUNC_GLBUFFERDATA _glBufferData; static FUNC_GLBUFFERSUBDATA _glBufferSubData; #endif -#define GL_TEXTURE_MAX_LEVEL 0x813D -#ifndef CC_BUILD_WEB -#define PIXEL_FORMAT 0x80E1 /* GL_BGRA_EXT */ -#else +#if defined CC_BUILD_WEB || defined CC_BUILD_ANDROID #define PIXEL_FORMAT GL_RGBA +#else +#define PIXEL_FORMAT 0x80E1 /* GL_BGRA_EXT */ #endif -static int gl_compare[8] = { GL_ALWAYS, GL_NOTEQUAL, GL_NEVER, GL_LESS, GL_LEQUAL, GL_EQUAL, GL_GEQUAL, GL_GREATER }; +#define GL_TEXTURE_MAX_LEVEL 0x813D typedef void (*GL_SetupVBFunc)(void); typedef void (*GL_SetupVBRangeFunc)(int startVertex); diff --git a/src/Window.c b/src/Window.c index e1a1a4513..0426c7920 100644 --- a/src/Window.c +++ b/src/Window.c @@ -2880,8 +2880,6 @@ static void JNICALL java_processSurfaceDestroyed(JNIEnv* env, jobject o) { if (win_handle) ANativeWindow_release(win_handle); win_handle = NULL; - Window_Focused = false; - Event_RaiseVoid(&WindowEvents.FocusChanged); /* TODO: Do we Window_Close() here */ /* TODO: Gfx Lose context */ JavaCallVoid(env, "processedSurfaceDestroyed", "()V", NULL); @@ -3567,6 +3565,12 @@ static void GLContext_InitSurface(void) { eglMakeCurrent(ctx_display, ctx_surface, ctx_surface, ctx_context); } +static void GLContext_FreeSurface(void) { + eglMakeCurrent(ctx_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglDestroySurface(ctx_display, ctx_surface); + ctx_surface = NULL; +} + void GLContext_Init(struct GraphicsMode* mode) { static EGLint contextAttribs[3] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; static EGLint attribs[19] = { @@ -3593,9 +3597,7 @@ void GLContext_Init(struct GraphicsMode* mode) { } void GLContext_Update(void) { - eglMakeCurrent(ctx_display, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx_context); - eglDestroySurface(ctx_display, ctx_surface); - ctx_surface = NULL; + GLContext_FreeSurface(); GLContext_InitSurface(); } @@ -3605,9 +3607,8 @@ bool GLContext_TryRestore(void) { } void GLContext_Free(void) { - eglMakeCurrent(ctx_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + GLContext_FreeSurface(); eglDestroyContext(ctx_display, ctx_context); - eglDestroySurface(ctx_display, ctx_surface); eglTerminate(ctx_display); }