aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/version.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-10-01 09:36:37 +0200
committermarha <marha@users.sourceforge.net>2012-10-01 09:36:37 +0200
commit7ed9dbafdbc724c1030404f29678559134de559b (patch)
treec19a8d332c4485b2b84a35ba5dd7b1767b4099b0 /mesalib/src/mesa/main/version.c
parent2cf1e3de4759264eac2fa8ac758ea750636542f8 (diff)
downloadvcxsrv-7ed9dbafdbc724c1030404f29678559134de559b.tar.gz
vcxsrv-7ed9dbafdbc724c1030404f29678559134de559b.tar.bz2
vcxsrv-7ed9dbafdbc724c1030404f29678559134de559b.zip
libxcb mesa pixman xkeyboard-config git update 1 oct 2012
libxcb: 23911a707b8845bff52cd7853fc5d59fb0823cef mesa: c321b1bef15e2807de3f6225c4abcbf48969997a pixman: 183afcf1d95625a1f237ef349a1c8931d94d000d xkeyboard-config: 159e8db2a3829a11801d06cc6cad6d1378551dd5
Diffstat (limited to 'mesalib/src/mesa/main/version.c')
-rw-r--r--mesalib/src/mesa/main/version.c88
1 files changed, 66 insertions, 22 deletions
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index 55638a807..5778792a6 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -28,30 +28,25 @@
#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".
+ * Scans 'string' to see if it ends with 'ending'.
*/
-static void
-override_version(struct gl_context *ctx)
+static GLboolean
+check_for_ending(const char *string, const char *ending)
{
- const char *env_var = "MESA_GL_VERSION_OVERRIDE";
- const char *version;
- int n;
- int major, minor;
+ int len1, len2;
- version = getenv(env_var);
- if (!version) {
- return;
- }
+ len1 = strlen(string);
+ len2 = strlen(ending);
- n = sscanf(version, "%u.%u", &major, &minor);
- if (n != 2) {
- fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version);
- return;
+ if (len2 > len1) {
+ return GL_FALSE;
}
- ctx->Version = major * 10 + minor;
+ if (strcmp(string + (len1 - len2), ending) == 0) {
+ return GL_TRUE;
+ } else {
+ return GL_FALSE;
+ }
}
/**
@@ -65,13 +60,64 @@ create_version_string(struct gl_context *ctx, const char *prefix)
ctx->VersionString = malloc(max);
if (ctx->VersionString) {
_mesa_snprintf(ctx->VersionString, max,
- "%s%u.%u Mesa " MESA_VERSION_STRING
+ "%s%u.%u%s Mesa " MESA_VERSION_STRING
#ifdef MESA_GIT_SHA1
" (" MESA_GIT_SHA1 ")"
#endif
,
prefix,
- ctx->Version / 10, ctx->Version % 10);
+ ctx->Version / 10, ctx->Version % 10,
+ (ctx->API == API_OPENGL_CORE) ? " (Core Profile)" : ""
+ );
+ }
+}
+
+/**
+ * Override the context's version and/or API type if the
+ * environment variable MESA_GL_VERSION_OVERRIDE is set.
+ *
+ * Example uses of MESA_GL_VERSION_OVERRIDE:
+ *
+ * 2.1: select a compatibility (non-Core) profile with GL version 2.1
+ * 3.0: select a compatibility (non-Core) profile with GL version 3.0
+ * 3.0FC: select a Core+Forward Compatible profile with GL version 3.0
+ * 3.1: select a Core profile with GL version 3.1
+ * 3.1FC: select a Core+Forward Compatible profile with GL version 3.1
+ */
+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;
+
+ version = getenv(env_var);
+ if (!version) {
+ return;
+ }
+
+ 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);
+ } 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;
+ }
+ create_version_string(ctx, "");
+ }
}
}
@@ -242,8 +288,6 @@ compute_version(struct gl_context *ctx)
ctx->Version = major * 10 + minor;
- override_version(ctx);
-
create_version_string(ctx, "");
}