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.
28 * Query string-valued state. The return value should _not_ be freed by
31 * \param name the state variable to query.
35 * Tries to get the string from dd_function_table::GetString, otherwise returns
36 * the hardcoded strings.
38 const GLubyte
* GLAPIENTRY
39 _mesa_GetString( GLenum name
)
41 GET_CURRENT_CONTEXT(ctx
);
42 static const char *vendor
= "Brian Paul";
43 static const char *renderer
= "Mesa";
48 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, NULL
);
50 /* this is a required driver function */
51 assert(ctx
->Driver
.GetString
);
53 /* Give the driver the chance to handle this query */
54 const GLubyte
*str
= (*ctx
->Driver
.GetString
)(ctx
, name
);
61 return (const GLubyte
*) vendor
;
63 return (const GLubyte
*) renderer
;
65 return (const GLubyte
*) ctx
->VersionString
;
67 return (const GLubyte
*) ctx
->Extensions
.String
;
69 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetString" );
70 return (const GLubyte
*) 0;
77 * Return pointer-valued state, such as a vertex array pointer.
79 * \param pname names state to be queried
80 * \param params returns the pointer value
82 * \sa glGetPointerv().
84 * Tries to get the specified pointer via dd_function_table::GetPointerv,
85 * otherwise gets the specified pointer from the current context.
88 _mesa_GetPointerv( GLenum pname
, GLvoid
**params
)
90 GET_CURRENT_CONTEXT(ctx
);
91 ASSERT_OUTSIDE_BEGIN_END(ctx
);
96 if (MESA_VERBOSE
& VERBOSE_API
)
97 _mesa_debug(ctx
, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname
));
100 case GL_VERTEX_ARRAY_POINTER
:
101 *params
= (GLvoid
*) ctx
->Array
.VertexAttrib
[VERT_ATTRIB_POS
].Ptr
;
103 case GL_NORMAL_ARRAY_POINTER
:
104 *params
= (GLvoid
*) ctx
->Array
.VertexAttrib
[VERT_ATTRIB_NORMAL
].Ptr
;
106 case GL_COLOR_ARRAY_POINTER
:
107 *params
= (GLvoid
*) ctx
->Array
.VertexAttrib
[VERT_ATTRIB_COLOR
].Ptr
;
109 case GL_FOG_COORDINATE_ARRAY_POINTER_EXT
:
110 *params
= (GLvoid
*) ctx
->Array
.VertexAttrib
[VERT_ATTRIB_FOG
].Ptr
;
112 case GL_INDEX_ARRAY_POINTER
:
113 *params
= (GLvoid
*) ctx
->Array
.VertexAttrib
[VERT_ATTRIB_COLOR_INDEX
].Ptr
;
115 case GL_TEXTURE_COORD_ARRAY_POINTER
:
116 *params
= (GLvoid
*) ctx
->Array
.VertexAttrib
[VERT_ATTRIB_TEX
].Ptr
;
118 case GL_EDGE_FLAG_ARRAY_POINTER
:
119 *params
= (GLvoid
*) ctx
->Array
.VertexAttrib
[VERT_ATTRIB_EDGEFLAG
].Ptr
;
121 case GL_FEEDBACK_BUFFER_POINTER
:
122 *params
= ctx
->Feedback
.Buffer
;
124 case GL_SELECTION_BUFFER_POINTER
:
125 *params
= ctx
->Select
.Buffer
;
128 _mesa_error( ctx
, GL_INVALID_ENUM
, "glGetPointerv" );
135 * Returns the current GL error code, or GL_NO_ERROR.
136 * \return current error code
138 * Returns __struct gl_contextRec::ErrorValue.
141 _mesa_GetError( void )
143 GET_CURRENT_CONTEXT(ctx
);
144 GLenum e
= ctx
->ErrorValue
;
145 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
147 if (MESA_VERBOSE
& VERBOSE_API
)
148 _mesa_debug(ctx
, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e
));
150 ctx
->ErrorValue
= (GLenum
) GL_NO_ERROR
;
151 ctx
->ErrorDebugCount
= 0;