blob: 11b4ad6400e6754931677172ce4ab069e898be42 [file] [log] [blame]
Keith Whitwell6dc85572003-07-17 13:43:59 +00001/**
2 * \file enable.c
3 * Enable/disable/query GL capabilities.
4 */
5
jtgafb833d1999-08-19 00:55:39 +00006/*
7 * Mesa 3-D graphics library
Brian Paul813e56d2006-07-18 19:15:40 +00008 * Version: 6.5.1
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00009 *
Brian Paul813e56d2006-07-18 19:15:40 +000010 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000011 *
jtgafb833d1999-08-19 00:55:39 +000012 * Permission is hereby granted, free of charge, to any person obtaining a
13 * copy of this software and associated documentation files (the "Software"),
14 * to deal in the Software without restriction, including without limitation
15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 * and/or sell copies of the Software, and to permit persons to whom the
17 * Software is furnished to do so, subject to the following conditions:
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000018 *
jtgafb833d1999-08-19 00:55:39 +000019 * The above copyright notice and this permission notice shall be included
20 * in all copies or substantial portions of the Software.
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000021 *
jtgafb833d1999-08-19 00:55:39 +000022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
23 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
26 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30
Brian Paulfbd8f211999-11-11 01:22:25 +000031#include "glheader.h"
jtgafb833d1999-08-19 00:55:39 +000032#include "context.h"
33#include "enable.h"
34#include "light.h"
35#include "macros.h"
jtgafb833d1999-08-19 00:55:39 +000036#include "simple_list.h"
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +000037#include "mtypes.h"
jtgafb833d1999-08-19 00:55:39 +000038#include "enums.h"
Keith Whitwell23caf202000-11-16 21:05:34 +000039#include "math/m_matrix.h"
40#include "math/m_xform.h"
Brian Paul3c634522002-10-24 23:57:19 +000041
jtgafb833d1999-08-19 00:55:39 +000042
43
Brian Paul02c03ef2002-06-18 16:53:46 +000044#define CHECK_EXTENSION(EXTNAME, CAP) \
Brian Paul86b84272001-12-14 02:50:01 +000045 if (!ctx->Extensions.EXTNAME) { \
Brian Paul4e9676f2002-06-29 19:48:15 +000046 _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \
47 state ? "Enable" : "Disable", CAP); \
Brian Paul86b84272001-12-14 02:50:01 +000048 return; \
49 }
50
Brian Paul86b84272001-12-14 02:50:01 +000051
Brian8dcfcad72006-12-13 15:31:14 -070052/**
53 * Helper to enable/disable client-side state.
54 */
Keith Whitwellcab974c2000-12-26 05:09:27 +000055static void
Brian8dcfcad72006-12-13 15:31:14 -070056client_state(GLcontext *ctx, GLenum cap, GLboolean state)
Keith Whitwellcab974c2000-12-26 05:09:27 +000057{
58 GLuint flag;
Keith Whitwell99efde42006-10-30 16:44:13 +000059 GLboolean *var;
Keith Whitwellcab974c2000-12-26 05:09:27 +000060
61 switch (cap) {
Brian Paul86b84272001-12-14 02:50:01 +000062 case GL_VERTEX_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000063 var = &ctx->Array.ArrayObj->Vertex.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000064 flag = _NEW_ARRAY_VERTEX;
65 break;
66 case GL_NORMAL_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000067 var = &ctx->Array.ArrayObj->Normal.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000068 flag = _NEW_ARRAY_NORMAL;
69 break;
70 case GL_COLOR_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000071 var = &ctx->Array.ArrayObj->Color.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000072 flag = _NEW_ARRAY_COLOR0;
73 break;
74 case GL_INDEX_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000075 var = &ctx->Array.ArrayObj->Index.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000076 flag = _NEW_ARRAY_INDEX;
77 break;
78 case GL_TEXTURE_COORD_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000079 var = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000080 flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture);
81 break;
82 case GL_EDGE_FLAG_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000083 var = &ctx->Array.ArrayObj->EdgeFlag.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000084 flag = _NEW_ARRAY_EDGEFLAG;
85 break;
86 case GL_FOG_COORDINATE_ARRAY_EXT:
Ian Romanickee34e6e2006-06-12 16:26:29 +000087 var = &ctx->Array.ArrayObj->FogCoord.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000088 flag = _NEW_ARRAY_FOGCOORD;
89 break;
90 case GL_SECONDARY_COLOR_ARRAY_EXT:
Ian Romanickee34e6e2006-06-12 16:26:29 +000091 var = &ctx->Array.ArrayObj->SecondaryColor.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000092 flag = _NEW_ARRAY_COLOR1;
93 break;
94
Brian Paul8dfc5b92002-10-16 17:57:51 +000095#if FEATURE_NV_vertex_program
Brian Paul86b84272001-12-14 02:50:01 +000096 case GL_VERTEX_ATTRIB_ARRAY0_NV:
97 case GL_VERTEX_ATTRIB_ARRAY1_NV:
98 case GL_VERTEX_ATTRIB_ARRAY2_NV:
99 case GL_VERTEX_ATTRIB_ARRAY3_NV:
100 case GL_VERTEX_ATTRIB_ARRAY4_NV:
101 case GL_VERTEX_ATTRIB_ARRAY5_NV:
102 case GL_VERTEX_ATTRIB_ARRAY6_NV:
103 case GL_VERTEX_ATTRIB_ARRAY7_NV:
104 case GL_VERTEX_ATTRIB_ARRAY8_NV:
105 case GL_VERTEX_ATTRIB_ARRAY9_NV:
106 case GL_VERTEX_ATTRIB_ARRAY10_NV:
107 case GL_VERTEX_ATTRIB_ARRAY11_NV:
108 case GL_VERTEX_ATTRIB_ARRAY12_NV:
109 case GL_VERTEX_ATTRIB_ARRAY13_NV:
110 case GL_VERTEX_ATTRIB_ARRAY14_NV:
111 case GL_VERTEX_ATTRIB_ARRAY15_NV:
Brian Paul02c03ef2002-06-18 16:53:46 +0000112 CHECK_EXTENSION(NV_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000113 {
114 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
Ian Romanickee34e6e2006-06-12 16:26:29 +0000115 var = &ctx->Array.ArrayObj->VertexAttrib[n].Enabled;
Brian Paulb7752722002-04-21 18:49:18 +0000116 flag = _NEW_ARRAY_ATTRIB(n);
Brian Paul86b84272001-12-14 02:50:01 +0000117 }
118 break;
Brian Paul8dfc5b92002-10-16 17:57:51 +0000119#endif /* FEATURE_NV_vertex_program */
120
Brian Paul86b84272001-12-14 02:50:01 +0000121 default:
Brian Paul4e9676f2002-06-29 19:48:15 +0000122 _mesa_error( ctx, GL_INVALID_ENUM,
123 "glEnable/DisableClientState(0x%x)", cap);
Brian Paul86b84272001-12-14 02:50:01 +0000124 return;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000125 }
126
Alan Hourihane68c48df2002-04-19 08:38:23 +0000127 if (*var == state)
Keith Whitwellcab974c2000-12-26 05:09:27 +0000128 return;
129
130 FLUSH_VERTICES(ctx, _NEW_ARRAY);
131 ctx->Array.NewState |= flag;
132 *var = state;
133
Gareth Hughes22144ab2001-03-12 00:48:37 +0000134 if (state)
Ian Romanickee34e6e2006-06-12 16:26:29 +0000135 ctx->Array.ArrayObj->_Enabled |= flag;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000136 else
Ian Romanickee34e6e2006-06-12 16:26:29 +0000137 ctx->Array.ArrayObj->_Enabled &= ~flag;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000138
139 if (ctx->Driver.Enable) {
Brian8dcfcad72006-12-13 15:31:14 -0700140 ctx->Driver.Enable( ctx, cap, state );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000141 }
142}
143
144
Keith Whitwell6dc85572003-07-17 13:43:59 +0000145/**
146 * Enable GL capability.
Brian8dcfcad72006-12-13 15:31:14 -0700147 * \param cap state to enable/disable.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000148 *
149 * Get's the current context, assures that we're outside glBegin()/glEnd() and
150 * calls client_state().
151 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000152void GLAPIENTRY
Keith Whitwellcab974c2000-12-26 05:09:27 +0000153_mesa_EnableClientState( GLenum cap )
154{
155 GET_CURRENT_CONTEXT(ctx);
156 ASSERT_OUTSIDE_BEGIN_END(ctx);
157 client_state( ctx, cap, GL_TRUE );
158}
159
160
Keith Whitwell6dc85572003-07-17 13:43:59 +0000161/**
162 * Disable GL capability.
Brian8dcfcad72006-12-13 15:31:14 -0700163 * \param cap state to enable/disable.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000164 *
165 * Get's the current context, assures that we're outside glBegin()/glEnd() and
166 * calls client_state().
167 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000168void GLAPIENTRY
Keith Whitwellcab974c2000-12-26 05:09:27 +0000169_mesa_DisableClientState( GLenum cap )
170{
171 GET_CURRENT_CONTEXT(ctx);
172 ASSERT_OUTSIDE_BEGIN_END(ctx);
173 client_state( ctx, cap, GL_FALSE );
174}
175
jtgafb833d1999-08-19 00:55:39 +0000176
Brian Paul86b84272001-12-14 02:50:01 +0000177#undef CHECK_EXTENSION
Brian Paul02c03ef2002-06-18 16:53:46 +0000178#define CHECK_EXTENSION(EXTNAME, CAP) \
179 if (!ctx->Extensions.EXTNAME) { \
Brian Paul4e9676f2002-06-29 19:48:15 +0000180 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
181 state ? "Enable" : "Disable", CAP); \
Brian Paul02c03ef2002-06-18 16:53:46 +0000182 return; \
Brian Paul86b84272001-12-14 02:50:01 +0000183 }
184
Brian Paulefb2ade2004-08-18 18:45:25 +0000185#define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
186 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
187 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
188 state ? "Enable" : "Disable", CAP); \
189 return; \
190 }
191
192
Brian Paul86b84272001-12-14 02:50:01 +0000193
Keith Whitwell6dc85572003-07-17 13:43:59 +0000194/**
Brian8dcfcad72006-12-13 15:31:14 -0700195 * Helper function to enable or disable state.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000196 *
197 * \param ctx GL context.
Brian8dcfcad72006-12-13 15:31:14 -0700198 * \param cap the state to enable/disable
Keith Whitwell6dc85572003-07-17 13:43:59 +0000199 * \param state whether to enable or disable the specified capability.
200 *
201 * Updates the current context and flushes the vertices as needed. For
202 * capabilities associated with extensions it verifies that those extensions
203 * are effectivly present before updating. Notifies the driver via
204 * dd_function_table::Enable.
jtgafb833d1999-08-19 00:55:39 +0000205 */
Brian8dcfcad72006-12-13 15:31:14 -0700206void
207_mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
jtgafb833d1999-08-19 00:55:39 +0000208{
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000209 if (MESA_VERBOSE & VERBOSE_API)
Brian Paul4753d602002-06-15 02:38:15 +0000210 _mesa_debug(ctx, "%s %s (newstate is %x)\n",
Brian Paul9a33a112002-06-13 04:28:29 +0000211 state ? "glEnable" : "glDisable",
212 _mesa_lookup_enum_by_nr(cap),
213 ctx->NewState);
jtgafb833d1999-08-19 00:55:39 +0000214
215 switch (cap) {
Brian Paul86b84272001-12-14 02:50:01 +0000216 case GL_ALPHA_TEST:
217 if (ctx->Color.AlphaEnabled == state)
218 return;
219 FLUSH_VERTICES(ctx, _NEW_COLOR);
220 ctx->Color.AlphaEnabled = state;
221 break;
222 case GL_AUTO_NORMAL:
223 if (ctx->Eval.AutoNormal == state)
224 return;
225 FLUSH_VERTICES(ctx, _NEW_EVAL);
226 ctx->Eval.AutoNormal = state;
227 break;
228 case GL_BLEND:
229 if (ctx->Color.BlendEnabled == state)
230 return;
231 FLUSH_VERTICES(ctx, _NEW_COLOR);
232 ctx->Color.BlendEnabled = state;
Brian Paul86b84272001-12-14 02:50:01 +0000233 break;
Keith Whitwell6dc85572003-07-17 13:43:59 +0000234#if FEATURE_userclip
Brian Paul86b84272001-12-14 02:50:01 +0000235 case GL_CLIP_PLANE0:
236 case GL_CLIP_PLANE1:
237 case GL_CLIP_PLANE2:
238 case GL_CLIP_PLANE3:
239 case GL_CLIP_PLANE4:
240 case GL_CLIP_PLANE5:
241 {
Brian Paul103bc0f2002-03-29 17:27:59 +0000242 const GLuint p = cap - GL_CLIP_PLANE0;
jtgafb833d1999-08-19 00:55:39 +0000243
Brian Pauldb07de02002-04-19 00:23:08 +0000244 if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p))
Brian Paul86b84272001-12-14 02:50:01 +0000245 return;
Gareth Hughes22144ab2001-03-12 00:48:37 +0000246
Brian Paul86b84272001-12-14 02:50:01 +0000247 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
jtgafb833d1999-08-19 00:55:39 +0000248
Brian Paul86b84272001-12-14 02:50:01 +0000249 if (state) {
Brian Paul103bc0f2002-03-29 17:27:59 +0000250 ctx->Transform.ClipPlanesEnabled |= (1 << p);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000251
Brian Paul049e3202005-06-30 14:22:23 +0000252 if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
Brian Paul30f51ae2001-12-18 04:06:44 +0000253 _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
Gareth Hughes22144ab2001-03-12 00:48:37 +0000254
Brian Paul86b84272001-12-14 02:50:01 +0000255 /* This derived state also calculated in clip.c and
256 * from _mesa_update_state() on changes to EyeUserPlane
257 * and ctx->ProjectionMatrix respectively.
258 */
259 _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
260 ctx->Transform.EyeUserPlane[p],
Brian Paul30f51ae2001-12-18 04:06:44 +0000261 ctx->ProjectionMatrixStack.Top->inv );
Brian Paul86b84272001-12-14 02:50:01 +0000262 }
Brian Paulf66de792002-03-28 22:45:45 +0000263 else {
Brian Paul103bc0f2002-03-29 17:27:59 +0000264 ctx->Transform.ClipPlanesEnabled &= ~(1 << p);
Brian Paulf66de792002-03-28 22:45:45 +0000265 }
Brian Paul86b84272001-12-14 02:50:01 +0000266 }
267 break;
Keith Whitwell6dc85572003-07-17 13:43:59 +0000268#endif
Brian Paul86b84272001-12-14 02:50:01 +0000269 case GL_COLOR_MATERIAL:
270 if (ctx->Light.ColorMaterialEnabled == state)
271 return;
272 FLUSH_VERTICES(ctx, _NEW_LIGHT);
Brian Pauld40f9fa2003-03-21 13:18:33 +0000273 FLUSH_CURRENT(ctx, 0);
Brian Paul86b84272001-12-14 02:50:01 +0000274 ctx->Light.ColorMaterialEnabled = state;
275 if (state) {
Brian Paul86b84272001-12-14 02:50:01 +0000276 _mesa_update_color_material( ctx,
277 ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
278 }
279 break;
280 case GL_CULL_FACE:
281 if (ctx->Polygon.CullFlag == state)
282 return;
283 FLUSH_VERTICES(ctx, _NEW_POLYGON);
284 ctx->Polygon.CullFlag = state;
285 break;
Keith Whitwell352d4db2004-05-10 18:16:03 +0000286 case GL_CULL_VERTEX_EXT:
287 CHECK_EXTENSION(EXT_cull_vertex, cap);
288 if (ctx->Transform.CullVertexFlag == state)
289 return;
290 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
291 ctx->Transform.CullVertexFlag = state;
292 break;
Brian Paul86b84272001-12-14 02:50:01 +0000293 case GL_DEPTH_TEST:
Brian Paule4b23562005-05-04 20:11:35 +0000294 if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
Brian Paul86b84272001-12-14 02:50:01 +0000295 _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
296 return;
297 }
Brian8dcfcad72006-12-13 15:31:14 -0700298 if (ctx->Depth.Test == state)
Brian Paul86b84272001-12-14 02:50:01 +0000299 return;
300 FLUSH_VERTICES(ctx, _NEW_DEPTH);
301 ctx->Depth.Test = state;
302 break;
303 case GL_DITHER:
304 if (ctx->NoDither) {
305 state = GL_FALSE; /* MESA_NO_DITHER env var */
306 }
Brian8dcfcad72006-12-13 15:31:14 -0700307 if (ctx->Color.DitherFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000308 return;
309 FLUSH_VERTICES(ctx, _NEW_COLOR);
310 ctx->Color.DitherFlag = state;
311 break;
312 case GL_FOG:
Brian8dcfcad72006-12-13 15:31:14 -0700313 if (ctx->Fog.Enabled == state)
Brian Paul86b84272001-12-14 02:50:01 +0000314 return;
315 FLUSH_VERTICES(ctx, _NEW_FOG);
316 ctx->Fog.Enabled = state;
317 break;
318 case GL_HISTOGRAM:
Brian Paul02c03ef2002-06-18 16:53:46 +0000319 CHECK_EXTENSION(EXT_histogram, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000320 if (ctx->Pixel.HistogramEnabled == state)
321 return;
322 FLUSH_VERTICES(ctx, _NEW_PIXEL);
323 ctx->Pixel.HistogramEnabled = state;
324 break;
325 case GL_LIGHT0:
326 case GL_LIGHT1:
327 case GL_LIGHT2:
328 case GL_LIGHT3:
329 case GL_LIGHT4:
330 case GL_LIGHT5:
331 case GL_LIGHT6:
332 case GL_LIGHT7:
333 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state)
334 return;
335 FLUSH_VERTICES(ctx, _NEW_LIGHT);
336 ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
337 if (state) {
338 insert_at_tail(&ctx->Light.EnabledList,
339 &ctx->Light.Light[cap-GL_LIGHT0]);
340 }
341 else {
342 remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
343 }
344 break;
345 case GL_LIGHTING:
346 if (ctx->Light.Enabled == state)
347 return;
348 FLUSH_VERTICES(ctx, _NEW_LIGHT);
349 ctx->Light.Enabled = state;
Brian Paul86b84272001-12-14 02:50:01 +0000350 break;
351 case GL_LINE_SMOOTH:
352 if (ctx->Line.SmoothFlag == state)
353 return;
354 FLUSH_VERTICES(ctx, _NEW_LINE);
355 ctx->Line.SmoothFlag = state;
Brian Paul86b84272001-12-14 02:50:01 +0000356 break;
357 case GL_LINE_STIPPLE:
358 if (ctx->Line.StippleFlag == state)
359 return;
360 FLUSH_VERTICES(ctx, _NEW_LINE);
361 ctx->Line.StippleFlag = state;
Brian Paul86b84272001-12-14 02:50:01 +0000362 break;
363 case GL_INDEX_LOGIC_OP:
364 if (ctx->Color.IndexLogicOpEnabled == state)
365 return;
366 FLUSH_VERTICES(ctx, _NEW_COLOR);
367 ctx->Color.IndexLogicOpEnabled = state;
368 break;
369 case GL_COLOR_LOGIC_OP:
370 if (ctx->Color.ColorLogicOpEnabled == state)
371 return;
372 FLUSH_VERTICES(ctx, _NEW_COLOR);
373 ctx->Color.ColorLogicOpEnabled = state;
374 break;
375 case GL_MAP1_COLOR_4:
376 if (ctx->Eval.Map1Color4 == state)
377 return;
378 FLUSH_VERTICES(ctx, _NEW_EVAL);
379 ctx->Eval.Map1Color4 = state;
380 break;
381 case GL_MAP1_INDEX:
382 if (ctx->Eval.Map1Index == state)
383 return;
384 FLUSH_VERTICES(ctx, _NEW_EVAL);
385 ctx->Eval.Map1Index = state;
386 break;
387 case GL_MAP1_NORMAL:
388 if (ctx->Eval.Map1Normal == state)
389 return;
390 FLUSH_VERTICES(ctx, _NEW_EVAL);
391 ctx->Eval.Map1Normal = state;
392 break;
393 case GL_MAP1_TEXTURE_COORD_1:
394 if (ctx->Eval.Map1TextureCoord1 == state)
395 return;
396 FLUSH_VERTICES(ctx, _NEW_EVAL);
397 ctx->Eval.Map1TextureCoord1 = state;
398 break;
399 case GL_MAP1_TEXTURE_COORD_2:
400 if (ctx->Eval.Map1TextureCoord2 == state)
401 return;
402 FLUSH_VERTICES(ctx, _NEW_EVAL);
403 ctx->Eval.Map1TextureCoord2 = state;
404 break;
405 case GL_MAP1_TEXTURE_COORD_3:
406 if (ctx->Eval.Map1TextureCoord3 == state)
407 return;
408 FLUSH_VERTICES(ctx, _NEW_EVAL);
409 ctx->Eval.Map1TextureCoord3 = state;
410 break;
411 case GL_MAP1_TEXTURE_COORD_4:
412 if (ctx->Eval.Map1TextureCoord4 == state)
413 return;
414 FLUSH_VERTICES(ctx, _NEW_EVAL);
415 ctx->Eval.Map1TextureCoord4 = state;
416 break;
417 case GL_MAP1_VERTEX_3:
418 if (ctx->Eval.Map1Vertex3 == state)
419 return;
420 FLUSH_VERTICES(ctx, _NEW_EVAL);
421 ctx->Eval.Map1Vertex3 = state;
422 break;
423 case GL_MAP1_VERTEX_4:
424 if (ctx->Eval.Map1Vertex4 == state)
425 return;
426 FLUSH_VERTICES(ctx, _NEW_EVAL);
427 ctx->Eval.Map1Vertex4 = state;
428 break;
429 case GL_MAP2_COLOR_4:
430 if (ctx->Eval.Map2Color4 == state)
431 return;
432 FLUSH_VERTICES(ctx, _NEW_EVAL);
433 ctx->Eval.Map2Color4 = state;
434 break;
435 case GL_MAP2_INDEX:
436 if (ctx->Eval.Map2Index == state)
437 return;
438 FLUSH_VERTICES(ctx, _NEW_EVAL);
439 ctx->Eval.Map2Index = state;
440 break;
441 case GL_MAP2_NORMAL:
442 if (ctx->Eval.Map2Normal == state)
443 return;
444 FLUSH_VERTICES(ctx, _NEW_EVAL);
445 ctx->Eval.Map2Normal = state;
446 break;
447 case GL_MAP2_TEXTURE_COORD_1:
448 if (ctx->Eval.Map2TextureCoord1 == state)
449 return;
450 FLUSH_VERTICES(ctx, _NEW_EVAL);
451 ctx->Eval.Map2TextureCoord1 = state;
452 break;
453 case GL_MAP2_TEXTURE_COORD_2:
454 if (ctx->Eval.Map2TextureCoord2 == state)
455 return;
456 FLUSH_VERTICES(ctx, _NEW_EVAL);
457 ctx->Eval.Map2TextureCoord2 = state;
458 break;
459 case GL_MAP2_TEXTURE_COORD_3:
460 if (ctx->Eval.Map2TextureCoord3 == state)
461 return;
462 FLUSH_VERTICES(ctx, _NEW_EVAL);
463 ctx->Eval.Map2TextureCoord3 = state;
464 break;
465 case GL_MAP2_TEXTURE_COORD_4:
466 if (ctx->Eval.Map2TextureCoord4 == state)
467 return;
468 FLUSH_VERTICES(ctx, _NEW_EVAL);
469 ctx->Eval.Map2TextureCoord4 = state;
470 break;
471 case GL_MAP2_VERTEX_3:
472 if (ctx->Eval.Map2Vertex3 == state)
473 return;
474 FLUSH_VERTICES(ctx, _NEW_EVAL);
475 ctx->Eval.Map2Vertex3 = state;
476 break;
477 case GL_MAP2_VERTEX_4:
478 if (ctx->Eval.Map2Vertex4 == state)
479 return;
480 FLUSH_VERTICES(ctx, _NEW_EVAL);
481 ctx->Eval.Map2Vertex4 = state;
482 break;
483 case GL_MINMAX:
484 if (ctx->Pixel.MinMaxEnabled == state)
485 return;
486 FLUSH_VERTICES(ctx, _NEW_PIXEL);
487 ctx->Pixel.MinMaxEnabled = state;
488 break;
489 case GL_NORMALIZE:
490 if (ctx->Transform.Normalize == state)
491 return;
492 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
493 ctx->Transform.Normalize = state;
494 break;
495 case GL_POINT_SMOOTH:
Brian8dcfcad72006-12-13 15:31:14 -0700496 if (ctx->Point.SmoothFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000497 return;
498 FLUSH_VERTICES(ctx, _NEW_POINT);
499 ctx->Point.SmoothFlag = state;
Brian Paul86b84272001-12-14 02:50:01 +0000500 break;
501 case GL_POLYGON_SMOOTH:
Brian8dcfcad72006-12-13 15:31:14 -0700502 if (ctx->Polygon.SmoothFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000503 return;
504 FLUSH_VERTICES(ctx, _NEW_POLYGON);
505 ctx->Polygon.SmoothFlag = state;
Brian Paul86b84272001-12-14 02:50:01 +0000506 break;
507 case GL_POLYGON_STIPPLE:
Brian8dcfcad72006-12-13 15:31:14 -0700508 if (ctx->Polygon.StippleFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000509 return;
510 FLUSH_VERTICES(ctx, _NEW_POLYGON);
511 ctx->Polygon.StippleFlag = state;
Brian Paul86b84272001-12-14 02:50:01 +0000512 break;
513 case GL_POLYGON_OFFSET_POINT:
Brian8dcfcad72006-12-13 15:31:14 -0700514 if (ctx->Polygon.OffsetPoint == state)
Brian Paul86b84272001-12-14 02:50:01 +0000515 return;
516 FLUSH_VERTICES(ctx, _NEW_POLYGON);
517 ctx->Polygon.OffsetPoint = state;
518 break;
519 case GL_POLYGON_OFFSET_LINE:
Brian8dcfcad72006-12-13 15:31:14 -0700520 if (ctx->Polygon.OffsetLine == state)
Brian Paul86b84272001-12-14 02:50:01 +0000521 return;
522 FLUSH_VERTICES(ctx, _NEW_POLYGON);
523 ctx->Polygon.OffsetLine = state;
524 break;
525 case GL_POLYGON_OFFSET_FILL:
526 /*case GL_POLYGON_OFFSET_EXT:*/
Brian8dcfcad72006-12-13 15:31:14 -0700527 if (ctx->Polygon.OffsetFill == state)
Brian Paul86b84272001-12-14 02:50:01 +0000528 return;
529 FLUSH_VERTICES(ctx, _NEW_POLYGON);
530 ctx->Polygon.OffsetFill = state;
531 break;
532 case GL_RESCALE_NORMAL_EXT:
533 if (ctx->Transform.RescaleNormals == state)
534 return;
535 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
536 ctx->Transform.RescaleNormals = state;
537 break;
538 case GL_SCISSOR_TEST:
Brian8dcfcad72006-12-13 15:31:14 -0700539 if (ctx->Scissor.Enabled == state)
Brian Paul86b84272001-12-14 02:50:01 +0000540 return;
541 FLUSH_VERTICES(ctx, _NEW_SCISSOR);
542 ctx->Scissor.Enabled = state;
543 break;
544 case GL_SHARED_TEXTURE_PALETTE_EXT:
545 if (ctx->Texture.SharedPalette == state)
546 return;
547 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
548 ctx->Texture.SharedPalette = state;
549 break;
550 case GL_STENCIL_TEST:
Brian Paule4b23562005-05-04 20:11:35 +0000551 if (state && ctx->DrawBuffer->Visual.stencilBits == 0) {
Brian Paul86b84272001-12-14 02:50:01 +0000552 _mesa_warning(ctx,
553 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
554 return;
555 }
Brian8dcfcad72006-12-13 15:31:14 -0700556 if (ctx->Stencil.Enabled == state)
Brian Paul86b84272001-12-14 02:50:01 +0000557 return;
558 FLUSH_VERTICES(ctx, _NEW_STENCIL);
559 ctx->Stencil.Enabled = state;
560 break;
561 case GL_TEXTURE_1D: {
562 const GLuint curr = ctx->Texture.CurrentUnit;
563 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Brian Paul8afe7de2002-06-15 03:03:06 +0000564 GLuint newenabled = texUnit->Enabled & ~TEXTURE_1D_BIT;
Brian Paul86b84272001-12-14 02:50:01 +0000565 if (state)
Brian Paul8afe7de2002-06-15 03:03:06 +0000566 newenabled |= TEXTURE_1D_BIT;
Brian Paule4b23562005-05-04 20:11:35 +0000567 if (!ctx->DrawBuffer->Visual.rgbMode
568 || texUnit->Enabled == newenabled)
Brian Paul86b84272001-12-14 02:50:01 +0000569 return;
570 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
571 texUnit->Enabled = newenabled;
572 break;
Gareth Hughes22144ab2001-03-12 00:48:37 +0000573 }
Brian Paul86b84272001-12-14 02:50:01 +0000574 case GL_TEXTURE_2D: {
575 const GLuint curr = ctx->Texture.CurrentUnit;
576 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Brian Paul8afe7de2002-06-15 03:03:06 +0000577 GLuint newenabled = texUnit->Enabled & ~TEXTURE_2D_BIT;
Brian Paul86b84272001-12-14 02:50:01 +0000578 if (state)
Brian Paul8afe7de2002-06-15 03:03:06 +0000579 newenabled |= TEXTURE_2D_BIT;
Brian Paule4b23562005-05-04 20:11:35 +0000580 if (!ctx->DrawBuffer->Visual.rgbMode
581 || texUnit->Enabled == newenabled)
Brian Paul86b84272001-12-14 02:50:01 +0000582 return;
583 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
584 texUnit->Enabled = newenabled;
585 break;
586 }
587 case GL_TEXTURE_3D: {
588 const GLuint curr = ctx->Texture.CurrentUnit;
589 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Brian Paul8afe7de2002-06-15 03:03:06 +0000590 GLuint newenabled = texUnit->Enabled & ~TEXTURE_3D_BIT;
Brian Paul86b84272001-12-14 02:50:01 +0000591 if (state)
Brian Paul8afe7de2002-06-15 03:03:06 +0000592 newenabled |= TEXTURE_3D_BIT;
Brian Paule4b23562005-05-04 20:11:35 +0000593 if (!ctx->DrawBuffer->Visual.rgbMode
594 || texUnit->Enabled == newenabled)
Brian Paul86b84272001-12-14 02:50:01 +0000595 return;
596 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
597 texUnit->Enabled = newenabled;
598 break;
599 }
600 case GL_TEXTURE_GEN_Q: {
601 GLuint unit = ctx->Texture.CurrentUnit;
602 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
603 GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
604 if (state)
605 newenabled |= Q_BIT;
606 if (texUnit->TexGenEnabled == newenabled)
607 return;
608 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
609 texUnit->TexGenEnabled = newenabled;
610 break;
611 }
612 case GL_TEXTURE_GEN_R: {
613 GLuint unit = ctx->Texture.CurrentUnit;
614 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
615 GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
616 if (state)
617 newenabled |= R_BIT;
618 if (texUnit->TexGenEnabled == newenabled)
619 return;
620 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
621 texUnit->TexGenEnabled = newenabled;
622 break;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000623 }
Brian Paul86b84272001-12-14 02:50:01 +0000624 case GL_TEXTURE_GEN_S: {
625 GLuint unit = ctx->Texture.CurrentUnit;
626 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
627 GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
628 if (state)
629 newenabled |= S_BIT;
630 if (texUnit->TexGenEnabled == newenabled)
631 return;
632 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
633 texUnit->TexGenEnabled = newenabled;
634 break;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000635 }
Brian Paul86b84272001-12-14 02:50:01 +0000636 case GL_TEXTURE_GEN_T: {
637 GLuint unit = ctx->Texture.CurrentUnit;
638 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
639 GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
640 if (state)
641 newenabled |= T_BIT;
642 if (texUnit->TexGenEnabled == newenabled)
643 return;
644 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
645 texUnit->TexGenEnabled = newenabled;
646 break;
647 }
Keith Whitwell46b09882001-02-16 18:14:41 +0000648
Brian Paul86b84272001-12-14 02:50:01 +0000649 /*
650 * CLIENT STATE!!!
651 */
652 case GL_VERTEX_ARRAY:
653 case GL_NORMAL_ARRAY:
654 case GL_COLOR_ARRAY:
655 case GL_INDEX_ARRAY:
656 case GL_TEXTURE_COORD_ARRAY:
657 case GL_EDGE_FLAG_ARRAY:
658 case GL_FOG_COORDINATE_ARRAY_EXT:
659 case GL_SECONDARY_COLOR_ARRAY_EXT:
660 client_state( ctx, cap, state );
661 return;
jtgafb833d1999-08-19 00:55:39 +0000662
Brian Paul13811372000-04-12 00:27:37 +0000663 /* GL_SGI_color_table */
Brian Paul86b84272001-12-14 02:50:01 +0000664 case GL_COLOR_TABLE_SGI:
Brian Paul02c03ef2002-06-18 16:53:46 +0000665 CHECK_EXTENSION(SGI_color_table, cap);
Brian7573b582007-03-16 09:36:12 -0600666 if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] == state)
Brian Paul86b84272001-12-14 02:50:01 +0000667 return;
668 FLUSH_VERTICES(ctx, _NEW_PIXEL);
Brian7573b582007-03-16 09:36:12 -0600669 ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] = state;
Brian Paul86b84272001-12-14 02:50:01 +0000670 break;
671 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
Brian Paul02c03ef2002-06-18 16:53:46 +0000672 CHECK_EXTENSION(SGI_color_table, cap);
Brian7573b582007-03-16 09:36:12 -0600673 if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] == state)
Brian Paul86b84272001-12-14 02:50:01 +0000674 return;
675 FLUSH_VERTICES(ctx, _NEW_PIXEL);
Brian7573b582007-03-16 09:36:12 -0600676 ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] = state;
Brian Paul86b84272001-12-14 02:50:01 +0000677 break;
678 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
Brian Paul02c03ef2002-06-18 16:53:46 +0000679 CHECK_EXTENSION(SGI_color_table, cap);
Brian7573b582007-03-16 09:36:12 -0600680 if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] == state)
Brian Paul86b84272001-12-14 02:50:01 +0000681 return;
682 FLUSH_VERTICES(ctx, _NEW_PIXEL);
Brian7573b582007-03-16 09:36:12 -0600683 ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] = state;
Brian Paul86b84272001-12-14 02:50:01 +0000684 break;
Brian Paul418ac002003-01-21 21:47:45 +0000685 case GL_TEXTURE_COLOR_TABLE_SGI:
686 CHECK_EXTENSION(SGI_texture_color_table, cap);
Brian Paul45b47d02003-01-26 14:37:15 +0000687 if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state)
Brian Paul418ac002003-01-21 21:47:45 +0000688 return;
689 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
Brian Paul45b47d02003-01-26 14:37:15 +0000690 ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state;
Brian Paul418ac002003-01-21 21:47:45 +0000691 break;
Brian Paul13811372000-04-12 00:27:37 +0000692
Brian Paul82b02f02000-05-07 20:37:40 +0000693 /* GL_EXT_convolution */
Brian Paul86b84272001-12-14 02:50:01 +0000694 case GL_CONVOLUTION_1D:
Brian Paul02c03ef2002-06-18 16:53:46 +0000695 CHECK_EXTENSION(EXT_convolution, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000696 if (ctx->Pixel.Convolution1DEnabled == state)
697 return;
698 FLUSH_VERTICES(ctx, _NEW_PIXEL);
699 ctx->Pixel.Convolution1DEnabled = state;
700 break;
701 case GL_CONVOLUTION_2D:
Brian Paul02c03ef2002-06-18 16:53:46 +0000702 CHECK_EXTENSION(EXT_convolution, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000703 if (ctx->Pixel.Convolution2DEnabled == state)
704 return;
705 FLUSH_VERTICES(ctx, _NEW_PIXEL);
706 ctx->Pixel.Convolution2DEnabled = state;
707 break;
708 case GL_SEPARABLE_2D:
Brian Paul02c03ef2002-06-18 16:53:46 +0000709 CHECK_EXTENSION(EXT_convolution, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000710 if (ctx->Pixel.Separable2DEnabled == state)
711 return;
712 FLUSH_VERTICES(ctx, _NEW_PIXEL);
713 ctx->Pixel.Separable2DEnabled = state;
714 break;
Brian Paul82b02f02000-05-07 20:37:40 +0000715
Brian Paul86fc3702000-05-22 16:33:20 +0000716 /* GL_ARB_texture_cube_map */
Brian Paul86b84272001-12-14 02:50:01 +0000717 case GL_TEXTURE_CUBE_MAP_ARB:
718 {
719 const GLuint curr = ctx->Texture.CurrentUnit;
720 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Brian Paul8afe7de2002-06-15 03:03:06 +0000721 GLuint newenabled = texUnit->Enabled & ~TEXTURE_CUBE_BIT;
Brian Paul02c03ef2002-06-18 16:53:46 +0000722 CHECK_EXTENSION(ARB_texture_cube_map, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000723 if (state)
Brian Paul8afe7de2002-06-15 03:03:06 +0000724 newenabled |= TEXTURE_CUBE_BIT;
Brian Paule4b23562005-05-04 20:11:35 +0000725 if (!ctx->DrawBuffer->Visual.rgbMode
726 || texUnit->Enabled == newenabled)
Brian Paul86b84272001-12-14 02:50:01 +0000727 return;
728 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
729 texUnit->Enabled = newenabled;
730 }
731 break;
732
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000733 /* GL_EXT_secondary_color */
Brian Paul86b84272001-12-14 02:50:01 +0000734 case GL_COLOR_SUM_EXT:
Roland Scheideggerda168132006-03-02 12:06:57 +0000735 CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000736 if (ctx->Fog.ColorSumEnabled == state)
737 return;
738 FLUSH_VERTICES(ctx, _NEW_FOG);
739 ctx->Fog.ColorSumEnabled = state;
Brian Paul86b84272001-12-14 02:50:01 +0000740 break;
Brian Paul06d05af2000-12-08 00:20:15 +0000741
Brian Paul736fcbe2001-05-29 15:23:48 +0000742 /* GL_ARB_multisample */
Brian Paul86b84272001-12-14 02:50:01 +0000743 case GL_MULTISAMPLE_ARB:
Brian Paul02c03ef2002-06-18 16:53:46 +0000744 CHECK_EXTENSION(ARB_multisample, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000745 if (ctx->Multisample.Enabled == state)
746 return;
747 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
748 ctx->Multisample.Enabled = state;
749 break;
750 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
Brian Paul02c03ef2002-06-18 16:53:46 +0000751 CHECK_EXTENSION(ARB_multisample, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000752 if (ctx->Multisample.SampleAlphaToCoverage == state)
753 return;
754 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
755 ctx->Multisample.SampleAlphaToCoverage = state;
756 break;
757 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
Brian Paul02c03ef2002-06-18 16:53:46 +0000758 CHECK_EXTENSION(ARB_multisample, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000759 if (ctx->Multisample.SampleAlphaToOne == state)
760 return;
761 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
762 ctx->Multisample.SampleAlphaToOne = state;
763 break;
764 case GL_SAMPLE_COVERAGE_ARB:
Brian Paul02c03ef2002-06-18 16:53:46 +0000765 CHECK_EXTENSION(ARB_multisample, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000766 if (ctx->Multisample.SampleCoverage == state)
767 return;
768 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
769 ctx->Multisample.SampleCoverage = state;
770 break;
771 case GL_SAMPLE_COVERAGE_INVERT_ARB:
Brian Paul02c03ef2002-06-18 16:53:46 +0000772 CHECK_EXTENSION(ARB_multisample, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000773 if (ctx->Multisample.SampleCoverageInvert == state)
774 return;
775 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
776 ctx->Multisample.SampleCoverageInvert = state;
777 break;
Brian Paul8c2f6c52001-06-26 01:32:48 +0000778
779 /* GL_IBM_rasterpos_clip */
Brian Paul86b84272001-12-14 02:50:01 +0000780 case GL_RASTER_POSITION_UNCLIPPED_IBM:
Brian Paul02c03ef2002-06-18 16:53:46 +0000781 CHECK_EXTENSION(IBM_rasterpos_clip, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000782 if (ctx->Transform.RasterPositionUnclipped == state)
783 return;
784 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
785 ctx->Transform.RasterPositionUnclipped = state;
786 break;
Brian Paul736fcbe2001-05-29 15:23:48 +0000787
Brian Paul6c408b42002-05-27 17:04:52 +0000788 /* GL_NV_point_sprite */
789 case GL_POINT_SPRITE_NV:
Ian Romanick63736722003-08-23 00:12:46 +0000790 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap);
Brian Paul6c408b42002-05-27 17:04:52 +0000791 if (ctx->Point.PointSprite == state)
Brian Paul86b84272001-12-14 02:50:01 +0000792 return;
793 FLUSH_VERTICES(ctx, _NEW_POINT);
Brian Paul6c408b42002-05-27 17:04:52 +0000794 ctx->Point.PointSprite = state;
Brian Paul86b84272001-12-14 02:50:01 +0000795 break;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000796
Roland Scheidegger93da6732006-03-01 23:11:14 +0000797#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
Roland Scheideggere1e03b32006-03-03 15:03:04 +0000798 case GL_VERTEX_PROGRAM_ARB:
799 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000800 if (ctx->VertexProgram.Enabled == state)
801 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000802 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul86b84272001-12-14 02:50:01 +0000803 ctx->VertexProgram.Enabled = state;
804 break;
Roland Scheideggere1e03b32006-03-03 15:03:04 +0000805 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
806 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000807 if (ctx->VertexProgram.PointSizeEnabled == state)
808 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000809 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul86b84272001-12-14 02:50:01 +0000810 ctx->VertexProgram.PointSizeEnabled = state;
811 break;
Roland Scheideggere1e03b32006-03-03 15:03:04 +0000812 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB:
813 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000814 if (ctx->VertexProgram.TwoSideEnabled == state)
815 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000816 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul86b84272001-12-14 02:50:01 +0000817 ctx->VertexProgram.TwoSideEnabled = state;
818 break;
Roland Scheidegger93da6732006-03-01 23:11:14 +0000819#endif
820#if FEATURE_NV_vertex_program
Brian Paul86b84272001-12-14 02:50:01 +0000821 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
822 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
823 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
824 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
825 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
826 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
827 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
828 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
829 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
830 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
831 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
832 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
833 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
834 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
835 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
836 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
Brian Paul02c03ef2002-06-18 16:53:46 +0000837 CHECK_EXTENSION(NV_vertex_program, cap);
Brian Paulbc42c192002-01-05 21:53:20 +0000838 {
839 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
840 FLUSH_VERTICES(ctx, _NEW_EVAL);
841 ctx->Eval.Map1Attrib[map] = state;
842 }
Brian Paul86b84272001-12-14 02:50:01 +0000843 break;
844 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
845 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
846 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
847 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
848 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
849 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
850 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
851 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
852 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
853 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
854 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
855 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
856 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
857 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
858 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
859 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
Brian Paul02c03ef2002-06-18 16:53:46 +0000860 CHECK_EXTENSION(NV_vertex_program, cap);
Brian Paulbc42c192002-01-05 21:53:20 +0000861 {
862 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
863 FLUSH_VERTICES(ctx, _NEW_EVAL);
864 ctx->Eval.Map2Attrib[map] = state;
865 }
Brian Paul86b84272001-12-14 02:50:01 +0000866 break;
Brian Paul8dfc5b92002-10-16 17:57:51 +0000867#endif /* FEATURE_NV_vertex_program */
Brian Paul86b84272001-12-14 02:50:01 +0000868
Brian Paul610d5992003-01-14 04:55:45 +0000869#if FEATURE_NV_fragment_program
870 case GL_FRAGMENT_PROGRAM_NV:
871 CHECK_EXTENSION(NV_fragment_program, cap);
872 if (ctx->FragmentProgram.Enabled == state)
873 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000874 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul610d5992003-01-14 04:55:45 +0000875 ctx->FragmentProgram.Enabled = state;
876 break;
877#endif /* FEATURE_NV_fragment_program */
878
Brian Paul8afe7de2002-06-15 03:03:06 +0000879 /* GL_NV_texture_rectangle */
880 case GL_TEXTURE_RECTANGLE_NV:
Brian Paul5f60a0b2002-09-06 02:56:08 +0000881 CHECK_EXTENSION(NV_texture_rectangle, cap);
Brian Paul8afe7de2002-06-15 03:03:06 +0000882 {
883 const GLuint curr = ctx->Texture.CurrentUnit;
884 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
885 GLuint newenabled = texUnit->Enabled & ~TEXTURE_RECT_BIT;
Brian Paul02c03ef2002-06-18 16:53:46 +0000886 CHECK_EXTENSION(NV_texture_rectangle, cap);
Brian Paul8afe7de2002-06-15 03:03:06 +0000887 if (state)
888 newenabled |= TEXTURE_RECT_BIT;
Brian Paule4b23562005-05-04 20:11:35 +0000889 if (!ctx->DrawBuffer->Visual.rgbMode
890 || texUnit->Enabled == newenabled)
Brian Paul8afe7de2002-06-15 03:03:06 +0000891 return;
892 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
893 texUnit->Enabled = newenabled;
894 }
895 break;
896
Brian Paul5f60a0b2002-09-06 02:56:08 +0000897 /* GL_EXT_stencil_two_side */
898 case GL_STENCIL_TEST_TWO_SIDE_EXT:
899 CHECK_EXTENSION(EXT_stencil_two_side, cap);
900 if (ctx->Stencil.TestTwoSide == state)
901 return;
902 FLUSH_VERTICES(ctx, _NEW_STENCIL);
903 ctx->Stencil.TestTwoSide = state;
904 break;
905
Brian Paul77eec612003-04-18 01:56:11 +0000906#if FEATURE_ARB_fragment_program
907 case GL_FRAGMENT_PROGRAM_ARB:
908 CHECK_EXTENSION(ARB_fragment_program, cap);
909 if (ctx->FragmentProgram.Enabled == state)
910 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000911 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul77eec612003-04-18 01:56:11 +0000912 ctx->FragmentProgram.Enabled = state;
913 break;
914#endif /* FEATURE_ARB_fragment_program */
915
Brian Paule5b244f2003-04-21 15:02:17 +0000916 /* GL_EXT_depth_bounds_test */
917 case GL_DEPTH_BOUNDS_TEST_EXT:
918 CHECK_EXTENSION(EXT_depth_bounds_test, cap);
Brian Paule4b23562005-05-04 20:11:35 +0000919 if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
Brian Paule5b244f2003-04-21 15:02:17 +0000920 _mesa_warning(ctx,
921 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
922 return;
923 }
924 if (ctx->Depth.BoundsTest == state)
925 return;
926 FLUSH_VERTICES(ctx, _NEW_DEPTH);
927 ctx->Depth.BoundsTest = state;
928 break;
929
Brian Paul08ff0592003-07-21 04:22:40 +0000930 /* GL_MESA_program_debug */
931 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
932 CHECK_EXTENSION(MESA_program_debug, cap);
933 ctx->FragmentProgram.CallbackEnabled = state;
934 break;
935 case GL_VERTEX_PROGRAM_CALLBACK_MESA:
936 CHECK_EXTENSION(MESA_program_debug, cap);
937 ctx->VertexProgram.CallbackEnabled = state;
938 break;
939
Dave Airlie7f752fe2004-12-19 03:06:59 +0000940#if FEATURE_ATI_fragment_shader
941 case GL_FRAGMENT_SHADER_ATI:
942 CHECK_EXTENSION(ATI_fragment_shader, cap);
943 if (ctx->ATIFragmentShader.Enabled == state)
944 return;
945 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
946 ctx->ATIFragmentShader.Enabled = state;
947 break;
948#endif
Brian Paul86b84272001-12-14 02:50:01 +0000949 default:
Brian Paul4e9676f2002-06-29 19:48:15 +0000950 _mesa_error(ctx, GL_INVALID_ENUM,
951 "%s(0x%x)", state ? "glEnable" : "glDisable", cap);
Brian Paul86b84272001-12-14 02:50:01 +0000952 return;
jtgafb833d1999-08-19 00:55:39 +0000953 }
954
955 if (ctx->Driver.Enable) {
Brian8dcfcad72006-12-13 15:31:14 -0700956 ctx->Driver.Enable( ctx, cap, state );
jtgafb833d1999-08-19 00:55:39 +0000957 }
958}
959
960
Keith Whitwell6dc85572003-07-17 13:43:59 +0000961/**
Brian8dcfcad72006-12-13 15:31:14 -0700962 * Enable GL capability. Called by glEnable()
963 * \param cap state to enable.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000964 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000965void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000966_mesa_Enable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000967{
Brian Paulfbd8f211999-11-11 01:22:25 +0000968 GET_CURRENT_CONTEXT(ctx);
Keith Whitwell376d0222000-12-27 22:52:45 +0000969 ASSERT_OUTSIDE_BEGIN_END(ctx);
970
Brian Paulfbd8f211999-11-11 01:22:25 +0000971 _mesa_set_enable( ctx, cap, GL_TRUE );
jtgafb833d1999-08-19 00:55:39 +0000972}
973
974
Keith Whitwell6dc85572003-07-17 13:43:59 +0000975/**
Brian8dcfcad72006-12-13 15:31:14 -0700976 * Disable GL capability. Called by glDisable()
977 * \param cap state to disable.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000978 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000979void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000980_mesa_Disable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000981{
Brian Paulfbd8f211999-11-11 01:22:25 +0000982 GET_CURRENT_CONTEXT(ctx);
Keith Whitwell376d0222000-12-27 22:52:45 +0000983 ASSERT_OUTSIDE_BEGIN_END(ctx);
984
Brian Paulfbd8f211999-11-11 01:22:25 +0000985 _mesa_set_enable( ctx, cap, GL_FALSE );
jtgafb833d1999-08-19 00:55:39 +0000986}
987
988
Brian Paul86b84272001-12-14 02:50:01 +0000989#undef CHECK_EXTENSION
990#define CHECK_EXTENSION(EXTNAME) \
991 if (!ctx->Extensions.EXTNAME) { \
992 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
993 return GL_FALSE; \
994 }
995
Roland Scheideggerda168132006-03-02 12:06:57 +0000996#undef CHECK_EXTENSION2
997#define CHECK_EXTENSION2(EXT1, EXT2) \
998 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
999 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1000 return GL_FALSE; \
1001 }
jtgafb833d1999-08-19 00:55:39 +00001002
Brian8dcfcad72006-12-13 15:31:14 -07001003
Keith Whitwell6dc85572003-07-17 13:43:59 +00001004/**
Brian8dcfcad72006-12-13 15:31:14 -07001005 * Return simple enable/disable state.
Keith Whitwell6dc85572003-07-17 13:43:59 +00001006 *
Brian8dcfcad72006-12-13 15:31:14 -07001007 * \param cap state variable to query.
Keith Whitwell6dc85572003-07-17 13:43:59 +00001008 *
1009 * Returns the state of the specified capability from the current GL context.
1010 * For the capabilities associated with extensions verifies that those
1011 * extensions are effectively present before reporting.
1012 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +00001013GLboolean GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +00001014_mesa_IsEnabled( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +00001015{
Brian Paulfbd8f211999-11-11 01:22:25 +00001016 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +00001017 switch (cap) {
1018 case GL_ALPHA_TEST:
1019 return ctx->Color.AlphaEnabled;
1020 case GL_AUTO_NORMAL:
1021 return ctx->Eval.AutoNormal;
1022 case GL_BLEND:
1023 return ctx->Color.BlendEnabled;
1024 case GL_CLIP_PLANE0:
1025 case GL_CLIP_PLANE1:
1026 case GL_CLIP_PLANE2:
1027 case GL_CLIP_PLANE3:
1028 case GL_CLIP_PLANE4:
1029 case GL_CLIP_PLANE5:
Brian Paul103bc0f2002-03-29 17:27:59 +00001030 return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1;
jtgafb833d1999-08-19 00:55:39 +00001031 case GL_COLOR_MATERIAL:
1032 return ctx->Light.ColorMaterialEnabled;
1033 case GL_CULL_FACE:
1034 return ctx->Polygon.CullFlag;
1035 case GL_DEPTH_TEST:
1036 return ctx->Depth.Test;
1037 case GL_DITHER:
1038 return ctx->Color.DitherFlag;
1039 case GL_FOG:
1040 return ctx->Fog.Enabled;
1041 case GL_LIGHTING:
1042 return ctx->Light.Enabled;
1043 case GL_LIGHT0:
1044 case GL_LIGHT1:
1045 case GL_LIGHT2:
1046 case GL_LIGHT3:
1047 case GL_LIGHT4:
1048 case GL_LIGHT5:
1049 case GL_LIGHT6:
1050 case GL_LIGHT7:
1051 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
1052 case GL_LINE_SMOOTH:
1053 return ctx->Line.SmoothFlag;
1054 case GL_LINE_STIPPLE:
1055 return ctx->Line.StippleFlag;
1056 case GL_INDEX_LOGIC_OP:
1057 return ctx->Color.IndexLogicOpEnabled;
1058 case GL_COLOR_LOGIC_OP:
1059 return ctx->Color.ColorLogicOpEnabled;
1060 case GL_MAP1_COLOR_4:
1061 return ctx->Eval.Map1Color4;
1062 case GL_MAP1_INDEX:
1063 return ctx->Eval.Map1Index;
1064 case GL_MAP1_NORMAL:
1065 return ctx->Eval.Map1Normal;
1066 case GL_MAP1_TEXTURE_COORD_1:
1067 return ctx->Eval.Map1TextureCoord1;
1068 case GL_MAP1_TEXTURE_COORD_2:
1069 return ctx->Eval.Map1TextureCoord2;
1070 case GL_MAP1_TEXTURE_COORD_3:
1071 return ctx->Eval.Map1TextureCoord3;
1072 case GL_MAP1_TEXTURE_COORD_4:
1073 return ctx->Eval.Map1TextureCoord4;
1074 case GL_MAP1_VERTEX_3:
1075 return ctx->Eval.Map1Vertex3;
1076 case GL_MAP1_VERTEX_4:
1077 return ctx->Eval.Map1Vertex4;
1078 case GL_MAP2_COLOR_4:
1079 return ctx->Eval.Map2Color4;
1080 case GL_MAP2_INDEX:
1081 return ctx->Eval.Map2Index;
1082 case GL_MAP2_NORMAL:
1083 return ctx->Eval.Map2Normal;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001084 case GL_MAP2_TEXTURE_COORD_1:
jtgafb833d1999-08-19 00:55:39 +00001085 return ctx->Eval.Map2TextureCoord1;
1086 case GL_MAP2_TEXTURE_COORD_2:
1087 return ctx->Eval.Map2TextureCoord2;
1088 case GL_MAP2_TEXTURE_COORD_3:
1089 return ctx->Eval.Map2TextureCoord3;
1090 case GL_MAP2_TEXTURE_COORD_4:
1091 return ctx->Eval.Map2TextureCoord4;
1092 case GL_MAP2_VERTEX_3:
1093 return ctx->Eval.Map2Vertex3;
1094 case GL_MAP2_VERTEX_4:
1095 return ctx->Eval.Map2Vertex4;
1096 case GL_NORMALIZE:
1097 return ctx->Transform.Normalize;
1098 case GL_POINT_SMOOTH:
1099 return ctx->Point.SmoothFlag;
1100 case GL_POLYGON_SMOOTH:
1101 return ctx->Polygon.SmoothFlag;
1102 case GL_POLYGON_STIPPLE:
1103 return ctx->Polygon.StippleFlag;
1104 case GL_POLYGON_OFFSET_POINT:
1105 return ctx->Polygon.OffsetPoint;
1106 case GL_POLYGON_OFFSET_LINE:
1107 return ctx->Polygon.OffsetLine;
1108 case GL_POLYGON_OFFSET_FILL:
1109 /*case GL_POLYGON_OFFSET_EXT:*/
1110 return ctx->Polygon.OffsetFill;
1111 case GL_RESCALE_NORMAL_EXT:
1112 return ctx->Transform.RescaleNormals;
1113 case GL_SCISSOR_TEST:
1114 return ctx->Scissor.Enabled;
1115 case GL_SHARED_TEXTURE_PALETTE_EXT:
1116 return ctx->Texture.SharedPalette;
1117 case GL_STENCIL_TEST:
1118 return ctx->Stencil.Enabled;
1119 case GL_TEXTURE_1D:
1120 {
Brian Paul86b84272001-12-14 02:50:01 +00001121 const struct gl_texture_unit *texUnit;
1122 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
Brian Paul8afe7de2002-06-15 03:03:06 +00001123 return (texUnit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001124 }
1125 case GL_TEXTURE_2D:
1126 {
Brian Paul86b84272001-12-14 02:50:01 +00001127 const struct gl_texture_unit *texUnit;
1128 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
Brian Paul8afe7de2002-06-15 03:03:06 +00001129 return (texUnit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001130 }
1131 case GL_TEXTURE_3D:
1132 {
Brian Paul86b84272001-12-14 02:50:01 +00001133 const struct gl_texture_unit *texUnit;
1134 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
Brian Paul8afe7de2002-06-15 03:03:06 +00001135 return (texUnit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE;
jtgafb833d1999-08-19 00:55:39 +00001136 }
1137 case GL_TEXTURE_GEN_Q:
1138 {
Brian Paul86b84272001-12-14 02:50:01 +00001139 const struct gl_texture_unit *texUnit;
1140 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001141 return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
1142 }
1143 case GL_TEXTURE_GEN_R:
1144 {
Brian Paul86b84272001-12-14 02:50:01 +00001145 const struct gl_texture_unit *texUnit;
1146 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001147 return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
1148 }
1149 case GL_TEXTURE_GEN_S:
1150 {
Brian Paul86b84272001-12-14 02:50:01 +00001151 const struct gl_texture_unit *texUnit;
1152 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001153 return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
1154 }
1155 case GL_TEXTURE_GEN_T:
1156 {
Brian Paul86b84272001-12-14 02:50:01 +00001157 const struct gl_texture_unit *texUnit;
1158 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001159 return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
1160 }
1161
1162 /*
1163 * CLIENT STATE!!!
1164 */
1165 case GL_VERTEX_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001166 return (ctx->Array.ArrayObj->Vertex.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001167 case GL_NORMAL_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001168 return (ctx->Array.ArrayObj->Normal.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001169 case GL_COLOR_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001170 return (ctx->Array.ArrayObj->Color.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001171 case GL_INDEX_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001172 return (ctx->Array.ArrayObj->Index.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001173 case GL_TEXTURE_COORD_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001174 return (ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001175 case GL_EDGE_FLAG_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001176 return (ctx->Array.ArrayObj->EdgeFlag.Enabled != 0);
Brian Paul6ee7a022002-01-22 18:40:46 +00001177 case GL_FOG_COORDINATE_ARRAY_EXT:
1178 CHECK_EXTENSION(EXT_fog_coord);
Ian Romanickee34e6e2006-06-12 16:26:29 +00001179 return (ctx->Array.ArrayObj->FogCoord.Enabled != 0);
Brian Paul6ee7a022002-01-22 18:40:46 +00001180 case GL_SECONDARY_COLOR_ARRAY_EXT:
1181 CHECK_EXTENSION(EXT_secondary_color);
Ian Romanickee34e6e2006-06-12 16:26:29 +00001182 return (ctx->Array.ArrayObj->SecondaryColor.Enabled != 0);
Brian Paul1b2ff692000-03-11 23:23:26 +00001183
Brian Paul86b84272001-12-14 02:50:01 +00001184 /* GL_EXT_histogram */
1185 case GL_HISTOGRAM:
1186 CHECK_EXTENSION(EXT_histogram);
1187 return ctx->Pixel.HistogramEnabled;
1188 case GL_MINMAX:
1189 CHECK_EXTENSION(EXT_histogram);
1190 return ctx->Pixel.MinMaxEnabled;
1191
Brian Paul13811372000-04-12 00:27:37 +00001192 /* GL_SGI_color_table */
1193 case GL_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001194 CHECK_EXTENSION(SGI_color_table);
Brian7573b582007-03-16 09:36:12 -06001195 return ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION];
Brian Paul13811372000-04-12 00:27:37 +00001196 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001197 CHECK_EXTENSION(SGI_color_table);
Brian7573b582007-03-16 09:36:12 -06001198 return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION];
Brian Paul13811372000-04-12 00:27:37 +00001199 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001200 CHECK_EXTENSION(SGI_color_table);
Brian7573b582007-03-16 09:36:12 -06001201 return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX];
Brian Paul2b2e9252000-04-07 16:27:26 +00001202
Brian Paul45b47d02003-01-26 14:37:15 +00001203 /* GL_SGI_texture_color_table */
1204 case GL_TEXTURE_COLOR_TABLE_SGI:
1205 CHECK_EXTENSION(SGI_texture_color_table);
1206 return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled;
1207
Brian Paul82b02f02000-05-07 20:37:40 +00001208 /* GL_EXT_convolution */
1209 case GL_CONVOLUTION_1D:
Brian Paul86b84272001-12-14 02:50:01 +00001210 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001211 return ctx->Pixel.Convolution1DEnabled;
1212 case GL_CONVOLUTION_2D:
Brian Paul86b84272001-12-14 02:50:01 +00001213 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001214 return ctx->Pixel.Convolution2DEnabled;
1215 case GL_SEPARABLE_2D:
Brian Paul86b84272001-12-14 02:50:01 +00001216 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001217 return ctx->Pixel.Separable2DEnabled;
1218
Brian Paul86fc3702000-05-22 16:33:20 +00001219 /* GL_ARB_texture_cube_map */
1220 case GL_TEXTURE_CUBE_MAP_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001221 CHECK_EXTENSION(ARB_texture_cube_map);
1222 {
1223 const struct gl_texture_unit *texUnit;
1224 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
Brian Paul8afe7de2002-06-15 03:03:06 +00001225 return (texUnit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE;
Brian Paul86fc3702000-05-22 16:33:20 +00001226 }
Brian Paul86fc3702000-05-22 16:33:20 +00001227
Roland Scheideggerda168132006-03-02 12:06:57 +00001228 /* GL_EXT_secondary_color */
1229 case GL_COLOR_SUM_EXT:
1230 CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program);
1231 return ctx->Fog.ColorSumEnabled;
1232
Brian Paul736fcbe2001-05-29 15:23:48 +00001233 /* GL_ARB_multisample */
1234 case GL_MULTISAMPLE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001235 CHECK_EXTENSION(ARB_multisample);
1236 return ctx->Multisample.Enabled;
Brian Paul736fcbe2001-05-29 15:23:48 +00001237 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001238 CHECK_EXTENSION(ARB_multisample);
1239 return ctx->Multisample.SampleAlphaToCoverage;
Brian Paul736fcbe2001-05-29 15:23:48 +00001240 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001241 CHECK_EXTENSION(ARB_multisample);
1242 return ctx->Multisample.SampleAlphaToOne;
Brian Paul736fcbe2001-05-29 15:23:48 +00001243 case GL_SAMPLE_COVERAGE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001244 CHECK_EXTENSION(ARB_multisample);
1245 return ctx->Multisample.SampleCoverage;
Brian Paul736fcbe2001-05-29 15:23:48 +00001246 case GL_SAMPLE_COVERAGE_INVERT_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001247 CHECK_EXTENSION(ARB_multisample);
1248 return ctx->Multisample.SampleCoverageInvert;
Brian Paul736fcbe2001-05-29 15:23:48 +00001249
Brian Paul8c2f6c52001-06-26 01:32:48 +00001250 /* GL_IBM_rasterpos_clip */
1251 case GL_RASTER_POSITION_UNCLIPPED_IBM:
Brian Paul86b84272001-12-14 02:50:01 +00001252 CHECK_EXTENSION(IBM_rasterpos_clip);
1253 return ctx->Transform.RasterPositionUnclipped;
Brian Paul8c2f6c52001-06-26 01:32:48 +00001254
Brian Paul6c408b42002-05-27 17:04:52 +00001255 /* GL_NV_point_sprite */
1256 case GL_POINT_SPRITE_NV:
Roland Scheideggerda168132006-03-02 12:06:57 +00001257 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite)
Brian Paul6c408b42002-05-27 17:04:52 +00001258 return ctx->Point.PointSprite;
Brian Paul06d05af2000-12-08 00:20:15 +00001259
Roland Scheidegger93da6732006-03-01 23:11:14 +00001260#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
Roland Scheideggerda168132006-03-02 12:06:57 +00001261 case GL_VERTEX_PROGRAM_ARB:
1262 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
Brian Paul86b84272001-12-14 02:50:01 +00001263 return ctx->VertexProgram.Enabled;
Roland Scheideggerda168132006-03-02 12:06:57 +00001264 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
1265 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
Brian Paul86b84272001-12-14 02:50:01 +00001266 return ctx->VertexProgram.PointSizeEnabled;
Roland Scheideggerda168132006-03-02 12:06:57 +00001267 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB:
1268 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
Brian Paul86b84272001-12-14 02:50:01 +00001269 return ctx->VertexProgram.TwoSideEnabled;
Roland Scheidegger93da6732006-03-01 23:11:14 +00001270#endif
1271#if FEATURE_NV_vertex_program
Brian Paul86b84272001-12-14 02:50:01 +00001272 case GL_VERTEX_ATTRIB_ARRAY0_NV:
1273 case GL_VERTEX_ATTRIB_ARRAY1_NV:
1274 case GL_VERTEX_ATTRIB_ARRAY2_NV:
1275 case GL_VERTEX_ATTRIB_ARRAY3_NV:
1276 case GL_VERTEX_ATTRIB_ARRAY4_NV:
1277 case GL_VERTEX_ATTRIB_ARRAY5_NV:
1278 case GL_VERTEX_ATTRIB_ARRAY6_NV:
1279 case GL_VERTEX_ATTRIB_ARRAY7_NV:
1280 case GL_VERTEX_ATTRIB_ARRAY8_NV:
1281 case GL_VERTEX_ATTRIB_ARRAY9_NV:
1282 case GL_VERTEX_ATTRIB_ARRAY10_NV:
1283 case GL_VERTEX_ATTRIB_ARRAY11_NV:
1284 case GL_VERTEX_ATTRIB_ARRAY12_NV:
1285 case GL_VERTEX_ATTRIB_ARRAY13_NV:
1286 case GL_VERTEX_ATTRIB_ARRAY14_NV:
1287 case GL_VERTEX_ATTRIB_ARRAY15_NV:
1288 CHECK_EXTENSION(NV_vertex_program);
1289 {
1290 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
Ian Romanickee34e6e2006-06-12 16:26:29 +00001291 return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0);
Brian Paul86b84272001-12-14 02:50:01 +00001292 }
1293 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
1294 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
1295 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
1296 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
1297 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
1298 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
1299 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
1300 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
1301 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
1302 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
1303 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
1304 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
1305 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
1306 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
1307 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
1308 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
1309 CHECK_EXTENSION(NV_vertex_program);
Brian Paulbc42c192002-01-05 21:53:20 +00001310 {
1311 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
1312 return ctx->Eval.Map1Attrib[map];
1313 }
Brian Paul86b84272001-12-14 02:50:01 +00001314 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
1315 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
1316 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
1317 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
1318 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
1319 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
1320 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
1321 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
1322 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
1323 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
1324 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
1325 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
1326 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
1327 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
1328 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
1329 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
1330 CHECK_EXTENSION(NV_vertex_program);
Brian Paulbc42c192002-01-05 21:53:20 +00001331 {
1332 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
1333 return ctx->Eval.Map2Attrib[map];
1334 }
Brian Paul8dfc5b92002-10-16 17:57:51 +00001335#endif /* FEATURE_NV_vertex_program */
Brian Paul86b84272001-12-14 02:50:01 +00001336
Brian Paul610d5992003-01-14 04:55:45 +00001337#if FEATURE_NV_fragment_program
1338 case GL_FRAGMENT_PROGRAM_NV:
1339 CHECK_EXTENSION(NV_fragment_program);
1340 return ctx->FragmentProgram.Enabled;
1341#endif /* FEATURE_NV_fragment_program */
1342
Brian Paul8afe7de2002-06-15 03:03:06 +00001343 /* GL_NV_texture_rectangle */
1344 case GL_TEXTURE_RECTANGLE_NV:
1345 CHECK_EXTENSION(NV_texture_rectangle);
1346 {
1347 const struct gl_texture_unit *texUnit;
1348 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1349 return (texUnit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE;
1350 }
1351
Brian Paul5f60a0b2002-09-06 02:56:08 +00001352 /* GL_EXT_stencil_two_side */
1353 case GL_STENCIL_TEST_TWO_SIDE_EXT:
1354 CHECK_EXTENSION(EXT_stencil_two_side);
1355 return ctx->Stencil.TestTwoSide;
1356
Brian Paul77eec612003-04-18 01:56:11 +00001357#if FEATURE_ARB_fragment_program
1358 case GL_FRAGMENT_PROGRAM_ARB:
1359 return ctx->FragmentProgram.Enabled;
1360#endif /* FEATURE_ARB_fragment_program */
1361
Brian Paule5b244f2003-04-21 15:02:17 +00001362 /* GL_EXT_depth_bounds_test */
1363 case GL_DEPTH_BOUNDS_TEST_EXT:
1364 CHECK_EXTENSION(EXT_depth_bounds_test);
1365 return ctx->Depth.BoundsTest;
1366
Brian Paul08ff0592003-07-21 04:22:40 +00001367 /* GL_MESA_program_debug */
1368 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
1369 CHECK_EXTENSION(MESA_program_debug);
1370 return ctx->FragmentProgram.CallbackEnabled;
1371 case GL_VERTEX_PROGRAM_CALLBACK_MESA:
1372 CHECK_EXTENSION(MESA_program_debug);
1373 return ctx->VertexProgram.CallbackEnabled;
Dave Airlie7f752fe2004-12-19 03:06:59 +00001374#if FEATURE_ATI_fragment_shader
1375 case GL_FRAGMENT_SHADER_ATI:
1376 CHECK_EXTENSION(ATI_fragment_shader);
1377 return ctx->ATIFragmentShader.Enabled;
1378#endif /* FEATURE_ATI_fragment_shader */
jtgafb833d1999-08-19 00:55:39 +00001379 default:
Brian Paul4e9676f2002-06-29 19:48:15 +00001380 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap);
jtgafb833d1999-08-19 00:55:39 +00001381 return GL_FALSE;
1382 }
1383}