diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index b4d2053712..fa9b9d08e8 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -255,3 +255,16 @@ bool egl_create_surface(NativeWindowType native_window) return true; } + +bool egl_get_native_visual_id(EGLint *value) +{ + if (!eglGetConfigAttrib(g_egl_dpy, g_egl_config, + EGL_NATIVE_VISUAL_ID, value)) + { + RARCH_ERR("[EGL]: egl_get_native_visual_id failed.\n"); + return false; + } + + return true; +} + diff --git a/gfx/common/egl_common.h b/gfx/common/egl_common.h index 81bbde23cc..b0b85fbb10 100644 --- a/gfx/common/egl_common.h +++ b/gfx/common/egl_common.h @@ -64,6 +64,8 @@ bool egl_create_context(EGLint *egl_attribs); bool egl_create_surface(NativeWindowType native_window); +bool egl_get_native_visual_id(EGLint *value); + #ifdef __cplusplus } #endif diff --git a/gfx/drivers_context/androidegl_ctx.c b/gfx/drivers_context/androidegl_ctx.c index 37283d9870..fee40a4a72 100644 --- a/gfx/drivers_context/androidegl_ctx.c +++ b/gfx/drivers_context/androidegl_ctx.c @@ -34,7 +34,6 @@ static bool g_es3; static bool android_gfx_ctx_init(void *data) { - int var; EGLint n, major, minor; EGLint format; EGLint context_attributes[] = { @@ -64,14 +63,8 @@ static bool android_gfx_ctx_init(void *data) goto error; } - var = eglGetConfigAttrib(g_egl_dpy, g_egl_config, - EGL_NATIVE_VISUAL_ID, &format); - - if (!var) - { - RARCH_ERR("eglGetConfigAttrib failed: %d.\n", var); + if (!egl_get_native_visual_id(&format)) goto error; - } ANativeWindow_setBuffersGeometry(android_app->window, 0, 0, format); diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 50528f77ff..6e48239102 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -253,7 +253,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, attr = egl_attribs; attr = xegl_fill_attribs(attr); - if (!eglGetConfigAttrib(g_egl_dpy, g_egl_config, EGL_NATIVE_VISUAL_ID, &vid)) + if (!egl_get_native_visual_id(&vid)) goto error; temp.visualid = vid;