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"
This commit is contained in:
Robert Bragg 2011-04-18 16:24:51 +01:00
parent dc7383b714
commit 31ee65784d
4 changed files with 12 additions and 0 deletions

View File

@ -28,6 +28,9 @@
#include "config.h"
#endif
#include <stdlib.h>
#include <string.h>
#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');

View File

@ -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,

View File

@ -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,

View File

@ -54,6 +54,8 @@ typedef enum
typedef struct _CoglWinsysVtable
{
const char *name;
CoglFuncPtr
(*get_proc_address) (const char *name);