diff --git a/cogl/cogl/cogl-renderer.c b/cogl/cogl/cogl-renderer.c index 199dd175e..d815757a0 100644 --- a/cogl/cogl/cogl-renderer.c +++ b/cogl/cogl/cogl-renderer.c @@ -774,3 +774,11 @@ cogl_renderer_create_dma_buf (CoglRenderer *renderer, return NULL; } + +void +cogl_renderer_bind_api (CoglRenderer *renderer) +{ + const CoglWinsysVtable *winsys = _cogl_renderer_get_winsys (renderer); + + winsys->renderer_bind_api (renderer); +} diff --git a/cogl/cogl/cogl-renderer.h b/cogl/cogl/cogl-renderer.h index b8eb6e545..70910c07b 100644 --- a/cogl/cogl/cogl-renderer.h +++ b/cogl/cogl/cogl-renderer.h @@ -419,6 +419,12 @@ cogl_renderer_create_dma_buf (CoglRenderer *renderer, int height, GError **error); +/** + * cogl_renderer_bind_api: (skip) + */ +COGL_EXPORT void +cogl_renderer_bind_api (CoglRenderer *renderer); + G_END_DECLS #endif /* __COGL_RENDERER_H__ */ diff --git a/cogl/cogl/winsys/cogl-winsys-egl.c b/cogl/cogl/winsys/cogl-winsys-egl.c index 85409433d..8ea1008b5 100644 --- a/cogl/cogl/winsys/cogl-winsys-egl.c +++ b/cogl/cogl/winsys/cogl-winsys-egl.c @@ -134,6 +134,16 @@ _cogl_winsys_renderer_disconnect (CoglRenderer *renderer) g_assert_not_reached (); } +static void +_cogl_winsys_renderer_bind_api (CoglRenderer *renderer) +{ + if (renderer->driver == COGL_DRIVER_GL || + renderer->driver == COGL_DRIVER_GL3) + eglBindAPI (EGL_OPENGL_API); + else if (renderer->driver == COGL_DRIVER_GLES2) + eglBindAPI (EGL_OPENGL_ES_API); +} + /* Updates all the function pointers */ static void check_egl_extensions (CoglRenderer *renderer) @@ -364,11 +374,7 @@ try_create_context (CoglDisplay *display, g_return_val_if_fail (egl_display->egl_context == NULL, TRUE); - if (renderer->driver == COGL_DRIVER_GL || - renderer->driver == COGL_DRIVER_GL3) - eglBindAPI (EGL_OPENGL_API); - else if (renderer->driver == COGL_DRIVER_GLES2) - eglBindAPI (EGL_OPENGL_ES_API); + cogl_renderer_bind_api (renderer); cogl_display_egl_determine_attributes (display, &display->onscreen_template->config, @@ -620,6 +626,7 @@ static CoglWinsysVtable _cogl_winsys_vtable = .renderer_get_proc_address = _cogl_winsys_renderer_get_proc_address, .renderer_connect = _cogl_winsys_renderer_connect, .renderer_disconnect = _cogl_winsys_renderer_disconnect, + .renderer_bind_api = _cogl_winsys_renderer_bind_api, .display_setup = _cogl_winsys_display_setup, .display_destroy = _cogl_winsys_display_destroy, .context_init = _cogl_winsys_context_init, diff --git a/cogl/cogl/winsys/cogl-winsys-glx.c b/cogl/cogl/winsys/cogl-winsys-glx.c index a8453dd48..f3738e07c 100644 --- a/cogl/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/cogl/winsys/cogl-winsys-glx.c @@ -297,6 +297,11 @@ _cogl_winsys_renderer_outputs_changed (CoglRenderer *renderer) update_all_outputs (renderer); } +static void +_cogl_winsys_renderer_bind_api (CoglRenderer *renderer) +{ +} + static gboolean resolve_core_glx_functions (CoglRenderer *renderer, GError **error) @@ -1419,6 +1424,7 @@ static CoglWinsysVtable _cogl_winsys_vtable = .renderer_connect = _cogl_winsys_renderer_connect, .renderer_disconnect = _cogl_winsys_renderer_disconnect, .renderer_outputs_changed = _cogl_winsys_renderer_outputs_changed, + .renderer_bind_api = _cogl_winsys_renderer_bind_api, .display_setup = _cogl_winsys_display_setup, .display_destroy = _cogl_winsys_display_destroy, .context_init = _cogl_winsys_context_init, diff --git a/cogl/cogl/winsys/cogl-winsys-private.h b/cogl/cogl/winsys/cogl-winsys-private.h index 29bea6aa4..b323a704d 100644 --- a/cogl/cogl/winsys/cogl-winsys-private.h +++ b/cogl/cogl/winsys/cogl-winsys-private.h @@ -97,6 +97,9 @@ typedef struct _CoglWinsysVtable int height, GError **error); + void + (*renderer_bind_api) (CoglRenderer *renderer); + gboolean (*context_init) (CoglContext *context, GError **error);