[Mesa-dev] [PATCH 1/4] mesa: Add a Version field to the context with VersionMajor*10+VersionMinor.
Jordan Justen
jljusten at gmail.com
Thu Jul 26 17:54:41 PDT 2012
On Thu, Jul 26, 2012 at 5:27 PM, Eric Anholt <eric at anholt.net> wrote:
> 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".
> ---
> src/mesa/main/mtypes.h | 2 ++
> src/mesa/main/version.c | 6 ++++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 3d59dc6..23d32a6 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -3427,6 +3427,8 @@ struct gl_context
>
> /** Version info */
> GLuint VersionMajor, VersionMinor;
> + /** VersionMajor * 10 + VersionMinor, so 31 for GL 3.1. */
> + GLuint Version;
> char *VersionString;
>
> /** \name State attribute stack (for glPush/PopAttrib) */
> diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
> index efaaf58..697758e 100644
> --- a/src/mesa/main/version.c
> +++ b/src/mesa/main/version.c
> @@ -223,6 +223,8 @@ compute_version(struct gl_context *ctx)
>
> override_version(ctx, &ctx->VersionMajor, &ctx->VersionMinor);
>
> + ctx->Version = ctx->VersionMajor * 10 + ctx->VersionMinor;
How about a macro rather than coding the *10 everywhere?
#define UINT_VERSION(major, minor) ((10*(major)) + (minor))
> +
> ctx->VersionString = (char *) malloc(max);
> if (ctx->VersionString) {
> _mesa_snprintf(ctx->VersionString, max,
> @@ -257,6 +259,8 @@ compute_version_es1(struct gl_context *ctx)
> _mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support.");
> }
>
> + ctx->Version = ctx->VersionMajor * 10 + ctx->VersionMinor;
> +
> ctx->VersionString = (char *) malloc(max);
> if (ctx->VersionString) {
> _mesa_snprintf(ctx->VersionString, max,
> @@ -291,6 +295,8 @@ compute_version_es2(struct gl_context *ctx)
> _mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support.");
> }
>
> + ctx->Version = ctx->VersionMajor * 10 + ctx->VersionMinor;
> +
> ctx->VersionString = (char *) malloc(max);
> if (ctx->VersionString) {
> _mesa_snprintf(ctx->VersionString, max,
> --
> 1.7.10.4
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list