mesa: don't include Mesa version in GL_SHADING_LANGUAGE_VERSION string
[mesa.git] / src / mesa / main / getstring.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 7.1
4 *
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26
27 #include "glheader.h"
28 #include "colormac.h"
29 #include "context.h"
30 #include "get.h"
31 #include "version.h"
32 #include "enums.h"
33 #include "extensions.h"
34
35
36 /**
37 * Query string-valued state. The return value should _not_ be freed by
38 * the caller.
39 *
40 * \param name the state variable to query.
41 *
42 * \sa glGetString().
43 *
44 * Tries to get the string from dd_function_table::GetString, otherwise returns
45 * the hardcoded strings.
46 */
47 const GLubyte * GLAPIENTRY
48 _mesa_GetString( GLenum name )
49 {
50 GET_CURRENT_CONTEXT(ctx);
51 static const char *vendor = "Brian Paul";
52 static const char *renderer = "Mesa";
53 static const char *version_1_2 = "1.2 Mesa " MESA_VERSION_STRING;
54 static const char *version_1_3 = "1.3 Mesa " MESA_VERSION_STRING;
55 static const char *version_1_4 = "1.4 Mesa " MESA_VERSION_STRING;
56 static const char *version_1_5 = "1.5 Mesa " MESA_VERSION_STRING;
57 static const char *version_2_0 = "2.0 Mesa " MESA_VERSION_STRING;
58 static const char *version_2_1 = "2.1 Mesa " MESA_VERSION_STRING;
59
60 #if FEATURE_ARB_shading_language_120_foo /* support not complete! */
61 static const char *sl_version = "1.20";
62 #elif FEATURE_ARB_shading_language_100
63 static const char *sl_version = "1.10";
64 #endif
65
66 if (!ctx)
67 return NULL;
68
69 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
70
71 /* this is a required driver function */
72 assert(ctx->Driver.GetString);
73 {
74 /* Give the driver the chance to handle this query */
75 const GLubyte *str = (*ctx->Driver.GetString)(ctx, name);
76 if (str)
77 return str;
78 }
79
80 switch (name) {
81 case GL_VENDOR:
82 return (const GLubyte *) vendor;
83 case GL_RENDERER:
84 return (const GLubyte *) renderer;
85 case GL_VERSION:
86 /* tests for 1.3: */
87 if (ctx->Extensions.ARB_multisample &&
88 ctx->Extensions.ARB_multitexture &&
89 ctx->Extensions.ARB_texture_border_clamp &&
90 ctx->Extensions.ARB_texture_compression &&
91 ctx->Extensions.ARB_texture_cube_map &&
92 ctx->Extensions.EXT_texture_env_add &&
93 ctx->Extensions.ARB_texture_env_combine &&
94 ctx->Extensions.ARB_texture_env_dot3) {
95 /* tests for 1.4: */
96 if (ctx->Extensions.ARB_depth_texture &&
97 ctx->Extensions.ARB_shadow &&
98 ctx->Extensions.ARB_texture_env_crossbar &&
99 ctx->Extensions.ARB_texture_mirrored_repeat &&
100 ctx->Extensions.ARB_window_pos &&
101 ctx->Extensions.EXT_blend_color &&
102 ctx->Extensions.EXT_blend_func_separate &&
103 ctx->Extensions.EXT_blend_minmax &&
104 ctx->Extensions.EXT_blend_subtract &&
105 ctx->Extensions.EXT_fog_coord &&
106 ctx->Extensions.EXT_multi_draw_arrays &&
107 ctx->Extensions.EXT_point_parameters && /*aka ARB*/
108 ctx->Extensions.EXT_secondary_color &&
109 ctx->Extensions.EXT_stencil_wrap &&
110 ctx->Extensions.EXT_texture_lod_bias &&
111 ctx->Extensions.SGIS_generate_mipmap) {
112 /* tests for 1.5: */
113 if (ctx->Extensions.ARB_occlusion_query &&
114 ctx->Extensions.ARB_vertex_buffer_object &&
115 ctx->Extensions.EXT_shadow_funcs) {
116 /* tests for 2.0: */
117 if (ctx->Extensions.ARB_draw_buffers &&
118 ctx->Extensions.ARB_point_sprite &&
119 ctx->Extensions.ARB_shader_objects &&
120 ctx->Extensions.ARB_vertex_shader &&
121 ctx->Extensions.ARB_fragment_shader &&
122 ctx->Extensions.ARB_texture_non_power_of_two &&
123 ctx->Extensions.EXT_blend_equation_separate) {
124 /* tests for 2.1: */
125 if (ctx->Extensions.ARB_shading_language_120 &&
126 ctx->Extensions.EXT_pixel_buffer_object &&
127 ctx->Extensions.EXT_texture_sRGB) {
128 return (const GLubyte *) version_2_1;
129 }
130 else {
131 return (const GLubyte *) version_2_0;
132 }
133 }
134 else {
135 return (const GLubyte *) version_1_5;
136 }
137 }
138 else {
139 return (const GLubyte *) version_1_4;
140 }
141 }
142 else {
143 return (const GLubyte *) version_1_3;
144 }
145 }
146 else {
147 return (const GLubyte *) version_1_2;
148 }
149 case GL_EXTENSIONS:
150 if (!ctx->Extensions.String)
151 ctx->Extensions.String = _mesa_make_extension_string(ctx);
152 return (const GLubyte *) ctx->Extensions.String;
153 #if FEATURE_ARB_shading_language_100
154 case GL_SHADING_LANGUAGE_VERSION_ARB:
155 if (ctx->Extensions.ARB_shading_language_100)
156 return (const GLubyte *) sl_version;
157 goto error;
158 #endif
159 #if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \
160 FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
161 case GL_PROGRAM_ERROR_STRING_NV:
162 if (ctx->Extensions.NV_fragment_program ||
163 ctx->Extensions.ARB_fragment_program ||
164 ctx->Extensions.NV_vertex_program ||
165 ctx->Extensions.ARB_vertex_program) {
166 return (const GLubyte *) ctx->Program.ErrorString;
167 }
168 /* FALL-THROUGH */
169 #endif
170 #if FEATURE_ARB_shading_language_100
171 error:
172 #endif
173 default:
174 _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" );
175 return (const GLubyte *) 0;
176 }
177 }
178
179
180 /**
181 * Return pointer-valued state, such as a vertex array pointer.
182 *
183 * \param pname names state to be queried
184 * \param params returns the pointer value
185 *
186 * \sa glGetPointerv().
187 *
188 * Tries to get the specified pointer via dd_function_table::GetPointerv,
189 * otherwise gets the specified pointer from the current context.
190 */
191 void GLAPIENTRY
192 _mesa_GetPointerv( GLenum pname, GLvoid **params )
193 {
194 GET_CURRENT_CONTEXT(ctx);
195 const GLuint clientUnit = ctx->Array.ActiveTexture;
196 ASSERT_OUTSIDE_BEGIN_END(ctx);
197
198 if (!params)
199 return;
200
201 if (MESA_VERBOSE & VERBOSE_API)
202 _mesa_debug(ctx, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname));
203
204 if (ctx->Driver.GetPointerv
205 && (*ctx->Driver.GetPointerv)(ctx, pname, params))
206 return;
207
208 switch (pname) {
209 case GL_VERTEX_ARRAY_POINTER:
210 *params = (GLvoid *) ctx->Array.ArrayObj->Vertex.Ptr;
211 break;
212 case GL_NORMAL_ARRAY_POINTER:
213 *params = (GLvoid *) ctx->Array.ArrayObj->Normal.Ptr;
214 break;
215 case GL_COLOR_ARRAY_POINTER:
216 *params = (GLvoid *) ctx->Array.ArrayObj->Color.Ptr;
217 break;
218 case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT:
219 *params = (GLvoid *) ctx->Array.ArrayObj->SecondaryColor.Ptr;
220 break;
221 case GL_FOG_COORDINATE_ARRAY_POINTER_EXT:
222 *params = (GLvoid *) ctx->Array.ArrayObj->FogCoord.Ptr;
223 break;
224 case GL_INDEX_ARRAY_POINTER:
225 *params = (GLvoid *) ctx->Array.ArrayObj->Index.Ptr;
226 break;
227 case GL_TEXTURE_COORD_ARRAY_POINTER:
228 *params = (GLvoid *) ctx->Array.ArrayObj->TexCoord[clientUnit].Ptr;
229 break;
230 case GL_EDGE_FLAG_ARRAY_POINTER:
231 *params = (GLvoid *) ctx->Array.ArrayObj->EdgeFlag.Ptr;
232 break;
233 case GL_FEEDBACK_BUFFER_POINTER:
234 *params = ctx->Feedback.Buffer;
235 break;
236 case GL_SELECTION_BUFFER_POINTER:
237 *params = ctx->Select.Buffer;
238 break;
239 #if FEATURE_MESA_program_debug
240 case GL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA:
241 if (!ctx->Extensions.MESA_program_debug) {
242 _mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv");
243 return;
244 }
245 *params = *(GLvoid **) &ctx->FragmentProgram.Callback;
246 break;
247 case GL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA:
248 if (!ctx->Extensions.MESA_program_debug) {
249 _mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv");
250 return;
251 }
252 *params = ctx->FragmentProgram.CallbackData;
253 break;
254 case GL_VERTEX_PROGRAM_CALLBACK_FUNC_MESA:
255 if (!ctx->Extensions.MESA_program_debug) {
256 _mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv");
257 return;
258 }
259 *params = *(GLvoid **) &ctx->VertexProgram.Callback;
260 break;
261 case GL_VERTEX_PROGRAM_CALLBACK_DATA_MESA:
262 if (!ctx->Extensions.MESA_program_debug) {
263 _mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv");
264 return;
265 }
266 *params = ctx->VertexProgram.CallbackData;
267 break;
268 #endif
269 default:
270 _mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerv" );
271 return;
272 }
273 }
274
275
276 /**
277 * Returns the current GL error code, or GL_NO_ERROR.
278 * \return current error code
279 *
280 * Returns __GLcontextRec::ErrorValue.
281 */
282 GLenum GLAPIENTRY
283 _mesa_GetError( void )
284 {
285 GET_CURRENT_CONTEXT(ctx);
286 GLenum e = ctx->ErrorValue;
287 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
288
289 if (MESA_VERBOSE & VERBOSE_API)
290 _mesa_debug(ctx, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e));
291
292 ctx->ErrorValue = (GLenum) GL_NO_ERROR;
293 return e;
294 }