2 * Mesa 3-D graphics library
4 * Copyright (C) 2010 VMware, Inc. All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * Override the context's GL version if the environment variable
30 * MESA_GL_VERSION_OVERRIDE is set. Valid values of MESA_GL_VERSION_OVERRIDE
31 * are point-separated version numbers, such as "3.0".
34 override_version(struct gl_context
*ctx
, GLuint
*major
, GLuint
*minor
)
36 const char *env_var
= "MESA_GL_VERSION_OVERRIDE";
40 version
= getenv(env_var
);
45 n
= sscanf(version
, "%u.%u", major
, minor
);
47 fprintf(stderr
, "error: invalid value for %s: %s\n", env_var
, version
);
53 * Examine enabled GL extensions to determine GL version.
54 * Return major and minor version numbers.
57 compute_version(struct gl_context
*ctx
)
59 /* report openGL 1.1 */
60 ctx
->VersionMajor
= 1;
61 ctx
->VersionMinor
= 1;
63 override_version(ctx
, &ctx
->VersionMajor
, &ctx
->VersionMinor
);
65 ctx
->VersionString
= (char *) malloc(20);
66 if (ctx
->VersionString
) {
67 _mesa_snprintf(ctx
->VersionString
, 20,
68 "%u.%u Mesa " MESA_VERSION_STRING
70 " (" MESA_GIT_SHA1
")"
73 ctx
->VersionMajor
, ctx
->VersionMinor
);
78 * Set the context's VersionMajor, VersionMinor, VersionString fields.
79 * This should only be called once as part of context initialization
80 * or to perform version check for GLX_ARB_create_context_profile.
83 _mesa_compute_version(struct gl_context
*ctx
)
85 if (ctx
->VersionMajor
)