| 1 |
/* |
| 2 |
* Mesa 3-D graphics library |
| 3 |
* Version: 6.3 |
| 4 |
* |
| 5 |
* Copyright (C) 1999-2005 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 = "1.5 Mesa " MESA_VERSION_STRING;/*XXX FIX*/ |
| 58 |
|
| 59 |
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL); |
| 60 |
|
| 61 |
/* this is a required driver function */ |
| 62 |
assert(ctx->Driver.GetString); |
| 63 |
{ |
| 64 |
/* Give the driver the chance to handle this query */ |
| 65 |
const GLubyte *str = (*ctx->Driver.GetString)(ctx, name); |
| 66 |
if (str) |
| 67 |
return str; |
| 68 |
} |
| 69 |
|
| 70 |
switch (name) { |
| 71 |
case GL_VENDOR: |
| 72 |
return (const GLubyte *) vendor; |
| 73 |
case GL_RENDERER: |
| 74 |
return (const GLubyte *) renderer; |
| 75 |
case GL_VERSION: |
| 76 |
if (ctx->Extensions.ARB_multisample && |
| 77 |
ctx->Extensions.ARB_multitexture && |
| 78 |
ctx->Extensions.ARB_texture_border_clamp && |
| 79 |
ctx->Extensions.ARB_texture_compression && |
| 80 |
ctx->Extensions.ARB_texture_cube_map && |
| 81 |
ctx->Extensions.EXT_texture_env_add && |
| 82 |
ctx->Extensions.ARB_texture_env_combine && |
| 83 |
ctx->Extensions.ARB_texture_env_dot3) { |
| 84 |
if (ctx->Extensions.ARB_depth_texture && |
| 85 |
ctx->Extensions.ARB_shadow && |
| 86 |
ctx->Extensions.ARB_texture_env_crossbar && |
| 87 |
ctx->Extensions.ARB_texture_mirrored_repeat && |
| 88 |
ctx->Extensions.ARB_window_pos && |
| 89 |
ctx->Extensions.EXT_blend_color && |
| 90 |
ctx->Extensions.EXT_blend_func_separate && |
| 91 |
ctx->Extensions.EXT_blend_logic_op && |
| 92 |
ctx->Extensions.EXT_blend_minmax && |
| 93 |
ctx->Extensions.EXT_blend_subtract && |
| 94 |
ctx->Extensions.EXT_fog_coord && |
| 95 |
ctx->Extensions.EXT_multi_draw_arrays && |
| 96 |
ctx->Extensions.EXT_point_parameters && /*aka ARB*/ |
| 97 |
ctx->Extensions.EXT_secondary_color && |
| 98 |
ctx->Extensions.EXT_stencil_wrap && |
| 99 |
ctx->Extensions.EXT_texture_lod_bias && |
| 100 |
ctx->Extensions.SGIS_generate_mipmap) { |
| 101 |
if (ctx->Extensions.ARB_occlusion_query && |
| 102 |
ctx->Extensions.ARB_vertex_buffer_object && |
| 103 |
ctx->Extensions.EXT_shadow_funcs) { |
| 104 |
if (ctx->Extensions.ARB_draw_buffers && |
| 105 |
ctx->Extensions.ARB_point_sprite && |
| 106 |
ctx->Extensions.ARB_texture_non_power_of_two && |
| 107 |
ctx->Extensions.EXT_stencil_two_side) { |
| 108 |
return (const GLubyte *) version_2_0; |
| 109 |
} |
| 110 |
else { |
| 111 |
return (const GLubyte *) version_1_5; |
| 112 |
} |
| 113 |
} |
| 114 |
else { |
| 115 |
return (const GLubyte *) version_1_4; |
| 116 |
} |
| 117 |
} |
| 118 |
else { |
| 119 |
return (const GLubyte *) version_1_3; |
| 120 |
} |
| 121 |
} |
| 122 |
else { |
| 123 |
return (const GLubyte *) version_1_2; |
| 124 |
} |
| 125 |
case GL_EXTENSIONS: |
| 126 |
if (!ctx->Extensions.String) |
| 127 |
ctx->Extensions.String = _mesa_make_extension_string(ctx); |
| 128 |
return (const GLubyte *) ctx->Extensions.String; |
| 129 |
#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \ |
| 130 |
FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program |
| 131 |
case GL_PROGRAM_ERROR_STRING_NV: |
| 132 |
if (ctx->Extensions.NV_fragment_program || |
| 133 |
ctx->Extensions.ARB_fragment_program || |
| 134 |
ctx->Extensions.NV_vertex_program || |
| 135 |
ctx->Extensions.ARB_vertex_program) { |
| 136 |
return (const GLubyte *) ctx->Program.ErrorString; |
| 137 |
} |
| 138 |
/* FALL-THROUGH */ |
| 139 |
#endif |
| 140 |
default: |
| 141 |
_mesa_error( ctx, GL_INVALID_ENUM, "glGetString" ); |
| 142 |
return (const GLubyte *) 0; |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
/** |
| 148 |
* Return pointer-valued state, such as a vertex array pointer. |
| 149 |
* |
| 150 |
* \param pname names state to be queried |
| 151 |
* \param params returns the pointer value |
| 152 |
* |
| 153 |
* \sa glGetPointerv(). |
| 154 |
* |
| 155 |
* Tries to get the specified pointer via dd_function_table::GetPointerv, |
| 156 |
* otherwise gets the specified pointer from the current context. |
| 157 |
*/ |
| 158 |
void GLAPIENTRY |
| 159 |
_mesa_GetPointerv( GLenum pname, GLvoid **params ) |
| 160 |
{ |
| 161 |
GET_CURRENT_CONTEXT(ctx); |
| 162 |
const GLuint clientUnit = ctx->Array.ActiveTexture; |
| 163 |
ASSERT_OUTSIDE_BEGIN_END(ctx); |
| 164 |
|
| 165 |
if (!params) |
| 166 |
return; |
| 167 |
|
| 168 |
if (MESA_VERBOSE & VERBOSE_API) |
| 169 |
_mesa_debug(ctx, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname)); |
| 170 |
|
| 171 |
if (ctx->Driver.GetPointerv |
| 172 |
&& (*ctx->Driver.GetPointerv)(ctx, pname, params)) |
| 173 |
return; |
| 174 |
|
| 175 |
switch (pname) { |
| 176 |
case GL_VERTEX_ARRAY_POINTER: |
| 177 |
*params = (GLvoid *) ctx->Array.Vertex.Ptr; |
| 178 |
break; |
| 179 |
case GL_NORMAL_ARRAY_POINTER: |
| 180 |
*params = (GLvoid *) ctx->Array.Normal.Ptr; |
| 181 |
break; |
| 182 |
case GL_COLOR_ARRAY_POINTER: |
| 183 |
*params = (GLvoid *) ctx->Array.Color.Ptr; |
| 184 |
break; |
| 185 |
case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT: |
| 186 |
*params = (GLvoid *) ctx->Array.SecondaryColor.Ptr; |
| 187 |
break; |
| 188 |
case GL_FOG_COORDINATE_ARRAY_POINTER_EXT: |
| 189 |
*params = (GLvoid *) ctx->Array.FogCoord.Ptr; |
| 190 |
break; |
| 191 |
case GL_INDEX_ARRAY_POINTER: |
| 192 |
*params = (GLvoid *) ctx->Array.Index.Ptr; |
| 193 |
break; |
| 194 |
case GL_TEXTURE_COORD_ARRAY_POINTER: |
| 195 |
*params = (GLvoid *) ctx->Array.TexCoord[clientUnit].Ptr; |
| 196 |
break; |
| 197 |
case GL_EDGE_FLAG_ARRAY_POINTER: |
| 198 |
*params = (GLvoid *) ctx->Array.EdgeFlag.Ptr; |
| 199 |
break; |
| 200 |
case GL_FEEDBACK_BUFFER_POINTER: |
| 201 |
*params = ctx->Feedback.Buffer; |
| 202 |
break; |
| 203 |
case GL_SELECTION_BUFFER_POINTER: |
| 204 |
*params = ctx->Select.Buffer; |
| 205 |
break; |
| 206 |
#if FEATURE_MESA_program_debug |
| 207 |
case GL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA: |
| 208 |
if (!ctx->Extensions.MESA_program_debug) { |
| 209 |
_mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv"); |
| 210 |
return; |
| 211 |
} |
| 212 |
*params = *(GLvoid **) &ctx->FragmentProgram.Callback; |
| 213 |
break; |
| 214 |
case GL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA: |
| 215 |
if (!ctx->Extensions.MESA_program_debug) { |
| 216 |
_mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv"); |
| 217 |
return; |
| 218 |
} |
| 219 |
*params = ctx->FragmentProgram.CallbackData; |
| 220 |
break; |
| 221 |
case GL_VERTEX_PROGRAM_CALLBACK_FUNC_MESA: |
| 222 |
if (!ctx->Extensions.MESA_program_debug) { |
| 223 |
_mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv"); |
| 224 |
return; |
| 225 |
} |
| 226 |
*params = *(GLvoid **) &ctx->VertexProgram.Callback; |
| 227 |
break; |
| 228 |
case GL_VERTEX_PROGRAM_CALLBACK_DATA_MESA: |
| 229 |
if (!ctx->Extensions.MESA_program_debug) { |
| 230 |
_mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv"); |
| 231 |
return; |
| 232 |
} |
| 233 |
*params = ctx->VertexProgram.CallbackData; |
| 234 |
break; |
| 235 |
#endif |
| 236 |
default: |
| 237 |
_mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerv" ); |
| 238 |
return; |
| 239 |
} |
| 240 |
} |
| 241 |
|
| 242 |
|
| 243 |
/** |
| 244 |
* Returns the current GL error code, or GL_NO_ERROR. |
| 245 |
* \return current error code |
| 246 |
* |
| 247 |
* Returns __GLcontextRec::ErrorValue. |
| 248 |
*/ |
| 249 |
GLenum GLAPIENTRY |
| 250 |
_mesa_GetError( void ) |
| 251 |
{ |
| 252 |
GET_CURRENT_CONTEXT(ctx); |
| 253 |
GLenum e = ctx->ErrorValue; |
| 254 |
ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); |
| 255 |
|
| 256 |
if (MESA_VERBOSE & VERBOSE_API) |
| 257 |
_mesa_debug(ctx, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e)); |
| 258 |
|
| 259 |
ctx->ErrorValue = (GLenum) GL_NO_ERROR; |
| 260 |
return e; |
| 261 |
} |