From 31ee65784d2828b538fc2c7f37a6dca985155478 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Mon, 18 Apr 2011 16:24:51 +0100 Subject: [PATCH] winsys: Expose environment variable to choose winsys This makes it possible to override the winsys that cogl uses by setting the COGL_RENDERER environment variable e.g. to "GLX" or "EGL" --- cogl/cogl-renderer.c | 8 ++++++++ cogl/winsys/cogl-winsys-egl.c | 1 + cogl/winsys/cogl-winsys-glx.c | 1 + cogl/winsys/cogl-winsys-private.h | 2 ++ 4 files changed, 12 insertions(+) diff --git a/cogl/cogl-renderer.c b/cogl/cogl-renderer.c index 613b1634d..93e33a49f 100644 --- a/cogl/cogl-renderer.c +++ b/cogl/cogl-renderer.c @@ -28,6 +28,9 @@ #include "config.h" #endif +#include +#include + #include "cogl.h" #include "cogl-internal.h" #include "cogl-object.h" @@ -168,6 +171,7 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error) { #ifdef COGL_HAS_FULL_WINSYS int i; + char *renderer_name = getenv ("COGL_RENDERER"); #endif GString *error_message; @@ -180,6 +184,10 @@ cogl_renderer_connect (CoglRenderer *renderer, GError **error) { const CoglWinsysVtable *winsys = _cogl_winsys_vtable_getters[i](); GError *tmp_error = NULL; + + if (renderer_name && strcmp (winsys->name, renderer_name) != 0) + continue; + if (!winsys->renderer_connect (renderer, &tmp_error)) { g_string_append_c (error_message, '\n'); diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c index 46f5842b3..da39cbdb6 100644 --- a/cogl/winsys/cogl-winsys-egl.c +++ b/cogl/winsys/cogl-winsys-egl.c @@ -1082,6 +1082,7 @@ _cogl_winsys_context_egl_get_egl_display (CoglContext *context) static CoglWinsysVtable _cogl_winsys_vtable = { + .name = "EGL", .get_proc_address = _cogl_winsys_get_proc_address, .renderer_connect = _cogl_winsys_renderer_connect, .renderer_disconnect = _cogl_winsys_renderer_disconnect, diff --git a/cogl/winsys/cogl-winsys-glx.c b/cogl/winsys/cogl-winsys-glx.c index 26ad6e6e7..b15263c78 100644 --- a/cogl/winsys/cogl-winsys-glx.c +++ b/cogl/winsys/cogl-winsys-glx.c @@ -1880,6 +1880,7 @@ _cogl_winsys_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap) static CoglWinsysVtable _cogl_winsys_vtable = { + .name = "GLX", .get_proc_address = _cogl_winsys_get_proc_address, .renderer_connect = _cogl_winsys_renderer_connect, .renderer_disconnect = _cogl_winsys_renderer_disconnect, diff --git a/cogl/winsys/cogl-winsys-private.h b/cogl/winsys/cogl-winsys-private.h index a61084869..856fc8ded 100644 --- a/cogl/winsys/cogl-winsys-private.h +++ b/cogl/winsys/cogl-winsys-private.h @@ -54,6 +54,8 @@ typedef enum typedef struct _CoglWinsysVtable { + const char *name; + CoglFuncPtr (*get_proc_address) (const char *name);