From 18a8f9f6839dfd899814a76a971e720c1e622236 Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 28 Sep 2011 15:18:21 +0200 Subject: mesa pixman xkeyboard-config git update 28 sep 2011 --- mesalib/src/mesa/main/version.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'mesalib/src/mesa/main/version.c') diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c index 384281479..a5deeabd2 100644 --- a/mesalib/src/mesa/main/version.c +++ b/mesalib/src/mesa/main/version.c @@ -27,7 +27,29 @@ #include "version.h" #include "git_sha1.h" +/** + * Override the context's GL version if the environment variable + * MESA_GL_VERSION_OVERRIDE is set. Valid values of MESA_GL_VERSION_OVERRIDE + * are point-separated version numbers, such as "3.0". + */ +static void +override_version(struct gl_context *ctx, GLuint *major, GLuint *minor) +{ + const char *env_var = "MESA_GL_VERSION_OVERRIDE"; + const char *version; + int n; + + version = getenv(env_var); + if (!version) { + return; + } + n = sscanf(version, "%d.%d", major, minor); + if (n != 2) { + fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version); + return; + } +} /** * Examine enabled GL extensions to determine GL version. @@ -178,6 +200,9 @@ compute_version(struct gl_context *ctx) ctx->VersionMajor = major; ctx->VersionMinor = minor; + + override_version(ctx, &ctx->VersionMajor, &ctx->VersionMinor); + ctx->VersionString = (char *) malloc(max); if (ctx->VersionString) { _mesa_snprintf(ctx->VersionString, max, -- cgit v1.2.3