aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/version.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-03-04 08:18:40 +0100
committermarha <marha@users.sourceforge.net>2013-03-04 08:18:40 +0100
commitd4d629b77742e60caac3d120ff40e9f386380af2 (patch)
treeed3eacb0fdcf29da0a24e03c4330ce8e3bb66718 /mesalib/src/mesa/main/version.c
parentc74ef795c7282681616decc36a9a81cd1b1b6ec7 (diff)
downloadvcxsrv-d4d629b77742e60caac3d120ff40e9f386380af2.tar.gz
vcxsrv-d4d629b77742e60caac3d120ff40e9f386380af2.tar.bz2
vcxsrv-d4d629b77742e60caac3d120ff40e9f386380af2.zip
fontconfig libX11 mesalib pixman xserver xkeyboard-config git update 4 Mar 2013
xserver commit 8f4640bdb9d3988148e09a08d2c7e3bab1d538d6 xkeyboard-config commit fa2f330df22511c3846cb1cb0760551c6e244a81 libX11 commit c23d61d1b84dca3740bf4786978c7908d0065fb9 pixman commit 5feda20fc39407879993ed4a6d861ef7f78d9432 fontconfig commit 612ee2a5c91b8929b2cc5abce4af84d8d7e66bd0 mesa commit e29124717eae4f8d329bb6a9707b802c0ff4bdd9
Diffstat (limited to 'mesalib/src/mesa/main/version.c')
-rw-r--r--mesalib/src/mesa/main/version.c94
1 files changed, 67 insertions, 27 deletions
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index e944a5518..c90318981 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -50,6 +50,45 @@ check_for_ending(const char *string, const char *ending)
}
/**
+ * Returns the gl override data
+ *
+ * version > 0 indicates there is an override requested
+ * fwd_context is only valid if version > 0
+ */
+static void
+get_gl_override(int *version, GLboolean *fwd_context)
+{
+ const char *env_var = "MESA_GL_VERSION_OVERRIDE";
+ const char *version_str;
+ int major, minor, n;
+ static int override_version = -1;
+ static GLboolean fc_suffix = GL_FALSE;
+
+ if (override_version < 0) {
+ override_version = 0;
+
+ version_str = getenv(env_var);
+ if (version_str) {
+ fc_suffix = check_for_ending(version_str, "FC");
+
+ n = sscanf(version_str, "%u.%u", &major, &minor);
+ if (n != 2) {
+ fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version_str);
+ override_version = 0;
+ } else {
+ override_version = major * 10 + minor;
+ if (override_version < 30 && fc_suffix) {
+ fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version_str);
+ }
+ }
+ }
+ }
+
+ *version = override_version;
+ *fwd_context = fc_suffix;
+}
+
+/**
* Builds the MESA version string.
*/
static void
@@ -87,41 +126,42 @@ create_version_string(struct gl_context *ctx, const char *prefix)
void
_mesa_override_gl_version(struct gl_context *ctx)
{
- const char *env_var = "MESA_GL_VERSION_OVERRIDE";
- const char *version;
- int n;
- int major, minor;
- GLboolean fc_suffix;
+ int version;
+ GLboolean fwd_context;
- version = getenv(env_var);
- if (!version) {
- return;
- }
+ get_gl_override(&version, &fwd_context);
- fc_suffix = check_for_ending(version, "FC");
-
- n = sscanf(version, "%u.%u", &major, &minor);
- if (n != 2) {
- fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version);
- } else {
- ctx->Version = major * 10 + minor;
- if (ctx->Version < 30 && fc_suffix) {
- fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version);
+ if (version > 0) {
+ ctx->Version = version;
+ if (version >= 30 && fwd_context) {
+ ctx->API = API_OPENGL_CORE;
+ ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
+ } else if (version >= 31) {
+ ctx->API = API_OPENGL_CORE;
} else {
- if (ctx->Version >= 30 && fc_suffix) {
- ctx->API = API_OPENGL_CORE;
- ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
- } else if (ctx->Version >= 31) {
- ctx->API = API_OPENGL_CORE;
- } else {
- ctx->API = API_OPENGL_COMPAT;
- }
- create_version_string(ctx, "");
+ ctx->API = API_OPENGL_COMPAT;
}
+ create_version_string(ctx, "");
}
}
/**
+ * Returns the gl override value
+ *
+ * version > 0 indicates there is an override requested
+ */
+int
+_mesa_get_gl_version_override(void)
+{
+ int version;
+ GLboolean fwd_context;
+
+ get_gl_override(&version, &fwd_context);
+
+ return version;
+}
+
+/**
* Override the context's GLSL version if the environment variable
* MESA_GLSL_VERSION_OVERRIDE is set. Valid values for
* MESA_GLSL_VERSION_OVERRIDE are integers, such as "130".