From fc0f5f888953012ed77d5f680b8eae25d95f412b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 20 Nov 2015 13:36:16 +0100 Subject: [PATCH] Create egl_create_surface --- gfx/common/egl_common.c | 13 +++++++++++++ gfx/common/egl_common.h | 2 ++ gfx/drivers_context/drm_egl_ctx.c | 8 +------- gfx/drivers_context/vc_egl_ctx.c | 7 +------ 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index bd4a7253ba..087115ecfd 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -228,3 +228,16 @@ bool egl_create_context(EGLint *egl_attribs) return true; } + +bool egl_create_surface(NativeWindowType native_window) +{ + g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, native_window, NULL); + if (!g_egl_surf) + return false; + + /* Connect the context to the surface. */ + if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) + return false; + + return true; +} diff --git a/gfx/common/egl_common.h b/gfx/common/egl_common.h index 9c792e6170..8f0437b7a3 100644 --- a/gfx/common/egl_common.h +++ b/gfx/common/egl_common.h @@ -59,4 +59,6 @@ bool egl_init_context(NativeDisplayType display, bool egl_create_context(EGLint *egl_attribs); +bool egl_create_surface(NativeWindowType native_window); + #endif diff --git a/gfx/drivers_context/drm_egl_ctx.c b/gfx/drivers_context/drm_egl_ctx.c index 2d05fdef7a..886db978a0 100644 --- a/gfx/drivers_context/drm_egl_ctx.c +++ b/gfx/drivers_context/drm_egl_ctx.c @@ -737,13 +737,7 @@ static bool gfx_ctx_drm_egl_set_video_mode(void *data, goto error; } - g_egl_surf = eglCreateWindowSurface(g_egl_dpy, - g_egl_config, (EGLNativeWindowType)drm->g_gbm_surface, NULL); - if (!g_egl_surf) - goto error; - - if (!eglMakeCurrent(g_egl_dpy, - g_egl_surf, g_egl_surf, g_egl_ctx)) + if (!egl_create_surface((EGLNativeWindowType)drm->g_gbm_surface)) goto error; glClear(GL_COLOR_BUFFER_BIT); diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 820fc32c57..3a243e9b88 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -259,12 +259,7 @@ static bool gfx_ctx_vc_init(void *data) } vc_dispmanx_update_submit_sync(dispman_update); - g_egl_surf = eglCreateWindowSurface(g_egl_dpy, g_egl_config, &nativewindow, NULL); - if (!g_egl_surf) - goto error; - - /* Connect the context to the surface. */ - if (!eglMakeCurrent(g_egl_dpy, g_egl_surf, g_egl_surf, g_egl_ctx)) + if (!egl_create_surface(&nativewindow)) goto error; return true;