2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
31 #include "extensions.h"
36 * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query.
38 static const GLubyte
*
39 shading_language_version(struct gl_context
*ctx
)
42 case API_OPENGL_COMPAT
:
44 switch (ctx
->Const
.GLSLVersion
) {
46 return (const GLubyte
*) "1.10";
48 return (const GLubyte
*) "1.20";
50 return (const GLubyte
*) "1.30";
52 return (const GLubyte
*) "1.40";
54 return (const GLubyte
*) "1.50";
56 return (const GLubyte
*) "3.30";
58 return (const GLubyte
*) "4.00";
60 return (const GLubyte
*) "4.10";
62 return (const GLubyte
*) "4.20";
65 "Invalid GLSL version in shading_language_version()");
66 return (const GLubyte
*) 0;
71 return (ctx
->Version
< 30)
72 ? (const GLubyte
*) "OpenGL ES GLSL ES 1.0.16"
73 : (const GLubyte
*) "OpenGL ES GLSL ES 3.0";
79 _mesa_problem(ctx
, "Unexpected API value in shading_language_version()");
80 return (const GLubyte
*) 0;
86 * Query string-valued state. The return value should _not_ be freed by
89 * \param name the state variable to query.
93 * Tries to get the string from dd_function_table::GetString, otherwise returns
94 * the hardcoded strings.
96 const GLubyte
* GLAPIENTRY
97 _mesa_GetString( GLenum name
)
99 GET_CURRENT_CONTEXT(ctx
);
100 static const char *vendor
= "Brian Paul";
101 static const char *renderer
= "Mesa";
106 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, NULL
);
108 /* this is a required driver function */
109 assert(ctx
->Driver
.GetString
);
111 /* Give the driver the chance to handle this query */
112 const GLubyte
*str
= (*ctx
->Driver
.GetString
)(ctx
, name
);
119 return (const GLubyte
*) vendor
;
121 return (const GLubyte
*) renderer
;
123 return (const GLubyte
*) ctx
->VersionString
;
125 if (ctx
->API
== API_OPENGL_CORE
) {
126 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetString(GL_EXTENSIONS)");
127 return (const GLubyte
*) 0;
129 return (const GLubyte
*) ctx
->Extensions
.String
;
130 case GL_SHADING_LANGUAGE_VERSION
:
131 if (ctx
->API
== API_OPENGLES
)
133 return shading_language_version(ctx
);
134 case GL_PROGRAM_ERROR_STRING_ARB
:
135 if (ctx
->API
== API_OPENGL_COMPAT
&&
136 (ctx
->Extensions
.ARB_fragment_program
||
137 ctx
->Extensions
.ARB_vertex_program
)) {
138 return (const GLubyte
*) ctx
->Program
.ErrorString
;
145 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetString" );
146 return (const GLubyte
*) 0;
153 const GLubyte
* GLAPIENTRY
154 _mesa_GetStringi(GLenum name
, GLuint index
)
156 GET_CURRENT_CONTEXT(ctx
);
161 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, NULL
);
165 if (index
>= _mesa_get_extension_count(ctx
)) {
166 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetStringi(index=%u)", index
);
167 return (const GLubyte
*) 0;
169 return _mesa_get_enabled_extension(ctx
, index
);
171 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetString" );
172 return (const GLubyte
*) 0;
179 * Return pointer-valued state, such as a vertex array pointer.
181 * \param pname names state to be queried
182 * \param params returns the pointer value
184 * \sa glGetPointerv().
186 * Tries to get the specified pointer via dd_function_table::GetPointerv,
187 * otherwise gets the specified pointer from the current context.
190 _mesa_GetPointerv( GLenum pname
, GLvoid
**params
)
192 GET_CURRENT_CONTEXT(ctx
);
193 const GLuint clientUnit
= ctx
->Array
.ActiveTexture
;
198 if (MESA_VERBOSE
& VERBOSE_API
)
199 _mesa_debug(ctx
, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname
));
202 case GL_VERTEX_ARRAY_POINTER
:
203 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
205 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POS
].Ptr
;
207 case GL_NORMAL_ARRAY_POINTER
:
208 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
210 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_NORMAL
].Ptr
;
212 case GL_COLOR_ARRAY_POINTER
:
213 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
215 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR0
].Ptr
;
217 case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT
:
218 if (ctx
->API
!= API_OPENGL_COMPAT
)
220 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR1
].Ptr
;
222 case GL_FOG_COORDINATE_ARRAY_POINTER_EXT
:
223 if (ctx
->API
!= API_OPENGL_COMPAT
)
225 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_FOG
].Ptr
;
227 case GL_INDEX_ARRAY_POINTER
:
228 if (ctx
->API
!= API_OPENGL_COMPAT
)
230 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Ptr
;
232 case GL_TEXTURE_COORD_ARRAY_POINTER
:
233 if (ctx
->API
!= API_OPENGL_COMPAT
&& ctx
->API
!= API_OPENGLES
)
235 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_TEX(clientUnit
)].Ptr
;
237 case GL_EDGE_FLAG_ARRAY_POINTER
:
238 if (ctx
->API
!= API_OPENGL_COMPAT
)
240 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Ptr
;
242 case GL_FEEDBACK_BUFFER_POINTER
:
243 if (ctx
->API
!= API_OPENGL_COMPAT
)
245 *params
= ctx
->Feedback
.Buffer
;
247 case GL_SELECTION_BUFFER_POINTER
:
248 if (ctx
->API
!= API_OPENGL_COMPAT
)
250 *params
= ctx
->Select
.Buffer
;
252 case GL_POINT_SIZE_ARRAY_POINTER_OES
:
253 if (ctx
->API
!= API_OPENGLES
)
255 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[VERT_ATTRIB_POINT_SIZE
].Ptr
;
257 case GL_DEBUG_CALLBACK_FUNCTION_ARB
:
258 if (!_mesa_is_desktop_gl(ctx
))
260 *params
= (GLvoid
*) ctx
->Debug
.Callback
;
262 case GL_DEBUG_CALLBACK_USER_PARAM_ARB
:
263 if (!_mesa_is_desktop_gl(ctx
))
265 *params
= ctx
->Debug
.CallbackData
;
274 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetPointerv" );
280 * Returns the current GL error code, or GL_NO_ERROR.
281 * \return current error code
283 * Returns __struct gl_contextRec::ErrorValue.
286 _mesa_GetError( void )
288 GET_CURRENT_CONTEXT(ctx
);
289 GLenum e
= ctx
->ErrorValue
;
290 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
292 if (MESA_VERBOSE
& VERBOSE_API
)
293 _mesa_debug(ctx
, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e
));
295 ctx
->ErrorValue
= (GLenum
) GL_NO_ERROR
;
296 ctx
->ErrorDebugCount
= 0;
301 * Returns an error code specified by GL_ARB_robustness, or GL_NO_ERROR.
302 * \return current context status
305 _mesa_GetGraphicsResetStatusARB( void )
307 GET_CURRENT_CONTEXT(ctx
);
308 GLenum status
= ctx
->ResetStatus
;
310 if (MESA_VERBOSE
& VERBOSE_API
)
311 _mesa_debug(ctx
, "glGetGraphicsResetStatusARB"
312 "(always returns GL_NO_ERROR)\n");