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"
33 static const GLubyte
*
34 shading_laguage_version(GLcontext
*ctx
)
37 #if FEATURE_ARB_shading_language_100
39 if (ctx
->Extensions
.ARB_shading_language_120
)
40 return (const GLubyte
*) "1.20";
41 else if (ctx
->Extensions
.ARB_shading_language_100
)
42 return (const GLubyte
*) "1.10";
47 return (const GLubyte
*) "OpenGL ES GLSL ES 1.0.16";
52 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetString" );
53 return (const GLubyte
*) 0;
59 * Query string-valued state. The return value should _not_ be freed by
62 * \param name the state variable to query.
66 * Tries to get the string from dd_function_table::GetString, otherwise returns
67 * the hardcoded strings.
69 const GLubyte
* GLAPIENTRY
70 _mesa_GetString( GLenum name
)
72 GET_CURRENT_CONTEXT(ctx
);
73 static const char *vendor
= "Brian Paul";
74 static const char *renderer
= "Mesa";
79 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, NULL
);
81 /* this is a required driver function */
82 assert(ctx
->Driver
.GetString
);
84 /* Give the driver the chance to handle this query */
85 const GLubyte
*str
= (*ctx
->Driver
.GetString
)(ctx
, name
);
92 return (const GLubyte
*) vendor
;
94 return (const GLubyte
*) renderer
;
96 return (const GLubyte
*) ctx
->VersionString
;
98 if (!ctx
->Extensions
.String
)
99 ctx
->Extensions
.String
= _mesa_make_extension_string(ctx
);
100 return (const GLubyte
*) ctx
->Extensions
.String
;
101 #if FEATURE_ARB_shading_language_100 || FEATURE_ES2
102 case GL_SHADING_LANGUAGE_VERSION
:
103 return shading_laguage_version(ctx
);
105 #if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \
106 FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
107 case GL_PROGRAM_ERROR_STRING_NV
:
108 if (ctx
->Extensions
.NV_fragment_program
||
109 ctx
->Extensions
.ARB_fragment_program
||
110 ctx
->Extensions
.NV_vertex_program
||
111 ctx
->Extensions
.ARB_vertex_program
) {
112 return (const GLubyte
*) ctx
->Program
.ErrorString
;
117 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetString" );
118 return (const GLubyte
*) 0;
126 const GLubyte
* GLAPIENTRY
127 _mesa_GetStringi(GLenum name
, GLuint index
)
129 GET_CURRENT_CONTEXT(ctx
);
134 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, NULL
);
138 if (index
>= _mesa_get_extension_count(ctx
)) {
139 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetStringi(index=%u)", index
);
140 return (const GLubyte
*) 0;
142 return _mesa_get_enabled_extension(ctx
, index
);
144 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetString" );
145 return (const GLubyte
*) 0;
152 * Return pointer-valued state, such as a vertex array pointer.
154 * \param pname names state to be queried
155 * \param params returns the pointer value
157 * \sa glGetPointerv().
159 * Tries to get the specified pointer via dd_function_table::GetPointerv,
160 * otherwise gets the specified pointer from the current context.
163 _mesa_GetPointerv( GLenum pname
, GLvoid
**params
)
165 GET_CURRENT_CONTEXT(ctx
);
166 const GLuint clientUnit
= ctx
->Array
.ActiveTexture
;
167 ASSERT_OUTSIDE_BEGIN_END(ctx
);
172 if (MESA_VERBOSE
& VERBOSE_API
)
173 _mesa_debug(ctx
, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname
));
176 case GL_VERTEX_ARRAY_POINTER
:
177 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->Vertex
.Ptr
;
179 case GL_NORMAL_ARRAY_POINTER
:
180 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->Normal
.Ptr
;
182 case GL_COLOR_ARRAY_POINTER
:
183 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->Color
.Ptr
;
185 case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT
:
186 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->SecondaryColor
.Ptr
;
188 case GL_FOG_COORDINATE_ARRAY_POINTER_EXT
:
189 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->FogCoord
.Ptr
;
191 case GL_INDEX_ARRAY_POINTER
:
192 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->Index
.Ptr
;
194 case GL_TEXTURE_COORD_ARRAY_POINTER
:
195 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->TexCoord
[clientUnit
].Ptr
;
197 case GL_EDGE_FLAG_ARRAY_POINTER
:
198 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->EdgeFlag
.Ptr
;
200 case GL_FEEDBACK_BUFFER_POINTER
:
201 *params
= ctx
->Feedback
.Buffer
;
203 case GL_SELECTION_BUFFER_POINTER
:
204 *params
= ctx
->Select
.Buffer
;
206 #if FEATURE_point_size_array
207 case GL_POINT_SIZE_ARRAY_POINTER_OES
:
208 *params
= (GLvoid
*) ctx
->Array
.ArrayObj
->PointSize
.Ptr
;
212 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetPointerv" );
219 * Returns the current GL error code, or GL_NO_ERROR.
220 * \return current error code
222 * Returns __GLcontextRec::ErrorValue.
225 _mesa_GetError( void )
227 GET_CURRENT_CONTEXT(ctx
);
228 GLenum e
= ctx
->ErrorValue
;
229 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
231 if (MESA_VERBOSE
& VERBOSE_API
)
232 _mesa_debug(ctx
, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e
));
234 ctx
->ErrorValue
= (GLenum
) GL_NO_ERROR
;
235 ctx
->ErrorDebugCount
= 0;