summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/version.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-07-26 14:43:56 -0700
committerEric Anholt <[email protected]>2012-08-07 11:47:19 -0700
commit9c1b41879aab2ff7386c547a2ccce7686c018cf5 (patch)
tree934b03d503f257d3979d6ebe9ad36cee2953bb25 /src/mesa/main/version.c
parent3aaeb3e5e76b7b468e2eb2a26f30d68d19d3c854 (diff)
mesa: Replace VersionMajor/VersionMinor with a Version field.
As we get into supporting GL 3.x core, we come across more and more features of the API that depend on the version number as opposed to just the extension list. This will let us more sanely do version checks than "(VersionMajor == 3 && VersionMinor >= 2) || VersionMajor >= 4". v2: Fix a bad <= 30 check. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/main/version.c')
-rw-r--r--src/mesa/main/version.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 85e623142d4..59c81aedc72 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -33,22 +33,25 @@
* are point-separated version numbers, such as "3.0".
*/
static void
-override_version(struct gl_context *ctx, GLuint *major, GLuint *minor)
+override_version(struct gl_context *ctx)
{
const char *env_var = "MESA_GL_VERSION_OVERRIDE";
const char *version;
int n;
+ int major, minor;
version = getenv(env_var);
if (!version) {
return;
}
- n = sscanf(version, "%u.%u", major, minor);
+ n = sscanf(version, "%u.%u", &major, &minor);
if (n != 2) {
fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version);
return;
}
+
+ ctx->Version = major * 10 + minor;
}
/**
@@ -218,10 +221,9 @@ compute_version(struct gl_context *ctx)
minor = 2;
}
- ctx->VersionMajor = major;
- ctx->VersionMinor = minor;
+ ctx->Version = major * 10 + minor;
- override_version(ctx, &ctx->VersionMajor, &ctx->VersionMinor);
+ override_version(ctx);
ctx->VersionString = (char *) malloc(max);
if (ctx->VersionString) {
@@ -231,7 +233,7 @@ compute_version(struct gl_context *ctx)
" (" MESA_GIT_SHA1 ")"
#endif
,
- ctx->VersionMajor, ctx->VersionMinor);
+ ctx->Version / 10, ctx->Version % 10);
}
}
@@ -248,11 +250,9 @@ compute_version_es1(struct gl_context *ctx)
ctx->Extensions.EXT_point_parameters);
if (ver_1_1) {
- ctx->VersionMajor = 1;
- ctx->VersionMinor = 1;
+ ctx->Version = 11;
} else if (ver_1_0) {
- ctx->VersionMajor = 1;
- ctx->VersionMinor = 0;
+ ctx->Version = 10;
} else {
_mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support.");
}
@@ -265,7 +265,7 @@ compute_version_es1(struct gl_context *ctx)
" (" MESA_GIT_SHA1 ")"
#endif
,
- ctx->VersionMinor);
+ ctx->Version % 10);
}
}
@@ -285,8 +285,7 @@ compute_version_es2(struct gl_context *ctx)
ctx->Extensions.ARB_texture_non_power_of_two &&
ctx->Extensions.EXT_blend_equation_separate);
if (ver_2_0) {
- ctx->VersionMajor = 2;
- ctx->VersionMinor = 0;
+ ctx->Version = 20;
} else {
_mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support.");
}
@@ -303,14 +302,14 @@ compute_version_es2(struct gl_context *ctx)
}
/**
- * Set the context's VersionMajor, VersionMinor, VersionString fields.
+ * Set the context's Version and VersionString fields.
* This should only be called once as part of context initialization
* or to perform version check for GLX_ARB_create_context_profile.
*/
void
_mesa_compute_version(struct gl_context *ctx)
{
- if (ctx->VersionMajor)
+ if (ctx->Version)
return;
switch (ctx->API) {