blob: 1cc844659228e3414ffab215667e088203c77eb4 [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
Ian Romanick58dacc82007-05-09 21:45:27 -0700193/**
194 * Helper function to enable or disable a texture target.
195 */
196static GLboolean
Ian Romanickc9e723e2007-05-10 08:20:04 -0700197enable_texture(GLcontext *ctx, GLboolean state, GLbitfield bit)
Ian Romanick58dacc82007-05-09 21:45:27 -0700198{
199 const GLuint curr = ctx->Texture.CurrentUnit;
200 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
201 const GLuint newenabled = (state)
202 ? (texUnit->Enabled & ~bit) : (texUnit->Enabled | bit);
203
204 if (!ctx->DrawBuffer->Visual.rgbMode || texUnit->Enabled == newenabled)
205 return GL_FALSE;
206
207 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
208 texUnit->Enabled = newenabled;
209 return GL_TRUE;
210}
211
Brian Paul86b84272001-12-14 02:50:01 +0000212
Keith Whitwell6dc85572003-07-17 13:43:59 +0000213/**
Brian8dcfcad72006-12-13 15:31:14 -0700214 * Helper function to enable or disable state.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000215 *
216 * \param ctx GL context.
Brian8dcfcad72006-12-13 15:31:14 -0700217 * \param cap the state to enable/disable
Keith Whitwell6dc85572003-07-17 13:43:59 +0000218 * \param state whether to enable or disable the specified capability.
219 *
220 * Updates the current context and flushes the vertices as needed. For
221 * capabilities associated with extensions it verifies that those extensions
222 * are effectivly present before updating. Notifies the driver via
223 * dd_function_table::Enable.
jtgafb833d1999-08-19 00:55:39 +0000224 */
Brian8dcfcad72006-12-13 15:31:14 -0700225void
226_mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
jtgafb833d1999-08-19 00:55:39 +0000227{
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000228 if (MESA_VERBOSE & VERBOSE_API)
Brian Paul4753d602002-06-15 02:38:15 +0000229 _mesa_debug(ctx, "%s %s (newstate is %x)\n",
Brian Paul9a33a112002-06-13 04:28:29 +0000230 state ? "glEnable" : "glDisable",
231 _mesa_lookup_enum_by_nr(cap),
232 ctx->NewState);
jtgafb833d1999-08-19 00:55:39 +0000233
234 switch (cap) {
Brian Paul86b84272001-12-14 02:50:01 +0000235 case GL_ALPHA_TEST:
236 if (ctx->Color.AlphaEnabled == state)
237 return;
238 FLUSH_VERTICES(ctx, _NEW_COLOR);
239 ctx->Color.AlphaEnabled = state;
240 break;
241 case GL_AUTO_NORMAL:
242 if (ctx->Eval.AutoNormal == state)
243 return;
244 FLUSH_VERTICES(ctx, _NEW_EVAL);
245 ctx->Eval.AutoNormal = state;
246 break;
247 case GL_BLEND:
248 if (ctx->Color.BlendEnabled == state)
249 return;
250 FLUSH_VERTICES(ctx, _NEW_COLOR);
251 ctx->Color.BlendEnabled = state;
Brian Paul86b84272001-12-14 02:50:01 +0000252 break;
Keith Whitwell6dc85572003-07-17 13:43:59 +0000253#if FEATURE_userclip
Brian Paul86b84272001-12-14 02:50:01 +0000254 case GL_CLIP_PLANE0:
255 case GL_CLIP_PLANE1:
256 case GL_CLIP_PLANE2:
257 case GL_CLIP_PLANE3:
258 case GL_CLIP_PLANE4:
259 case GL_CLIP_PLANE5:
260 {
Brian Paul103bc0f2002-03-29 17:27:59 +0000261 const GLuint p = cap - GL_CLIP_PLANE0;
jtgafb833d1999-08-19 00:55:39 +0000262
Brian Pauldb07de02002-04-19 00:23:08 +0000263 if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p))
Brian Paul86b84272001-12-14 02:50:01 +0000264 return;
Gareth Hughes22144ab2001-03-12 00:48:37 +0000265
Brian Paul86b84272001-12-14 02:50:01 +0000266 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
jtgafb833d1999-08-19 00:55:39 +0000267
Brian Paul86b84272001-12-14 02:50:01 +0000268 if (state) {
Brian Paul103bc0f2002-03-29 17:27:59 +0000269 ctx->Transform.ClipPlanesEnabled |= (1 << p);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000270
Brian Paul049e3202005-06-30 14:22:23 +0000271 if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
Brian Paul30f51ae2001-12-18 04:06:44 +0000272 _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
Gareth Hughes22144ab2001-03-12 00:48:37 +0000273
Brian Paul86b84272001-12-14 02:50:01 +0000274 /* This derived state also calculated in clip.c and
275 * from _mesa_update_state() on changes to EyeUserPlane
276 * and ctx->ProjectionMatrix respectively.
277 */
278 _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
279 ctx->Transform.EyeUserPlane[p],
Brian Paul30f51ae2001-12-18 04:06:44 +0000280 ctx->ProjectionMatrixStack.Top->inv );
Brian Paul86b84272001-12-14 02:50:01 +0000281 }
Brian Paulf66de792002-03-28 22:45:45 +0000282 else {
Brian Paul103bc0f2002-03-29 17:27:59 +0000283 ctx->Transform.ClipPlanesEnabled &= ~(1 << p);
Brian Paulf66de792002-03-28 22:45:45 +0000284 }
Brian Paul86b84272001-12-14 02:50:01 +0000285 }
286 break;
Keith Whitwell6dc85572003-07-17 13:43:59 +0000287#endif
Brian Paul86b84272001-12-14 02:50:01 +0000288 case GL_COLOR_MATERIAL:
289 if (ctx->Light.ColorMaterialEnabled == state)
290 return;
291 FLUSH_VERTICES(ctx, _NEW_LIGHT);
Brian Pauld40f9fa2003-03-21 13:18:33 +0000292 FLUSH_CURRENT(ctx, 0);
Brian Paul86b84272001-12-14 02:50:01 +0000293 ctx->Light.ColorMaterialEnabled = state;
294 if (state) {
Brian Paul86b84272001-12-14 02:50:01 +0000295 _mesa_update_color_material( ctx,
296 ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
297 }
298 break;
299 case GL_CULL_FACE:
300 if (ctx->Polygon.CullFlag == state)
301 return;
302 FLUSH_VERTICES(ctx, _NEW_POLYGON);
303 ctx->Polygon.CullFlag = state;
304 break;
Keith Whitwell352d4db2004-05-10 18:16:03 +0000305 case GL_CULL_VERTEX_EXT:
306 CHECK_EXTENSION(EXT_cull_vertex, cap);
307 if (ctx->Transform.CullVertexFlag == state)
308 return;
309 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
310 ctx->Transform.CullVertexFlag = state;
311 break;
Brian Paul86b84272001-12-14 02:50:01 +0000312 case GL_DEPTH_TEST:
Brian Paule4b23562005-05-04 20:11:35 +0000313 if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
Brian Paul86b84272001-12-14 02:50:01 +0000314 _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
315 return;
316 }
Brian8dcfcad72006-12-13 15:31:14 -0700317 if (ctx->Depth.Test == state)
Brian Paul86b84272001-12-14 02:50:01 +0000318 return;
319 FLUSH_VERTICES(ctx, _NEW_DEPTH);
320 ctx->Depth.Test = state;
321 break;
322 case GL_DITHER:
323 if (ctx->NoDither) {
324 state = GL_FALSE; /* MESA_NO_DITHER env var */
325 }
Brian8dcfcad72006-12-13 15:31:14 -0700326 if (ctx->Color.DitherFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000327 return;
328 FLUSH_VERTICES(ctx, _NEW_COLOR);
329 ctx->Color.DitherFlag = state;
330 break;
331 case GL_FOG:
Brian8dcfcad72006-12-13 15:31:14 -0700332 if (ctx->Fog.Enabled == state)
Brian Paul86b84272001-12-14 02:50:01 +0000333 return;
334 FLUSH_VERTICES(ctx, _NEW_FOG);
335 ctx->Fog.Enabled = state;
336 break;
337 case GL_HISTOGRAM:
Brian Paul02c03ef2002-06-18 16:53:46 +0000338 CHECK_EXTENSION(EXT_histogram, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000339 if (ctx->Pixel.HistogramEnabled == state)
340 return;
341 FLUSH_VERTICES(ctx, _NEW_PIXEL);
342 ctx->Pixel.HistogramEnabled = state;
343 break;
344 case GL_LIGHT0:
345 case GL_LIGHT1:
346 case GL_LIGHT2:
347 case GL_LIGHT3:
348 case GL_LIGHT4:
349 case GL_LIGHT5:
350 case GL_LIGHT6:
351 case GL_LIGHT7:
352 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state)
353 return;
354 FLUSH_VERTICES(ctx, _NEW_LIGHT);
355 ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
356 if (state) {
357 insert_at_tail(&ctx->Light.EnabledList,
358 &ctx->Light.Light[cap-GL_LIGHT0]);
359 }
360 else {
361 remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
362 }
363 break;
364 case GL_LIGHTING:
365 if (ctx->Light.Enabled == state)
366 return;
367 FLUSH_VERTICES(ctx, _NEW_LIGHT);
368 ctx->Light.Enabled = state;
Brian Paul86b84272001-12-14 02:50:01 +0000369 break;
370 case GL_LINE_SMOOTH:
371 if (ctx->Line.SmoothFlag == state)
372 return;
373 FLUSH_VERTICES(ctx, _NEW_LINE);
374 ctx->Line.SmoothFlag = state;
Brian Paul86b84272001-12-14 02:50:01 +0000375 break;
376 case GL_LINE_STIPPLE:
377 if (ctx->Line.StippleFlag == state)
378 return;
379 FLUSH_VERTICES(ctx, _NEW_LINE);
380 ctx->Line.StippleFlag = state;
Brian Paul86b84272001-12-14 02:50:01 +0000381 break;
382 case GL_INDEX_LOGIC_OP:
383 if (ctx->Color.IndexLogicOpEnabled == state)
384 return;
385 FLUSH_VERTICES(ctx, _NEW_COLOR);
386 ctx->Color.IndexLogicOpEnabled = state;
387 break;
388 case GL_COLOR_LOGIC_OP:
389 if (ctx->Color.ColorLogicOpEnabled == state)
390 return;
391 FLUSH_VERTICES(ctx, _NEW_COLOR);
392 ctx->Color.ColorLogicOpEnabled = state;
393 break;
394 case GL_MAP1_COLOR_4:
395 if (ctx->Eval.Map1Color4 == state)
396 return;
397 FLUSH_VERTICES(ctx, _NEW_EVAL);
398 ctx->Eval.Map1Color4 = state;
399 break;
400 case GL_MAP1_INDEX:
401 if (ctx->Eval.Map1Index == state)
402 return;
403 FLUSH_VERTICES(ctx, _NEW_EVAL);
404 ctx->Eval.Map1Index = state;
405 break;
406 case GL_MAP1_NORMAL:
407 if (ctx->Eval.Map1Normal == state)
408 return;
409 FLUSH_VERTICES(ctx, _NEW_EVAL);
410 ctx->Eval.Map1Normal = state;
411 break;
412 case GL_MAP1_TEXTURE_COORD_1:
413 if (ctx->Eval.Map1TextureCoord1 == state)
414 return;
415 FLUSH_VERTICES(ctx, _NEW_EVAL);
416 ctx->Eval.Map1TextureCoord1 = state;
417 break;
418 case GL_MAP1_TEXTURE_COORD_2:
419 if (ctx->Eval.Map1TextureCoord2 == state)
420 return;
421 FLUSH_VERTICES(ctx, _NEW_EVAL);
422 ctx->Eval.Map1TextureCoord2 = state;
423 break;
424 case GL_MAP1_TEXTURE_COORD_3:
425 if (ctx->Eval.Map1TextureCoord3 == state)
426 return;
427 FLUSH_VERTICES(ctx, _NEW_EVAL);
428 ctx->Eval.Map1TextureCoord3 = state;
429 break;
430 case GL_MAP1_TEXTURE_COORD_4:
431 if (ctx->Eval.Map1TextureCoord4 == state)
432 return;
433 FLUSH_VERTICES(ctx, _NEW_EVAL);
434 ctx->Eval.Map1TextureCoord4 = state;
435 break;
436 case GL_MAP1_VERTEX_3:
437 if (ctx->Eval.Map1Vertex3 == state)
438 return;
439 FLUSH_VERTICES(ctx, _NEW_EVAL);
440 ctx->Eval.Map1Vertex3 = state;
441 break;
442 case GL_MAP1_VERTEX_4:
443 if (ctx->Eval.Map1Vertex4 == state)
444 return;
445 FLUSH_VERTICES(ctx, _NEW_EVAL);
446 ctx->Eval.Map1Vertex4 = state;
447 break;
448 case GL_MAP2_COLOR_4:
449 if (ctx->Eval.Map2Color4 == state)
450 return;
451 FLUSH_VERTICES(ctx, _NEW_EVAL);
452 ctx->Eval.Map2Color4 = state;
453 break;
454 case GL_MAP2_INDEX:
455 if (ctx->Eval.Map2Index == state)
456 return;
457 FLUSH_VERTICES(ctx, _NEW_EVAL);
458 ctx->Eval.Map2Index = state;
459 break;
460 case GL_MAP2_NORMAL:
461 if (ctx->Eval.Map2Normal == state)
462 return;
463 FLUSH_VERTICES(ctx, _NEW_EVAL);
464 ctx->Eval.Map2Normal = state;
465 break;
466 case GL_MAP2_TEXTURE_COORD_1:
467 if (ctx->Eval.Map2TextureCoord1 == state)
468 return;
469 FLUSH_VERTICES(ctx, _NEW_EVAL);
470 ctx->Eval.Map2TextureCoord1 = state;
471 break;
472 case GL_MAP2_TEXTURE_COORD_2:
473 if (ctx->Eval.Map2TextureCoord2 == state)
474 return;
475 FLUSH_VERTICES(ctx, _NEW_EVAL);
476 ctx->Eval.Map2TextureCoord2 = state;
477 break;
478 case GL_MAP2_TEXTURE_COORD_3:
479 if (ctx->Eval.Map2TextureCoord3 == state)
480 return;
481 FLUSH_VERTICES(ctx, _NEW_EVAL);
482 ctx->Eval.Map2TextureCoord3 = state;
483 break;
484 case GL_MAP2_TEXTURE_COORD_4:
485 if (ctx->Eval.Map2TextureCoord4 == state)
486 return;
487 FLUSH_VERTICES(ctx, _NEW_EVAL);
488 ctx->Eval.Map2TextureCoord4 = state;
489 break;
490 case GL_MAP2_VERTEX_3:
491 if (ctx->Eval.Map2Vertex3 == state)
492 return;
493 FLUSH_VERTICES(ctx, _NEW_EVAL);
494 ctx->Eval.Map2Vertex3 = state;
495 break;
496 case GL_MAP2_VERTEX_4:
497 if (ctx->Eval.Map2Vertex4 == state)
498 return;
499 FLUSH_VERTICES(ctx, _NEW_EVAL);
500 ctx->Eval.Map2Vertex4 = state;
501 break;
502 case GL_MINMAX:
503 if (ctx->Pixel.MinMaxEnabled == state)
504 return;
505 FLUSH_VERTICES(ctx, _NEW_PIXEL);
506 ctx->Pixel.MinMaxEnabled = state;
507 break;
508 case GL_NORMALIZE:
509 if (ctx->Transform.Normalize == state)
510 return;
511 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
512 ctx->Transform.Normalize = state;
513 break;
514 case GL_POINT_SMOOTH:
Brian8dcfcad72006-12-13 15:31:14 -0700515 if (ctx->Point.SmoothFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000516 return;
517 FLUSH_VERTICES(ctx, _NEW_POINT);
518 ctx->Point.SmoothFlag = state;
Brian Paul86b84272001-12-14 02:50:01 +0000519 break;
520 case GL_POLYGON_SMOOTH:
Brian8dcfcad72006-12-13 15:31:14 -0700521 if (ctx->Polygon.SmoothFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000522 return;
523 FLUSH_VERTICES(ctx, _NEW_POLYGON);
524 ctx->Polygon.SmoothFlag = state;
Brian Paul86b84272001-12-14 02:50:01 +0000525 break;
526 case GL_POLYGON_STIPPLE:
Brian8dcfcad72006-12-13 15:31:14 -0700527 if (ctx->Polygon.StippleFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000528 return;
529 FLUSH_VERTICES(ctx, _NEW_POLYGON);
530 ctx->Polygon.StippleFlag = state;
Brian Paul86b84272001-12-14 02:50:01 +0000531 break;
532 case GL_POLYGON_OFFSET_POINT:
Brian8dcfcad72006-12-13 15:31:14 -0700533 if (ctx->Polygon.OffsetPoint == state)
Brian Paul86b84272001-12-14 02:50:01 +0000534 return;
535 FLUSH_VERTICES(ctx, _NEW_POLYGON);
536 ctx->Polygon.OffsetPoint = state;
537 break;
538 case GL_POLYGON_OFFSET_LINE:
Brian8dcfcad72006-12-13 15:31:14 -0700539 if (ctx->Polygon.OffsetLine == state)
Brian Paul86b84272001-12-14 02:50:01 +0000540 return;
541 FLUSH_VERTICES(ctx, _NEW_POLYGON);
542 ctx->Polygon.OffsetLine = state;
543 break;
544 case GL_POLYGON_OFFSET_FILL:
545 /*case GL_POLYGON_OFFSET_EXT:*/
Brian8dcfcad72006-12-13 15:31:14 -0700546 if (ctx->Polygon.OffsetFill == state)
Brian Paul86b84272001-12-14 02:50:01 +0000547 return;
548 FLUSH_VERTICES(ctx, _NEW_POLYGON);
549 ctx->Polygon.OffsetFill = state;
550 break;
551 case GL_RESCALE_NORMAL_EXT:
552 if (ctx->Transform.RescaleNormals == state)
553 return;
554 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
555 ctx->Transform.RescaleNormals = state;
556 break;
557 case GL_SCISSOR_TEST:
Brian8dcfcad72006-12-13 15:31:14 -0700558 if (ctx->Scissor.Enabled == state)
Brian Paul86b84272001-12-14 02:50:01 +0000559 return;
560 FLUSH_VERTICES(ctx, _NEW_SCISSOR);
561 ctx->Scissor.Enabled = state;
562 break;
563 case GL_SHARED_TEXTURE_PALETTE_EXT:
564 if (ctx->Texture.SharedPalette == state)
565 return;
566 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
567 ctx->Texture.SharedPalette = state;
568 break;
569 case GL_STENCIL_TEST:
Brian Paule4b23562005-05-04 20:11:35 +0000570 if (state && ctx->DrawBuffer->Visual.stencilBits == 0) {
Brian Paul86b84272001-12-14 02:50:01 +0000571 _mesa_warning(ctx,
572 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
573 return;
574 }
Brian8dcfcad72006-12-13 15:31:14 -0700575 if (ctx->Stencil.Enabled == state)
Brian Paul86b84272001-12-14 02:50:01 +0000576 return;
577 FLUSH_VERTICES(ctx, _NEW_STENCIL);
578 ctx->Stencil.Enabled = state;
579 break;
Ian Romanick58dacc82007-05-09 21:45:27 -0700580 case GL_TEXTURE_1D:
581 if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) {
Brian Paul86b84272001-12-14 02:50:01 +0000582 return;
Ian Romanick58dacc82007-05-09 21:45:27 -0700583 }
Brian Paul86b84272001-12-14 02:50:01 +0000584 break;
Ian Romanick58dacc82007-05-09 21:45:27 -0700585 case GL_TEXTURE_2D:
586 if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) {
Brian Paul86b84272001-12-14 02:50:01 +0000587 return;
Ian Romanick58dacc82007-05-09 21:45:27 -0700588 }
Brian Paul86b84272001-12-14 02:50:01 +0000589 break;
Ian Romanick58dacc82007-05-09 21:45:27 -0700590 case GL_TEXTURE_3D:
591 if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) {
Brian Paul86b84272001-12-14 02:50:01 +0000592 return;
Ian Romanick58dacc82007-05-09 21:45:27 -0700593 }
Brian Paul86b84272001-12-14 02:50:01 +0000594 break;
Brian Paul86b84272001-12-14 02:50:01 +0000595 case GL_TEXTURE_GEN_Q: {
596 GLuint unit = ctx->Texture.CurrentUnit;
597 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
598 GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
599 if (state)
600 newenabled |= Q_BIT;
601 if (texUnit->TexGenEnabled == newenabled)
602 return;
603 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
604 texUnit->TexGenEnabled = newenabled;
605 break;
606 }
607 case GL_TEXTURE_GEN_R: {
608 GLuint unit = ctx->Texture.CurrentUnit;
609 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
610 GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
611 if (state)
612 newenabled |= R_BIT;
613 if (texUnit->TexGenEnabled == newenabled)
614 return;
615 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
616 texUnit->TexGenEnabled = newenabled;
617 break;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000618 }
Brian Paul86b84272001-12-14 02:50:01 +0000619 case GL_TEXTURE_GEN_S: {
620 GLuint unit = ctx->Texture.CurrentUnit;
621 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
622 GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
623 if (state)
624 newenabled |= S_BIT;
625 if (texUnit->TexGenEnabled == newenabled)
626 return;
627 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
628 texUnit->TexGenEnabled = newenabled;
629 break;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000630 }
Brian Paul86b84272001-12-14 02:50:01 +0000631 case GL_TEXTURE_GEN_T: {
632 GLuint unit = ctx->Texture.CurrentUnit;
633 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
634 GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
635 if (state)
636 newenabled |= T_BIT;
637 if (texUnit->TexGenEnabled == newenabled)
638 return;
639 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
640 texUnit->TexGenEnabled = newenabled;
641 break;
642 }
Keith Whitwell46b09882001-02-16 18:14:41 +0000643
Brian Paul86b84272001-12-14 02:50:01 +0000644 /*
645 * CLIENT STATE!!!
646 */
647 case GL_VERTEX_ARRAY:
648 case GL_NORMAL_ARRAY:
649 case GL_COLOR_ARRAY:
650 case GL_INDEX_ARRAY:
651 case GL_TEXTURE_COORD_ARRAY:
652 case GL_EDGE_FLAG_ARRAY:
653 case GL_FOG_COORDINATE_ARRAY_EXT:
654 case GL_SECONDARY_COLOR_ARRAY_EXT:
655 client_state( ctx, cap, state );
656 return;
jtgafb833d1999-08-19 00:55:39 +0000657
Brian Paul13811372000-04-12 00:27:37 +0000658 /* GL_SGI_color_table */
Brian Paul86b84272001-12-14 02:50:01 +0000659 case GL_COLOR_TABLE_SGI:
Brian Paul02c03ef2002-06-18 16:53:46 +0000660 CHECK_EXTENSION(SGI_color_table, cap);
Brian7573b582007-03-16 09:36:12 -0600661 if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] == state)
Brian Paul86b84272001-12-14 02:50:01 +0000662 return;
663 FLUSH_VERTICES(ctx, _NEW_PIXEL);
Brian7573b582007-03-16 09:36:12 -0600664 ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] = state;
Brian Paul86b84272001-12-14 02:50:01 +0000665 break;
666 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
Brian Paul02c03ef2002-06-18 16:53:46 +0000667 CHECK_EXTENSION(SGI_color_table, cap);
Brian7573b582007-03-16 09:36:12 -0600668 if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] == state)
Brian Paul86b84272001-12-14 02:50:01 +0000669 return;
670 FLUSH_VERTICES(ctx, _NEW_PIXEL);
Brian7573b582007-03-16 09:36:12 -0600671 ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] = state;
Brian Paul86b84272001-12-14 02:50:01 +0000672 break;
673 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
Brian Paul02c03ef2002-06-18 16:53:46 +0000674 CHECK_EXTENSION(SGI_color_table, cap);
Brian7573b582007-03-16 09:36:12 -0600675 if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] == state)
Brian Paul86b84272001-12-14 02:50:01 +0000676 return;
677 FLUSH_VERTICES(ctx, _NEW_PIXEL);
Brian7573b582007-03-16 09:36:12 -0600678 ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] = state;
Brian Paul86b84272001-12-14 02:50:01 +0000679 break;
Brian Paul418ac002003-01-21 21:47:45 +0000680 case GL_TEXTURE_COLOR_TABLE_SGI:
681 CHECK_EXTENSION(SGI_texture_color_table, cap);
Brian Paul45b47d02003-01-26 14:37:15 +0000682 if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state)
Brian Paul418ac002003-01-21 21:47:45 +0000683 return;
684 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
Brian Paul45b47d02003-01-26 14:37:15 +0000685 ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state;
Brian Paul418ac002003-01-21 21:47:45 +0000686 break;
Brian Paul13811372000-04-12 00:27:37 +0000687
Brian Paul82b02f02000-05-07 20:37:40 +0000688 /* GL_EXT_convolution */
Brian Paul86b84272001-12-14 02:50:01 +0000689 case GL_CONVOLUTION_1D:
Brian Paul02c03ef2002-06-18 16:53:46 +0000690 CHECK_EXTENSION(EXT_convolution, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000691 if (ctx->Pixel.Convolution1DEnabled == state)
692 return;
693 FLUSH_VERTICES(ctx, _NEW_PIXEL);
694 ctx->Pixel.Convolution1DEnabled = state;
695 break;
696 case GL_CONVOLUTION_2D:
Brian Paul02c03ef2002-06-18 16:53:46 +0000697 CHECK_EXTENSION(EXT_convolution, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000698 if (ctx->Pixel.Convolution2DEnabled == state)
699 return;
700 FLUSH_VERTICES(ctx, _NEW_PIXEL);
701 ctx->Pixel.Convolution2DEnabled = state;
702 break;
703 case GL_SEPARABLE_2D:
Brian Paul02c03ef2002-06-18 16:53:46 +0000704 CHECK_EXTENSION(EXT_convolution, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000705 if (ctx->Pixel.Separable2DEnabled == state)
706 return;
707 FLUSH_VERTICES(ctx, _NEW_PIXEL);
708 ctx->Pixel.Separable2DEnabled = state;
709 break;
Brian Paul82b02f02000-05-07 20:37:40 +0000710
Brian Paul86fc3702000-05-22 16:33:20 +0000711 /* GL_ARB_texture_cube_map */
Brian Paul86b84272001-12-14 02:50:01 +0000712 case GL_TEXTURE_CUBE_MAP_ARB:
Ian Romanick58dacc82007-05-09 21:45:27 -0700713 CHECK_EXTENSION(ARB_texture_cube_map, cap);
714 if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) {
715 return;
Brian Paul86b84272001-12-14 02:50:01 +0000716 }
717 break;
718
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000719 /* GL_EXT_secondary_color */
Brian Paul86b84272001-12-14 02:50:01 +0000720 case GL_COLOR_SUM_EXT:
Roland Scheideggerda168132006-03-02 12:06:57 +0000721 CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000722 if (ctx->Fog.ColorSumEnabled == state)
723 return;
724 FLUSH_VERTICES(ctx, _NEW_FOG);
725 ctx->Fog.ColorSumEnabled = state;
Brian Paul86b84272001-12-14 02:50:01 +0000726 break;
Brian Paul06d05af2000-12-08 00:20:15 +0000727
Brian Paul736fcbe2001-05-29 15:23:48 +0000728 /* GL_ARB_multisample */
Brian Paul86b84272001-12-14 02:50:01 +0000729 case GL_MULTISAMPLE_ARB:
Brian Paul02c03ef2002-06-18 16:53:46 +0000730 CHECK_EXTENSION(ARB_multisample, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000731 if (ctx->Multisample.Enabled == state)
732 return;
733 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
734 ctx->Multisample.Enabled = state;
735 break;
736 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
Brian Paul02c03ef2002-06-18 16:53:46 +0000737 CHECK_EXTENSION(ARB_multisample, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000738 if (ctx->Multisample.SampleAlphaToCoverage == state)
739 return;
740 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
741 ctx->Multisample.SampleAlphaToCoverage = state;
742 break;
743 case GL_SAMPLE_ALPHA_TO_ONE_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.SampleAlphaToOne == state)
746 return;
747 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
748 ctx->Multisample.SampleAlphaToOne = state;
749 break;
750 case GL_SAMPLE_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.SampleCoverage == state)
753 return;
754 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
755 ctx->Multisample.SampleCoverage = state;
756 break;
757 case GL_SAMPLE_COVERAGE_INVERT_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.SampleCoverageInvert == state)
760 return;
761 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
762 ctx->Multisample.SampleCoverageInvert = state;
763 break;
Brian Paul8c2f6c52001-06-26 01:32:48 +0000764
765 /* GL_IBM_rasterpos_clip */
Brian Paul86b84272001-12-14 02:50:01 +0000766 case GL_RASTER_POSITION_UNCLIPPED_IBM:
Brian Paul02c03ef2002-06-18 16:53:46 +0000767 CHECK_EXTENSION(IBM_rasterpos_clip, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000768 if (ctx->Transform.RasterPositionUnclipped == state)
769 return;
770 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
771 ctx->Transform.RasterPositionUnclipped = state;
772 break;
Brian Paul736fcbe2001-05-29 15:23:48 +0000773
Brian Paul6c408b42002-05-27 17:04:52 +0000774 /* GL_NV_point_sprite */
775 case GL_POINT_SPRITE_NV:
Ian Romanick63736722003-08-23 00:12:46 +0000776 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap);
Brian Paul6c408b42002-05-27 17:04:52 +0000777 if (ctx->Point.PointSprite == state)
Brian Paul86b84272001-12-14 02:50:01 +0000778 return;
779 FLUSH_VERTICES(ctx, _NEW_POINT);
Brian Paul6c408b42002-05-27 17:04:52 +0000780 ctx->Point.PointSprite = state;
Brian Paul86b84272001-12-14 02:50:01 +0000781 break;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000782
Roland Scheidegger93da6732006-03-01 23:11:14 +0000783#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
Roland Scheideggere1e03b32006-03-03 15:03:04 +0000784 case GL_VERTEX_PROGRAM_ARB:
785 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000786 if (ctx->VertexProgram.Enabled == state)
787 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000788 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul86b84272001-12-14 02:50:01 +0000789 ctx->VertexProgram.Enabled = state;
790 break;
Roland Scheideggere1e03b32006-03-03 15:03:04 +0000791 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
792 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000793 if (ctx->VertexProgram.PointSizeEnabled == state)
794 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000795 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul86b84272001-12-14 02:50:01 +0000796 ctx->VertexProgram.PointSizeEnabled = state;
797 break;
Roland Scheideggere1e03b32006-03-03 15:03:04 +0000798 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB:
799 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000800 if (ctx->VertexProgram.TwoSideEnabled == 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.TwoSideEnabled = state;
804 break;
Roland Scheidegger93da6732006-03-01 23:11:14 +0000805#endif
806#if FEATURE_NV_vertex_program
Brian Paul86b84272001-12-14 02:50:01 +0000807 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
808 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
809 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
810 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
811 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
812 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
813 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
814 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
815 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
816 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
817 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
818 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
819 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
820 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
821 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
822 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
Brian Paul02c03ef2002-06-18 16:53:46 +0000823 CHECK_EXTENSION(NV_vertex_program, cap);
Brian Paulbc42c192002-01-05 21:53:20 +0000824 {
825 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
826 FLUSH_VERTICES(ctx, _NEW_EVAL);
827 ctx->Eval.Map1Attrib[map] = state;
828 }
Brian Paul86b84272001-12-14 02:50:01 +0000829 break;
830 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
831 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
832 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
833 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
834 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
835 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
836 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
837 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
838 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
839 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
840 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
841 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
842 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
843 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
844 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
845 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
Brian Paul02c03ef2002-06-18 16:53:46 +0000846 CHECK_EXTENSION(NV_vertex_program, cap);
Brian Paulbc42c192002-01-05 21:53:20 +0000847 {
848 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
849 FLUSH_VERTICES(ctx, _NEW_EVAL);
850 ctx->Eval.Map2Attrib[map] = state;
851 }
Brian Paul86b84272001-12-14 02:50:01 +0000852 break;
Brian Paul8dfc5b92002-10-16 17:57:51 +0000853#endif /* FEATURE_NV_vertex_program */
Brian Paul86b84272001-12-14 02:50:01 +0000854
Brian Paul610d5992003-01-14 04:55:45 +0000855#if FEATURE_NV_fragment_program
856 case GL_FRAGMENT_PROGRAM_NV:
857 CHECK_EXTENSION(NV_fragment_program, cap);
858 if (ctx->FragmentProgram.Enabled == state)
859 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000860 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul610d5992003-01-14 04:55:45 +0000861 ctx->FragmentProgram.Enabled = state;
862 break;
863#endif /* FEATURE_NV_fragment_program */
864
Brian Paul8afe7de2002-06-15 03:03:06 +0000865 /* GL_NV_texture_rectangle */
866 case GL_TEXTURE_RECTANGLE_NV:
Brian Paul5f60a0b2002-09-06 02:56:08 +0000867 CHECK_EXTENSION(NV_texture_rectangle, cap);
Ian Romanick58dacc82007-05-09 21:45:27 -0700868 if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) {
869 return;
Brian Paul8afe7de2002-06-15 03:03:06 +0000870 }
871 break;
872
Brian Paul5f60a0b2002-09-06 02:56:08 +0000873 /* GL_EXT_stencil_two_side */
874 case GL_STENCIL_TEST_TWO_SIDE_EXT:
875 CHECK_EXTENSION(EXT_stencil_two_side, cap);
876 if (ctx->Stencil.TestTwoSide == state)
877 return;
878 FLUSH_VERTICES(ctx, _NEW_STENCIL);
879 ctx->Stencil.TestTwoSide = state;
880 break;
881
Brian Paul77eec612003-04-18 01:56:11 +0000882#if FEATURE_ARB_fragment_program
883 case GL_FRAGMENT_PROGRAM_ARB:
884 CHECK_EXTENSION(ARB_fragment_program, cap);
885 if (ctx->FragmentProgram.Enabled == state)
886 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000887 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul77eec612003-04-18 01:56:11 +0000888 ctx->FragmentProgram.Enabled = state;
889 break;
890#endif /* FEATURE_ARB_fragment_program */
891
Brian Paule5b244f2003-04-21 15:02:17 +0000892 /* GL_EXT_depth_bounds_test */
893 case GL_DEPTH_BOUNDS_TEST_EXT:
894 CHECK_EXTENSION(EXT_depth_bounds_test, cap);
Brian Paule4b23562005-05-04 20:11:35 +0000895 if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
Brian Paule5b244f2003-04-21 15:02:17 +0000896 _mesa_warning(ctx,
897 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
898 return;
899 }
900 if (ctx->Depth.BoundsTest == state)
901 return;
902 FLUSH_VERTICES(ctx, _NEW_DEPTH);
903 ctx->Depth.BoundsTest = state;
904 break;
905
Brian Paul08ff0592003-07-21 04:22:40 +0000906 /* GL_MESA_program_debug */
907 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
908 CHECK_EXTENSION(MESA_program_debug, cap);
909 ctx->FragmentProgram.CallbackEnabled = state;
910 break;
911 case GL_VERTEX_PROGRAM_CALLBACK_MESA:
912 CHECK_EXTENSION(MESA_program_debug, cap);
913 ctx->VertexProgram.CallbackEnabled = state;
914 break;
915
Dave Airlie7f752fe2004-12-19 03:06:59 +0000916#if FEATURE_ATI_fragment_shader
917 case GL_FRAGMENT_SHADER_ATI:
918 CHECK_EXTENSION(ATI_fragment_shader, cap);
919 if (ctx->ATIFragmentShader.Enabled == state)
920 return;
921 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
922 ctx->ATIFragmentShader.Enabled = state;
923 break;
924#endif
Brian Paul86b84272001-12-14 02:50:01 +0000925 default:
Brian Paul4e9676f2002-06-29 19:48:15 +0000926 _mesa_error(ctx, GL_INVALID_ENUM,
927 "%s(0x%x)", state ? "glEnable" : "glDisable", cap);
Brian Paul86b84272001-12-14 02:50:01 +0000928 return;
jtgafb833d1999-08-19 00:55:39 +0000929 }
930
931 if (ctx->Driver.Enable) {
Brian8dcfcad72006-12-13 15:31:14 -0700932 ctx->Driver.Enable( ctx, cap, state );
jtgafb833d1999-08-19 00:55:39 +0000933 }
934}
935
936
Keith Whitwell6dc85572003-07-17 13:43:59 +0000937/**
Brian8dcfcad72006-12-13 15:31:14 -0700938 * Enable GL capability. Called by glEnable()
939 * \param cap state to enable.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000940 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000941void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000942_mesa_Enable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000943{
Brian Paulfbd8f211999-11-11 01:22:25 +0000944 GET_CURRENT_CONTEXT(ctx);
Keith Whitwell376d0222000-12-27 22:52:45 +0000945 ASSERT_OUTSIDE_BEGIN_END(ctx);
946
Brian Paulfbd8f211999-11-11 01:22:25 +0000947 _mesa_set_enable( ctx, cap, GL_TRUE );
jtgafb833d1999-08-19 00:55:39 +0000948}
949
950
Keith Whitwell6dc85572003-07-17 13:43:59 +0000951/**
Brian8dcfcad72006-12-13 15:31:14 -0700952 * Disable GL capability. Called by glDisable()
953 * \param cap state to disable.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000954 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000955void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000956_mesa_Disable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000957{
Brian Paulfbd8f211999-11-11 01:22:25 +0000958 GET_CURRENT_CONTEXT(ctx);
Keith Whitwell376d0222000-12-27 22:52:45 +0000959 ASSERT_OUTSIDE_BEGIN_END(ctx);
960
Brian Paulfbd8f211999-11-11 01:22:25 +0000961 _mesa_set_enable( ctx, cap, GL_FALSE );
jtgafb833d1999-08-19 00:55:39 +0000962}
963
964
Brian Paul86b84272001-12-14 02:50:01 +0000965#undef CHECK_EXTENSION
966#define CHECK_EXTENSION(EXTNAME) \
967 if (!ctx->Extensions.EXTNAME) { \
968 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
969 return GL_FALSE; \
970 }
971
Roland Scheideggerda168132006-03-02 12:06:57 +0000972#undef CHECK_EXTENSION2
973#define CHECK_EXTENSION2(EXT1, EXT2) \
974 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
975 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
976 return GL_FALSE; \
977 }
jtgafb833d1999-08-19 00:55:39 +0000978
Brian8dcfcad72006-12-13 15:31:14 -0700979
Keith Whitwell6dc85572003-07-17 13:43:59 +0000980/**
Ian Romanick58dacc82007-05-09 21:45:27 -0700981 * Helper function to determine whether a texture target is enabled.
982 */
983static GLboolean
Ian Romanickc9e723e2007-05-10 08:20:04 -0700984is_texture_enabled(GLcontext *ctx, GLbitfield bit)
Ian Romanick58dacc82007-05-09 21:45:27 -0700985{
986 const struct gl_texture_unit *const texUnit =
987 &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
988 return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE;
989}
990
991
992/**
Brian8dcfcad72006-12-13 15:31:14 -0700993 * Return simple enable/disable state.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000994 *
Brian8dcfcad72006-12-13 15:31:14 -0700995 * \param cap state variable to query.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000996 *
997 * Returns the state of the specified capability from the current GL context.
998 * For the capabilities associated with extensions verifies that those
999 * extensions are effectively present before reporting.
1000 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +00001001GLboolean GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +00001002_mesa_IsEnabled( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +00001003{
Brian Paulfbd8f211999-11-11 01:22:25 +00001004 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +00001005 switch (cap) {
1006 case GL_ALPHA_TEST:
1007 return ctx->Color.AlphaEnabled;
1008 case GL_AUTO_NORMAL:
1009 return ctx->Eval.AutoNormal;
1010 case GL_BLEND:
1011 return ctx->Color.BlendEnabled;
1012 case GL_CLIP_PLANE0:
1013 case GL_CLIP_PLANE1:
1014 case GL_CLIP_PLANE2:
1015 case GL_CLIP_PLANE3:
1016 case GL_CLIP_PLANE4:
1017 case GL_CLIP_PLANE5:
Brian Paul103bc0f2002-03-29 17:27:59 +00001018 return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1;
jtgafb833d1999-08-19 00:55:39 +00001019 case GL_COLOR_MATERIAL:
1020 return ctx->Light.ColorMaterialEnabled;
1021 case GL_CULL_FACE:
1022 return ctx->Polygon.CullFlag;
1023 case GL_DEPTH_TEST:
1024 return ctx->Depth.Test;
1025 case GL_DITHER:
1026 return ctx->Color.DitherFlag;
1027 case GL_FOG:
1028 return ctx->Fog.Enabled;
1029 case GL_LIGHTING:
1030 return ctx->Light.Enabled;
1031 case GL_LIGHT0:
1032 case GL_LIGHT1:
1033 case GL_LIGHT2:
1034 case GL_LIGHT3:
1035 case GL_LIGHT4:
1036 case GL_LIGHT5:
1037 case GL_LIGHT6:
1038 case GL_LIGHT7:
1039 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
1040 case GL_LINE_SMOOTH:
1041 return ctx->Line.SmoothFlag;
1042 case GL_LINE_STIPPLE:
1043 return ctx->Line.StippleFlag;
1044 case GL_INDEX_LOGIC_OP:
1045 return ctx->Color.IndexLogicOpEnabled;
1046 case GL_COLOR_LOGIC_OP:
1047 return ctx->Color.ColorLogicOpEnabled;
1048 case GL_MAP1_COLOR_4:
1049 return ctx->Eval.Map1Color4;
1050 case GL_MAP1_INDEX:
1051 return ctx->Eval.Map1Index;
1052 case GL_MAP1_NORMAL:
1053 return ctx->Eval.Map1Normal;
1054 case GL_MAP1_TEXTURE_COORD_1:
1055 return ctx->Eval.Map1TextureCoord1;
1056 case GL_MAP1_TEXTURE_COORD_2:
1057 return ctx->Eval.Map1TextureCoord2;
1058 case GL_MAP1_TEXTURE_COORD_3:
1059 return ctx->Eval.Map1TextureCoord3;
1060 case GL_MAP1_TEXTURE_COORD_4:
1061 return ctx->Eval.Map1TextureCoord4;
1062 case GL_MAP1_VERTEX_3:
1063 return ctx->Eval.Map1Vertex3;
1064 case GL_MAP1_VERTEX_4:
1065 return ctx->Eval.Map1Vertex4;
1066 case GL_MAP2_COLOR_4:
1067 return ctx->Eval.Map2Color4;
1068 case GL_MAP2_INDEX:
1069 return ctx->Eval.Map2Index;
1070 case GL_MAP2_NORMAL:
1071 return ctx->Eval.Map2Normal;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001072 case GL_MAP2_TEXTURE_COORD_1:
jtgafb833d1999-08-19 00:55:39 +00001073 return ctx->Eval.Map2TextureCoord1;
1074 case GL_MAP2_TEXTURE_COORD_2:
1075 return ctx->Eval.Map2TextureCoord2;
1076 case GL_MAP2_TEXTURE_COORD_3:
1077 return ctx->Eval.Map2TextureCoord3;
1078 case GL_MAP2_TEXTURE_COORD_4:
1079 return ctx->Eval.Map2TextureCoord4;
1080 case GL_MAP2_VERTEX_3:
1081 return ctx->Eval.Map2Vertex3;
1082 case GL_MAP2_VERTEX_4:
1083 return ctx->Eval.Map2Vertex4;
1084 case GL_NORMALIZE:
1085 return ctx->Transform.Normalize;
1086 case GL_POINT_SMOOTH:
1087 return ctx->Point.SmoothFlag;
1088 case GL_POLYGON_SMOOTH:
1089 return ctx->Polygon.SmoothFlag;
1090 case GL_POLYGON_STIPPLE:
1091 return ctx->Polygon.StippleFlag;
1092 case GL_POLYGON_OFFSET_POINT:
1093 return ctx->Polygon.OffsetPoint;
1094 case GL_POLYGON_OFFSET_LINE:
1095 return ctx->Polygon.OffsetLine;
1096 case GL_POLYGON_OFFSET_FILL:
1097 /*case GL_POLYGON_OFFSET_EXT:*/
1098 return ctx->Polygon.OffsetFill;
1099 case GL_RESCALE_NORMAL_EXT:
1100 return ctx->Transform.RescaleNormals;
1101 case GL_SCISSOR_TEST:
1102 return ctx->Scissor.Enabled;
1103 case GL_SHARED_TEXTURE_PALETTE_EXT:
1104 return ctx->Texture.SharedPalette;
1105 case GL_STENCIL_TEST:
1106 return ctx->Stencil.Enabled;
1107 case GL_TEXTURE_1D:
Ian Romanick58dacc82007-05-09 21:45:27 -07001108 return is_texture_enabled(ctx, TEXTURE_1D_BIT);
jtgafb833d1999-08-19 00:55:39 +00001109 case GL_TEXTURE_2D:
Ian Romanick58dacc82007-05-09 21:45:27 -07001110 return is_texture_enabled(ctx, TEXTURE_2D_BIT);
jtgafb833d1999-08-19 00:55:39 +00001111 case GL_TEXTURE_3D:
Ian Romanickc9e723e2007-05-10 08:20:04 -07001112 return is_texture_enabled(ctx, TEXTURE_3D_BIT);
jtgafb833d1999-08-19 00:55:39 +00001113 case GL_TEXTURE_GEN_Q:
1114 {
Brian Paul86b84272001-12-14 02:50:01 +00001115 const struct gl_texture_unit *texUnit;
1116 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001117 return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
1118 }
1119 case GL_TEXTURE_GEN_R:
1120 {
Brian Paul86b84272001-12-14 02:50:01 +00001121 const struct gl_texture_unit *texUnit;
1122 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001123 return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
1124 }
1125 case GL_TEXTURE_GEN_S:
1126 {
Brian Paul86b84272001-12-14 02:50:01 +00001127 const struct gl_texture_unit *texUnit;
1128 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001129 return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
1130 }
1131 case GL_TEXTURE_GEN_T:
1132 {
Brian Paul86b84272001-12-14 02:50:01 +00001133 const struct gl_texture_unit *texUnit;
1134 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001135 return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
1136 }
1137
1138 /*
1139 * CLIENT STATE!!!
1140 */
1141 case GL_VERTEX_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001142 return (ctx->Array.ArrayObj->Vertex.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001143 case GL_NORMAL_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001144 return (ctx->Array.ArrayObj->Normal.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001145 case GL_COLOR_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001146 return (ctx->Array.ArrayObj->Color.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001147 case GL_INDEX_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001148 return (ctx->Array.ArrayObj->Index.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001149 case GL_TEXTURE_COORD_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001150 return (ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001151 case GL_EDGE_FLAG_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001152 return (ctx->Array.ArrayObj->EdgeFlag.Enabled != 0);
Brian Paul6ee7a022002-01-22 18:40:46 +00001153 case GL_FOG_COORDINATE_ARRAY_EXT:
1154 CHECK_EXTENSION(EXT_fog_coord);
Ian Romanickee34e6e2006-06-12 16:26:29 +00001155 return (ctx->Array.ArrayObj->FogCoord.Enabled != 0);
Brian Paul6ee7a022002-01-22 18:40:46 +00001156 case GL_SECONDARY_COLOR_ARRAY_EXT:
1157 CHECK_EXTENSION(EXT_secondary_color);
Ian Romanickee34e6e2006-06-12 16:26:29 +00001158 return (ctx->Array.ArrayObj->SecondaryColor.Enabled != 0);
Brian Paul1b2ff692000-03-11 23:23:26 +00001159
Brian Paul86b84272001-12-14 02:50:01 +00001160 /* GL_EXT_histogram */
1161 case GL_HISTOGRAM:
1162 CHECK_EXTENSION(EXT_histogram);
1163 return ctx->Pixel.HistogramEnabled;
1164 case GL_MINMAX:
1165 CHECK_EXTENSION(EXT_histogram);
1166 return ctx->Pixel.MinMaxEnabled;
1167
Brian Paul13811372000-04-12 00:27:37 +00001168 /* GL_SGI_color_table */
1169 case GL_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001170 CHECK_EXTENSION(SGI_color_table);
Brian7573b582007-03-16 09:36:12 -06001171 return ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION];
Brian Paul13811372000-04-12 00:27:37 +00001172 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001173 CHECK_EXTENSION(SGI_color_table);
Brian7573b582007-03-16 09:36:12 -06001174 return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION];
Brian Paul13811372000-04-12 00:27:37 +00001175 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001176 CHECK_EXTENSION(SGI_color_table);
Brian7573b582007-03-16 09:36:12 -06001177 return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX];
Brian Paul2b2e9252000-04-07 16:27:26 +00001178
Brian Paul45b47d02003-01-26 14:37:15 +00001179 /* GL_SGI_texture_color_table */
1180 case GL_TEXTURE_COLOR_TABLE_SGI:
1181 CHECK_EXTENSION(SGI_texture_color_table);
1182 return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled;
1183
Brian Paul82b02f02000-05-07 20:37:40 +00001184 /* GL_EXT_convolution */
1185 case GL_CONVOLUTION_1D:
Brian Paul86b84272001-12-14 02:50:01 +00001186 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001187 return ctx->Pixel.Convolution1DEnabled;
1188 case GL_CONVOLUTION_2D:
Brian Paul86b84272001-12-14 02:50:01 +00001189 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001190 return ctx->Pixel.Convolution2DEnabled;
1191 case GL_SEPARABLE_2D:
Brian Paul86b84272001-12-14 02:50:01 +00001192 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001193 return ctx->Pixel.Separable2DEnabled;
1194
Brian Paul86fc3702000-05-22 16:33:20 +00001195 /* GL_ARB_texture_cube_map */
1196 case GL_TEXTURE_CUBE_MAP_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001197 CHECK_EXTENSION(ARB_texture_cube_map);
Ian Romanick58dacc82007-05-09 21:45:27 -07001198 return is_texture_enabled(ctx, TEXTURE_CUBE_BIT);
Brian Paul86fc3702000-05-22 16:33:20 +00001199
Roland Scheideggerda168132006-03-02 12:06:57 +00001200 /* GL_EXT_secondary_color */
1201 case GL_COLOR_SUM_EXT:
1202 CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program);
1203 return ctx->Fog.ColorSumEnabled;
1204
Brian Paul736fcbe2001-05-29 15:23:48 +00001205 /* GL_ARB_multisample */
1206 case GL_MULTISAMPLE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001207 CHECK_EXTENSION(ARB_multisample);
1208 return ctx->Multisample.Enabled;
Brian Paul736fcbe2001-05-29 15:23:48 +00001209 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001210 CHECK_EXTENSION(ARB_multisample);
1211 return ctx->Multisample.SampleAlphaToCoverage;
Brian Paul736fcbe2001-05-29 15:23:48 +00001212 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001213 CHECK_EXTENSION(ARB_multisample);
1214 return ctx->Multisample.SampleAlphaToOne;
Brian Paul736fcbe2001-05-29 15:23:48 +00001215 case GL_SAMPLE_COVERAGE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001216 CHECK_EXTENSION(ARB_multisample);
1217 return ctx->Multisample.SampleCoverage;
Brian Paul736fcbe2001-05-29 15:23:48 +00001218 case GL_SAMPLE_COVERAGE_INVERT_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001219 CHECK_EXTENSION(ARB_multisample);
1220 return ctx->Multisample.SampleCoverageInvert;
Brian Paul736fcbe2001-05-29 15:23:48 +00001221
Brian Paul8c2f6c52001-06-26 01:32:48 +00001222 /* GL_IBM_rasterpos_clip */
1223 case GL_RASTER_POSITION_UNCLIPPED_IBM:
Brian Paul86b84272001-12-14 02:50:01 +00001224 CHECK_EXTENSION(IBM_rasterpos_clip);
1225 return ctx->Transform.RasterPositionUnclipped;
Brian Paul8c2f6c52001-06-26 01:32:48 +00001226
Brian Paul6c408b42002-05-27 17:04:52 +00001227 /* GL_NV_point_sprite */
1228 case GL_POINT_SPRITE_NV:
Roland Scheideggerda168132006-03-02 12:06:57 +00001229 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite)
Brian Paul6c408b42002-05-27 17:04:52 +00001230 return ctx->Point.PointSprite;
Brian Paul06d05af2000-12-08 00:20:15 +00001231
Roland Scheidegger93da6732006-03-01 23:11:14 +00001232#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
Roland Scheideggerda168132006-03-02 12:06:57 +00001233 case GL_VERTEX_PROGRAM_ARB:
1234 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
Brian Paul86b84272001-12-14 02:50:01 +00001235 return ctx->VertexProgram.Enabled;
Roland Scheideggerda168132006-03-02 12:06:57 +00001236 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
1237 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
Brian Paul86b84272001-12-14 02:50:01 +00001238 return ctx->VertexProgram.PointSizeEnabled;
Roland Scheideggerda168132006-03-02 12:06:57 +00001239 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB:
1240 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
Brian Paul86b84272001-12-14 02:50:01 +00001241 return ctx->VertexProgram.TwoSideEnabled;
Roland Scheidegger93da6732006-03-01 23:11:14 +00001242#endif
1243#if FEATURE_NV_vertex_program
Brian Paul86b84272001-12-14 02:50:01 +00001244 case GL_VERTEX_ATTRIB_ARRAY0_NV:
1245 case GL_VERTEX_ATTRIB_ARRAY1_NV:
1246 case GL_VERTEX_ATTRIB_ARRAY2_NV:
1247 case GL_VERTEX_ATTRIB_ARRAY3_NV:
1248 case GL_VERTEX_ATTRIB_ARRAY4_NV:
1249 case GL_VERTEX_ATTRIB_ARRAY5_NV:
1250 case GL_VERTEX_ATTRIB_ARRAY6_NV:
1251 case GL_VERTEX_ATTRIB_ARRAY7_NV:
1252 case GL_VERTEX_ATTRIB_ARRAY8_NV:
1253 case GL_VERTEX_ATTRIB_ARRAY9_NV:
1254 case GL_VERTEX_ATTRIB_ARRAY10_NV:
1255 case GL_VERTEX_ATTRIB_ARRAY11_NV:
1256 case GL_VERTEX_ATTRIB_ARRAY12_NV:
1257 case GL_VERTEX_ATTRIB_ARRAY13_NV:
1258 case GL_VERTEX_ATTRIB_ARRAY14_NV:
1259 case GL_VERTEX_ATTRIB_ARRAY15_NV:
1260 CHECK_EXTENSION(NV_vertex_program);
1261 {
1262 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
Ian Romanickee34e6e2006-06-12 16:26:29 +00001263 return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0);
Brian Paul86b84272001-12-14 02:50:01 +00001264 }
1265 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
1266 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
1267 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
1268 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
1269 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
1270 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
1271 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
1272 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
1273 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
1274 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
1275 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
1276 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
1277 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
1278 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
1279 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
1280 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
1281 CHECK_EXTENSION(NV_vertex_program);
Brian Paulbc42c192002-01-05 21:53:20 +00001282 {
1283 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
1284 return ctx->Eval.Map1Attrib[map];
1285 }
Brian Paul86b84272001-12-14 02:50:01 +00001286 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
1287 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
1288 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
1289 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
1290 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
1291 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
1292 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
1293 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
1294 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
1295 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
1296 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
1297 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
1298 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
1299 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
1300 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
1301 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
1302 CHECK_EXTENSION(NV_vertex_program);
Brian Paulbc42c192002-01-05 21:53:20 +00001303 {
1304 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
1305 return ctx->Eval.Map2Attrib[map];
1306 }
Brian Paul8dfc5b92002-10-16 17:57:51 +00001307#endif /* FEATURE_NV_vertex_program */
Brian Paul86b84272001-12-14 02:50:01 +00001308
Brian Paul610d5992003-01-14 04:55:45 +00001309#if FEATURE_NV_fragment_program
1310 case GL_FRAGMENT_PROGRAM_NV:
1311 CHECK_EXTENSION(NV_fragment_program);
1312 return ctx->FragmentProgram.Enabled;
1313#endif /* FEATURE_NV_fragment_program */
1314
Brian Paul8afe7de2002-06-15 03:03:06 +00001315 /* GL_NV_texture_rectangle */
1316 case GL_TEXTURE_RECTANGLE_NV:
1317 CHECK_EXTENSION(NV_texture_rectangle);
Ian Romanick58dacc82007-05-09 21:45:27 -07001318 return is_texture_enabled(ctx, TEXTURE_RECT_BIT);
Brian Paul8afe7de2002-06-15 03:03:06 +00001319
Brian Paul5f60a0b2002-09-06 02:56:08 +00001320 /* GL_EXT_stencil_two_side */
1321 case GL_STENCIL_TEST_TWO_SIDE_EXT:
1322 CHECK_EXTENSION(EXT_stencil_two_side);
1323 return ctx->Stencil.TestTwoSide;
1324
Brian Paul77eec612003-04-18 01:56:11 +00001325#if FEATURE_ARB_fragment_program
1326 case GL_FRAGMENT_PROGRAM_ARB:
1327 return ctx->FragmentProgram.Enabled;
1328#endif /* FEATURE_ARB_fragment_program */
1329
Brian Paule5b244f2003-04-21 15:02:17 +00001330 /* GL_EXT_depth_bounds_test */
1331 case GL_DEPTH_BOUNDS_TEST_EXT:
1332 CHECK_EXTENSION(EXT_depth_bounds_test);
1333 return ctx->Depth.BoundsTest;
1334
Brian Paul08ff0592003-07-21 04:22:40 +00001335 /* GL_MESA_program_debug */
1336 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
1337 CHECK_EXTENSION(MESA_program_debug);
1338 return ctx->FragmentProgram.CallbackEnabled;
1339 case GL_VERTEX_PROGRAM_CALLBACK_MESA:
1340 CHECK_EXTENSION(MESA_program_debug);
1341 return ctx->VertexProgram.CallbackEnabled;
Dave Airlie7f752fe2004-12-19 03:06:59 +00001342#if FEATURE_ATI_fragment_shader
1343 case GL_FRAGMENT_SHADER_ATI:
1344 CHECK_EXTENSION(ATI_fragment_shader);
1345 return ctx->ATIFragmentShader.Enabled;
1346#endif /* FEATURE_ATI_fragment_shader */
jtgafb833d1999-08-19 00:55:39 +00001347 default:
Brian Paul4e9676f2002-06-29 19:48:15 +00001348 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap);
jtgafb833d1999-08-19 00:55:39 +00001349 return GL_FALSE;
1350 }
1351}