2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
31 #include "extensions.h"
32 #include "mfeatures.h"
37 * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query.
39 static const GLubyte
*
40 shading_language_version(struct gl_context
*ctx
)
43 case API_OPENGL_COMPAT
:
45 if (!ctx
->Extensions
.ARB_shader_objects
) {
46 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetString");
47 return (const GLubyte
*) 0;
50 switch (ctx
->Const
.GLSLVersion
) {
52 return (const GLubyte
*) "1.10";
54 return (const GLubyte
*) "1.20";
56 return (const GLubyte
*) "1.30";
58 return (const GLubyte
*) "1.40";
60 return (const GLubyte
*) "1.50";
62 return (const GLubyte
*) "3.30";
64 return (const GLubyte
*) "4.00";
66 return (const GLubyte
*) "4.10";
68 return (const GLubyte
*) "4.20";
71 "Invalid GLSL version in shading_language_version()");
72 return (const GLubyte
*) 0;
77 return (const GLubyte
*) "OpenGL ES GLSL ES 1.0.16";
83 _mesa_problem(ctx
, "Unexpected API value in shading_language_version()");
84 return (const GLubyte
*) 0;
90 * Query string-valued state. The return value should _not_ be freed by
93 * \param name the state variable to query.
97 * Tries to get the string from dd_function_table::GetString, otherwise returns
98 * the hardcoded strings.
100 const GLubyte
* GLAPIENTRY
101 _mesa_GetString( GLenum name
)
103 GET_CURRENT_CONTEXT(ctx
);
104 static const char *vendor
= "Brian Paul";
105 static const char *renderer
= "Mesa";
110 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, NULL
);
112 /* this is a required driver function */
113 assert(ctx
->Driver
.GetString
);
115 /* Give the driver the chance to handle this query */
116 const GLubyte
*str
= (*ctx
->Driver
.GetString
)(ctx
, name
);
123 return (const GLubyte
*) vendor
;
125 return (const GLubyte
*) renderer
;
127 return (const GLubyte
*) ctx
->VersionString
;
129 if (ctx
->API
== API_OPENGL_CORE
) {
130 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetString(GL_EXTENSIONS)");
131 return (const GLubyte
*) 0;
133 return (const GLubyte
*) ctx
->Extensions
.String
;
134 case GL_SHADING_LANGUAGE_VERSION
:
135 if (ctx
->API
== API_OPENGLES
)
137 return shading_language_version(ctx
);
138 case GL_PROGRAM_ERROR_STRING_NV
:
139 if (ctx
->API
== API_OPENGL_COMPAT
&&
140 (ctx
->Extensions
.ARB_fragment_program
||
141 ctx
->Extensions
.ARB_vertex_program
)) {
142 return (const GLubyte
*) ctx
->Program
.ErrorString
;
149 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetString" );
150 return (const GLubyte
*) 0;
157 const GLubyte
* GLAPIENTRY
158 _mesa_GetStringi(GLenum name
, GLuint index
)
160 GET_CURRENT_CONTEXT(ctx
);
165 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, NULL
);
169 if (index
>= _mesa_get_extension_count(ctx
)) {
170 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetStringi(index=%u)", index
);
171 return (const GLubyte
*) 0;
173 return _mesa_get_enabled_extension(ctx
, index
);
175 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetString" );
176 return (const GLubyte
*) 0;
183 * Return pointer-valued state, such as a vertex array pointer.
185 * \param pname names state to be queried
186 * \param params returns the pointer value
188 * \sa glGetPointerv().
190 * Tries to get the specified pointer via dd_function_table::GetPointerv,
191 * otherwise gets the specified pointer from the current context.
194 _mesa_GetPointerv( GLenum pname
, GLvoid
**params
)
196 GET_CURRENT_CONTEXT(ctx
);
197 const GLuint clientUnit
= ctx
->Array
.ActiveTexture
;
202 if (MESA_VERBOSE
& VERBOSE_API
)
203 _mesa_debug(ctx
, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname
));
206 case GL_VERTEX_ARRAY_POINTER
:
207 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
209 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Ptr
;
211 case GL_NORMAL_ARRAY_POINTER
:
212 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
214 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Ptr
;
216 case GL_COLOR_ARRAY_POINTER
:
217 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
219 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Ptr
;
221 case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT
:
222 if (ctx
->API
!= API_OPENGL_COMPAT
)
224 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Ptr
;
226 case GL_FOG_COORDINATE_ARRAY_POINTER_EXT
:
227 if (ctx
->API
!= API_OPENGL_COMPAT
)
229 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Ptr
;
231 case GL_INDEX_ARRAY_POINTER
:
232 if (ctx
->API
!= API_OPENGL_COMPAT
)
234 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Ptr
;
236 case GL_TEXTURE_COORD_ARRAY_POINTER
:
237 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
239 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(clientUnit
)].Ptr
;
241 case GL_EDGE_FLAG_ARRAY_POINTER
:
242 if (ctx
->API
!= API_OPENGL_COMPAT
)
244 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Ptr
;
246 case GL_FEEDBACK_BUFFER_POINTER
:
247 if (ctx
->API
!= API_OPENGL_COMPAT
)
249 *params
= ctx
->Feedback
.Buffer
;
251 case GL_SELECTION_BUFFER_POINTER
:
252 if (ctx
->API
!= API_OPENGL_COMPAT
)
254 *params
= ctx
->Select
.Buffer
;
256 case GL_POINT_SIZE_ARRAY_POINTER_OES
:
257 if (ctx
->API
!= API_OPENGLES
)
259 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Ptr
;
261 case GL_DEBUG_CALLBACK_FUNCTION_ARB
:
262 if (!_mesa_is_desktop_gl(ctx
))
264 *params
= (GLvoid
*) ctx
->Debug
.Callback
;
266 case GL_DEBUG_CALLBACK_USER_PARAM_ARB
:
267 if (!_mesa_is_desktop_gl(ctx
))
269 *params
= ctx
->Debug
.CallbackData
;
278 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetPointerv" );
284 * Returns the current GL error code, or GL_NO_ERROR.
285 * \return current error code
287 * Returns __struct gl_contextRec::ErrorValue.
290 _mesa_GetError( void )
292 GET_CURRENT_CONTEXT(ctx
);
293 GLenum e
= ctx
->ErrorValue
;
294 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
296 if (MESA_VERBOSE
& VERBOSE_API
)
297 _mesa_debug(ctx
, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e
));
299 ctx
->ErrorValue
= (GLenum
) GL_NO_ERROR
;
300 ctx
->ErrorDebugCount
= 0;
305 * Returns an error code specified by GL_ARB_robustness, or GL_NO_ERROR.
306 * \return current context status
309 _mesa_GetGraphicsResetStatusARB( void )
311 GET_CURRENT_CONTEXT(ctx
);
312 GLenum status
= ctx
->ResetStatus
;
314 if (MESA_VERBOSE
& VERBOSE_API
)
315 _mesa_debug(ctx
, "glGetGraphicsResetStatusARB"
316 "(always returns GL_NO_ERROR)\n");