diff --git a/gfx/context/androidegl_ctx.c b/gfx/context/androidegl_ctx.c index d3debc0b2b..d4f0287842 100644 --- a/gfx/context/androidegl_ctx.c +++ b/gfx/context/androidegl_ctx.c @@ -25,6 +25,10 @@ #include +#ifdef HAVE_GLSL +#include "../shader_glsl.h" +#endif + static EGLContext g_egl_ctx; static EGLSurface g_egl_surf; static EGLDisplay g_egl_dpy; @@ -59,6 +63,21 @@ static void gfx_ctx_destroy(void) g_config = 0; } +static void gfx_ctx_get_video_size(unsigned *width, unsigned *height) +{ + (void)width; + (void)height; + + if (g_egl_dpy) + { + EGLint gl_width, gl_height; + eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_WIDTH, &gl_width); + eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_HEIGHT, &gl_height); + *width = gl_width; + *height = gl_height; + } +} + static bool gfx_ctx_init(void) { RARCH_LOG("gfx_ctx_init().\n"); @@ -114,6 +133,32 @@ static bool gfx_ctx_init(void) !eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_HEIGHT, &height)) goto error; + if (g_android.input_state & (1ULL << RARCH_REENTRANT)) + { + RARCH_LOG("[ANDROID/EGL]: Setting up reentrant state.\n"); + + gl_t *gl = (gl_t*)driver.video_data; + + // Get real known video size, which might have been altered by context. + gfx_ctx_get_video_size(&gl->win_width, &gl->win_height); + RARCH_LOG("GL: Using resolution %ux%u\n", gl->win_width, gl->win_height); + + if (gl->full_x || gl->full_y) // We got bogus from gfx_ctx_get_video_size. Replace. + { + gl->full_x = gl->win_width; + gl->full_y = gl->win_height; + } + +#ifdef HAVE_GLSL + gl_glsl_use(0); +#endif + gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); +#ifdef HAVE_GLSL + gl_glsl_use(1); +#endif + gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); + } + return true; error: @@ -175,20 +220,6 @@ static void gfx_ctx_update_window_title(bool reset) RARCH_LOG("%s.\n", buf); } -static void gfx_ctx_get_video_size(unsigned *width, unsigned *height) -{ - (void)width; - (void)height; - - if (g_egl_dpy) - { - EGLint gl_width, gl_height; - eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_WIDTH, &gl_width); - eglQuerySurface(g_egl_dpy, g_egl_surf, EGL_HEIGHT, &gl_height); - *width = gl_width; - *height = gl_height; - } -} static bool gfx_ctx_set_video_mode(