From cde0eb3e762d14c6b9f1c1b34bbb525332cbda89 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Wed, 20 Jun 2012 09:47:41 +0200 Subject: [PATCH] Make the default driver selectable at configure time When building COGL with multiple backends it can be useful to force a default driver to be selected. For example while for Debian we do want to build the GL renderer on ARM, GLESv2 is much more suitable as the default renderer on that platform. Reviewed-by: Robert Bragg (cherry picked from commit 8a43aa7167b56784f7b50c557391b990861d594f) --- cogl/Makefile.am | 6 ++++++ cogl/cogl-renderer.c | 5 +++++ configure.ac | 15 ++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cogl/Makefile.am b/cogl/Makefile.am index 31c7f1958..a73d3f854 100644 --- a/cogl/Makefile.am +++ b/cogl/Makefile.am @@ -32,6 +32,12 @@ AM_CPPFLAGS = \ -DCOGL_LOCALEDIR=\""$(localedir)"\" \ $(NULL) +if HAVE_COGL_DEFAULT_DRIVER +AM_CPPFLAGS += \ + -DCOGL_DEFAULT_DRIVER=\"$(COGL_DEFAULT_DRIVER)\" +endif + + AM_CFLAGS = $(COGL_DEP_CFLAGS) $(COGL_EXTRA_CFLAGS) $(MAINTAINER_CFLAGS) BUILT_SOURCES += cogl-defines.h cogl-egl-defines.h cogl-gl-header.h diff --git a/cogl/cogl-renderer.c b/cogl/cogl-renderer.c index 82e45b685..d47e97210 100644 --- a/cogl/cogl-renderer.c +++ b/cogl/cogl-renderer.c @@ -260,6 +260,11 @@ _cogl_renderer_choose_driver (CoglRenderer *renderer, } } +#ifdef COGL_DEFAULT_DRIVER + if (!driver_name) + driver_name = COGL_DEFAULT_DRIVER; +#endif + #ifdef HAVE_COGL_GL if (renderer->driver_override == COGL_DRIVER_GL || (renderer->driver_override == COGL_DRIVER_ANY && diff --git a/configure.ac b/configure.ac index 893cc4652..c262c0d20 100644 --- a/configure.ac +++ b/configure.ac @@ -612,7 +612,7 @@ AM_CONDITIONAL([COGL_DRIVER_GL_SUPPORTED], [test "x$enable_gl" = "xyes"]) AM_CONDITIONAL([COGL_DRIVER_GLES_SUPPORTED], [test "x$enable_gles1" = "xyes" || test "x$enable_gles2" = "xyes"]) -dnl Allow the GL library names to be overridden with configure options +dnl Allow the GL library names and default driver to be overridden with configure options AC_ARG_WITH([gl-libname], [AS_HELP_STRING([--with-gl-libname], override the name of the GL library to dlopen)], @@ -625,6 +625,15 @@ AC_ARG_WITH([gles2-libname], [AS_HELP_STRING([--with-gles2-libname], override the name of the GLESv2 library to dlopen)], [COGL_GLES2_LIBNAME="$withval"]) +AC_ARG_WITH([default-driver], + [AS_HELP_STRING([--with-default-driver], + specify a default cogl driver)], + [COGL_DEFAULT_DRIVER="${withval}"], + [COGL_DEFAULT_DRIVER="" ]) + +AM_CONDITIONAL(HAVE_COGL_DEFAULT_DRIVER, + [ test "x$COGL_DEFAULT_DRIVER" != "x" ]) + AC_SUBST([COGL_GL_LIBNAME]) AC_SUBST([HAVE_GL]) @@ -632,6 +641,7 @@ AC_SUBST([COGL_GLES1_LIBNAME]) AC_SUBST([HAVE_GLES1]) AC_SUBST([COGL_GLES2_LIBNAME]) AC_SUBST([HAVE_GLES2]) +AC_SUBST([COGL_DEFAULT_DRIVER]) if test "x$GL_LIBRARY_DIRECTLY_LINKED" = "xyes"; then AC_DEFINE([HAVE_DIRECTLY_LINKED_GL_LIBRARY], [1], @@ -1234,6 +1244,9 @@ echo "Cogl - $COGL_1_VERSION/$COGL_VERSION (${COGL_RELEASE_STATUS})" echo "" echo " • Global:" echo " Prefix: ${prefix}" +if test "x$COGL_DEFAULT_DRIVER" != "x"; then +echo " Default driver: ${COGL_DEFAULT_DRIVER}" +fi echo "" # Features