1 /* Copyright © 2013, Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 #define GL_GLEXT_PROTOTYPES
31 void glenv_query (void);
33 typedef GLubyte * (get_string_type_t) (GLenum);
38 printf ("--vendor=\"%s\"\n", glGetString (GL_VENDOR));
39 printf ("--renderer=\"%s\"\n", glGetString (GL_RENDERER));
40 printf ("--version=\"%s\"\n", glGetString (GL_VERSION));
41 printf ("--shading-language-version=\"%s\"\n", glGetString (GL_SHADING_LANGUAGE_VERSION));
42 printf ("--extensions=\"%s\"\n", glGetString (GL_EXTENSIONS));
48 glenv_num_extensions (void)
55 glenv_major_version (void)
57 const char *version = getenv ("GLENV_GL_VERSION");
61 return atoi (version);
65 glenv_minor_version (void)
67 const char *version = getenv ("GLENV_GL_VERSION");
73 decimal = strchr (version, '.');
78 return atoi (decimal + 1);
82 glGetDoublev (GLenum pname, GLdouble *params)
85 case GL_NUM_EXTENSIONS:
86 *params = glenv_num_extensions();
88 case GL_MAJOR_VERSION:
89 if (getenv ("GLENV_GL_VERSION")) {
90 *params = glenv_major_version();
94 case GL_MINOR_VERSION:
95 if (getenv ("GLENV_GL_VERSION")) {
96 *params = glenv_minor_version();
102 GLAZE_DEFER (glGetDoublev, pname, params);
106 glGetFloatv (GLenum pname, GLfloat *params)
109 case GL_NUM_EXTENSIONS:
110 *params = glenv_num_extensions();
112 case GL_MAJOR_VERSION:
113 if (getenv ("GLENV_GL_VERSION")) {
114 *params = glenv_major_version();
118 case GL_MINOR_VERSION:
119 if (getenv ("GLENV_GL_VERSION")) {
120 *params = glenv_minor_version();
126 GLAZE_DEFER (glGetFloatv, pname, params);
130 glGetIntegerv (GLenum pname, GLint *params)
133 case GL_NUM_EXTENSIONS:
134 *params = glenv_num_extensions();
136 case GL_MAJOR_VERSION:
137 if (getenv ("GLENV_GL_VERSION")) {
138 *params = glenv_major_version();
142 case GL_MINOR_VERSION:
143 if (getenv ("GLENV_GL_VERSION")) {
144 *params = glenv_minor_version();
150 GLAZE_DEFER (glGetIntegerv, pname, params);
154 glGetInteger64v (GLenum pname, GLint64 * params)
157 case GL_NUM_EXTENSIONS:
158 *params = glenv_num_extensions();
160 case GL_MAJOR_VERSION:
161 if (getenv ("GLENV_GL_VERSION")) {
162 *params = glenv_major_version();
166 case GL_MINOR_VERSION:
167 if (getenv ("GLENV_GL_VERSION")) {
168 *params = glenv_minor_version();
174 GLAZE_DEFER (glGetInteger64v, pname, params);
178 glGetString (GLenum name)
184 ret = (GLubyte *) getenv ("GLENV_GL_VENDOR");
189 ret = (GLubyte *) getenv ("GLENV_GL_RENDERER");
194 ret = (GLubyte *) getenv ("GLENV_GL_VERSION");
198 case GL_SHADING_LANGUAGE_VERSION:
199 ret = (GLubyte *) getenv ("GLENV_GL_SHADING_LANGUAGE_VERSION");
204 ret = (GLubyte *) getenv ("GLENV_GL_EXTENSIONS");
210 GLAZE_DEFER_WITH_RETURN (ret, glGetString, name);
216 glGetStringi (GLenum name, GLuint index)
224 case GL_SHADING_LANGUAGE_VERSION:
226 ret = (GLubyte *) getenv ("GLENV_GL_SHADING_LANGUAGE_VERSION");
233 GLAZE_DEFER_WITH_RETURN (ret, glGetStringi, name, index);