blob: e0483a72e816fda7387240f64bf78d4126b9ed9b [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
Brian454043c2007-12-03 14:14:16 -07008 * Version: 7.0.3
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00009 *
Brian454043c2007-12-03 14:14:16 -070010 * Copyright (C) 1999-2007 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"
Krzysztof Czurylo6f4fd3a2008-08-21 15:01:20 -070041#include "api_arrayelt.h"
Brian Paul3c634522002-10-24 23:57:19 +000042
jtgafb833d1999-08-19 00:55:39 +000043
44
Brian Paul02c03ef2002-06-18 16:53:46 +000045#define CHECK_EXTENSION(EXTNAME, CAP) \
Brian Paul86b84272001-12-14 02:50:01 +000046 if (!ctx->Extensions.EXTNAME) { \
Brian Paul4e9676f2002-06-29 19:48:15 +000047 _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \
48 state ? "Enable" : "Disable", CAP); \
Brian Paul86b84272001-12-14 02:50:01 +000049 return; \
50 }
51
Brian Paul86b84272001-12-14 02:50:01 +000052
Brian8dcfcad72006-12-13 15:31:14 -070053/**
54 * Helper to enable/disable client-side state.
55 */
Keith Whitwellcab974c2000-12-26 05:09:27 +000056static void
Brian8dcfcad72006-12-13 15:31:14 -070057client_state(GLcontext *ctx, GLenum cap, GLboolean state)
Keith Whitwellcab974c2000-12-26 05:09:27 +000058{
59 GLuint flag;
Keith Whitwell99efde42006-10-30 16:44:13 +000060 GLboolean *var;
Keith Whitwellcab974c2000-12-26 05:09:27 +000061
62 switch (cap) {
Brian Paul86b84272001-12-14 02:50:01 +000063 case GL_VERTEX_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000064 var = &ctx->Array.ArrayObj->Vertex.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000065 flag = _NEW_ARRAY_VERTEX;
66 break;
67 case GL_NORMAL_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000068 var = &ctx->Array.ArrayObj->Normal.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000069 flag = _NEW_ARRAY_NORMAL;
70 break;
71 case GL_COLOR_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000072 var = &ctx->Array.ArrayObj->Color.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000073 flag = _NEW_ARRAY_COLOR0;
74 break;
75 case GL_INDEX_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000076 var = &ctx->Array.ArrayObj->Index.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000077 flag = _NEW_ARRAY_INDEX;
78 break;
79 case GL_TEXTURE_COORD_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000080 var = &ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000081 flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture);
82 break;
83 case GL_EDGE_FLAG_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +000084 var = &ctx->Array.ArrayObj->EdgeFlag.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000085 flag = _NEW_ARRAY_EDGEFLAG;
86 break;
87 case GL_FOG_COORDINATE_ARRAY_EXT:
Ian Romanickee34e6e2006-06-12 16:26:29 +000088 var = &ctx->Array.ArrayObj->FogCoord.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000089 flag = _NEW_ARRAY_FOGCOORD;
90 break;
91 case GL_SECONDARY_COLOR_ARRAY_EXT:
Ian Romanickee34e6e2006-06-12 16:26:29 +000092 var = &ctx->Array.ArrayObj->SecondaryColor.Enabled;
Brian Paul86b84272001-12-14 02:50:01 +000093 flag = _NEW_ARRAY_COLOR1;
94 break;
95
Brian Paul1cf2c8a2008-06-25 08:45:14 -060096#if FEATURE_point_size_array
97 case GL_POINT_SIZE_ARRAY_OES:
98 var = &ctx->Array.ArrayObj->PointSize.Enabled;
99 flag = _NEW_ARRAY_POINT_SIZE;
100 break;
101#endif
102
Brian Paul8dfc5b92002-10-16 17:57:51 +0000103#if FEATURE_NV_vertex_program
Brian Paul86b84272001-12-14 02:50:01 +0000104 case GL_VERTEX_ATTRIB_ARRAY0_NV:
105 case GL_VERTEX_ATTRIB_ARRAY1_NV:
106 case GL_VERTEX_ATTRIB_ARRAY2_NV:
107 case GL_VERTEX_ATTRIB_ARRAY3_NV:
108 case GL_VERTEX_ATTRIB_ARRAY4_NV:
109 case GL_VERTEX_ATTRIB_ARRAY5_NV:
110 case GL_VERTEX_ATTRIB_ARRAY6_NV:
111 case GL_VERTEX_ATTRIB_ARRAY7_NV:
112 case GL_VERTEX_ATTRIB_ARRAY8_NV:
113 case GL_VERTEX_ATTRIB_ARRAY9_NV:
114 case GL_VERTEX_ATTRIB_ARRAY10_NV:
115 case GL_VERTEX_ATTRIB_ARRAY11_NV:
116 case GL_VERTEX_ATTRIB_ARRAY12_NV:
117 case GL_VERTEX_ATTRIB_ARRAY13_NV:
118 case GL_VERTEX_ATTRIB_ARRAY14_NV:
119 case GL_VERTEX_ATTRIB_ARRAY15_NV:
Brian Paul02c03ef2002-06-18 16:53:46 +0000120 CHECK_EXTENSION(NV_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000121 {
122 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
Ian Romanickee34e6e2006-06-12 16:26:29 +0000123 var = &ctx->Array.ArrayObj->VertexAttrib[n].Enabled;
Brian Paulb7752722002-04-21 18:49:18 +0000124 flag = _NEW_ARRAY_ATTRIB(n);
Brian Paul86b84272001-12-14 02:50:01 +0000125 }
126 break;
Brian Paul8dfc5b92002-10-16 17:57:51 +0000127#endif /* FEATURE_NV_vertex_program */
128
Brian Paul86b84272001-12-14 02:50:01 +0000129 default:
Brian Paul4e9676f2002-06-29 19:48:15 +0000130 _mesa_error( ctx, GL_INVALID_ENUM,
131 "glEnable/DisableClientState(0x%x)", cap);
Brian Paul86b84272001-12-14 02:50:01 +0000132 return;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000133 }
134
Alan Hourihane68c48df2002-04-19 08:38:23 +0000135 if (*var == state)
Keith Whitwellcab974c2000-12-26 05:09:27 +0000136 return;
137
138 FLUSH_VERTICES(ctx, _NEW_ARRAY);
139 ctx->Array.NewState |= flag;
Krzysztof Czurylo6f4fd3a2008-08-21 15:01:20 -0700140
141 _ae_invalidate_state(ctx, _NEW_ARRAY);
142
Keith Whitwellcab974c2000-12-26 05:09:27 +0000143 *var = state;
144
Gareth Hughes22144ab2001-03-12 00:48:37 +0000145 if (state)
Ian Romanickee34e6e2006-06-12 16:26:29 +0000146 ctx->Array.ArrayObj->_Enabled |= flag;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000147 else
Ian Romanickee34e6e2006-06-12 16:26:29 +0000148 ctx->Array.ArrayObj->_Enabled &= ~flag;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000149
150 if (ctx->Driver.Enable) {
Brian8dcfcad72006-12-13 15:31:14 -0700151 ctx->Driver.Enable( ctx, cap, state );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000152 }
153}
154
155
Keith Whitwell6dc85572003-07-17 13:43:59 +0000156/**
157 * Enable GL capability.
Brian8dcfcad72006-12-13 15:31:14 -0700158 * \param cap state to enable/disable.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000159 *
160 * Get's the current context, assures that we're outside glBegin()/glEnd() and
161 * calls client_state().
162 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000163void GLAPIENTRY
Keith Whitwellcab974c2000-12-26 05:09:27 +0000164_mesa_EnableClientState( GLenum cap )
165{
166 GET_CURRENT_CONTEXT(ctx);
167 ASSERT_OUTSIDE_BEGIN_END(ctx);
168 client_state( ctx, cap, GL_TRUE );
169}
170
171
Keith Whitwell6dc85572003-07-17 13:43:59 +0000172/**
173 * Disable GL capability.
Brian8dcfcad72006-12-13 15:31:14 -0700174 * \param cap state to enable/disable.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000175 *
176 * Get's the current context, assures that we're outside glBegin()/glEnd() and
177 * calls client_state().
178 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000179void GLAPIENTRY
Keith Whitwellcab974c2000-12-26 05:09:27 +0000180_mesa_DisableClientState( GLenum cap )
181{
182 GET_CURRENT_CONTEXT(ctx);
183 ASSERT_OUTSIDE_BEGIN_END(ctx);
184 client_state( ctx, cap, GL_FALSE );
185}
186
jtgafb833d1999-08-19 00:55:39 +0000187
Brian Paul86b84272001-12-14 02:50:01 +0000188#undef CHECK_EXTENSION
Brian Paul02c03ef2002-06-18 16:53:46 +0000189#define CHECK_EXTENSION(EXTNAME, CAP) \
190 if (!ctx->Extensions.EXTNAME) { \
Brian Paul4e9676f2002-06-29 19:48:15 +0000191 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
192 state ? "Enable" : "Disable", CAP); \
Brian Paul02c03ef2002-06-18 16:53:46 +0000193 return; \
Brian Paul86b84272001-12-14 02:50:01 +0000194 }
195
Brian Paulefb2ade2004-08-18 18:45:25 +0000196#define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
197 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
198 _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
199 state ? "Enable" : "Disable", CAP); \
200 return; \
201 }
202
203
Ian Romanick58dacc82007-05-09 21:45:27 -0700204/**
205 * Helper function to enable or disable a texture target.
206 */
207static GLboolean
Ian Romanickc9e723e2007-05-10 08:20:04 -0700208enable_texture(GLcontext *ctx, GLboolean state, GLbitfield bit)
Ian Romanick58dacc82007-05-09 21:45:27 -0700209{
210 const GLuint curr = ctx->Texture.CurrentUnit;
211 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
Ian Romanick64a6a502007-05-10 15:00:41 -0700212 const GLuint newenabled = (!state)
Ian Romanick58dacc82007-05-09 21:45:27 -0700213 ? (texUnit->Enabled & ~bit) : (texUnit->Enabled | bit);
214
215 if (!ctx->DrawBuffer->Visual.rgbMode || texUnit->Enabled == newenabled)
216 return GL_FALSE;
217
218 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
219 texUnit->Enabled = newenabled;
220 return GL_TRUE;
221}
222
Brian Paul86b84272001-12-14 02:50:01 +0000223
Keith Whitwell6dc85572003-07-17 13:43:59 +0000224/**
Brian8dcfcad72006-12-13 15:31:14 -0700225 * Helper function to enable or disable state.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000226 *
227 * \param ctx GL context.
Brian8dcfcad72006-12-13 15:31:14 -0700228 * \param cap the state to enable/disable
Keith Whitwell6dc85572003-07-17 13:43:59 +0000229 * \param state whether to enable or disable the specified capability.
230 *
231 * Updates the current context and flushes the vertices as needed. For
232 * capabilities associated with extensions it verifies that those extensions
233 * are effectivly present before updating. Notifies the driver via
234 * dd_function_table::Enable.
jtgafb833d1999-08-19 00:55:39 +0000235 */
Brian8dcfcad72006-12-13 15:31:14 -0700236void
237_mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
jtgafb833d1999-08-19 00:55:39 +0000238{
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +0000239 if (MESA_VERBOSE & VERBOSE_API)
Brian Paul4753d602002-06-15 02:38:15 +0000240 _mesa_debug(ctx, "%s %s (newstate is %x)\n",
Brian Paul9a33a112002-06-13 04:28:29 +0000241 state ? "glEnable" : "glDisable",
242 _mesa_lookup_enum_by_nr(cap),
243 ctx->NewState);
jtgafb833d1999-08-19 00:55:39 +0000244
245 switch (cap) {
Brian Paul86b84272001-12-14 02:50:01 +0000246 case GL_ALPHA_TEST:
247 if (ctx->Color.AlphaEnabled == state)
248 return;
249 FLUSH_VERTICES(ctx, _NEW_COLOR);
250 ctx->Color.AlphaEnabled = state;
251 break;
252 case GL_AUTO_NORMAL:
253 if (ctx->Eval.AutoNormal == state)
254 return;
255 FLUSH_VERTICES(ctx, _NEW_EVAL);
256 ctx->Eval.AutoNormal = state;
257 break;
258 case GL_BLEND:
259 if (ctx->Color.BlendEnabled == state)
260 return;
261 FLUSH_VERTICES(ctx, _NEW_COLOR);
262 ctx->Color.BlendEnabled = state;
Brian Paul86b84272001-12-14 02:50:01 +0000263 break;
Keith Whitwell6dc85572003-07-17 13:43:59 +0000264#if FEATURE_userclip
Brian Paul86b84272001-12-14 02:50:01 +0000265 case GL_CLIP_PLANE0:
266 case GL_CLIP_PLANE1:
267 case GL_CLIP_PLANE2:
268 case GL_CLIP_PLANE3:
269 case GL_CLIP_PLANE4:
270 case GL_CLIP_PLANE5:
271 {
Brian Paul103bc0f2002-03-29 17:27:59 +0000272 const GLuint p = cap - GL_CLIP_PLANE0;
jtgafb833d1999-08-19 00:55:39 +0000273
Brian Pauldb07de02002-04-19 00:23:08 +0000274 if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p))
Brian Paul86b84272001-12-14 02:50:01 +0000275 return;
Gareth Hughes22144ab2001-03-12 00:48:37 +0000276
Brian Paul86b84272001-12-14 02:50:01 +0000277 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
jtgafb833d1999-08-19 00:55:39 +0000278
Brian Paul86b84272001-12-14 02:50:01 +0000279 if (state) {
Brian Paul103bc0f2002-03-29 17:27:59 +0000280 ctx->Transform.ClipPlanesEnabled |= (1 << p);
Keith Whitwellcab974c2000-12-26 05:09:27 +0000281
Brian Paul049e3202005-06-30 14:22:23 +0000282 if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
Brian Paul30f51ae2001-12-18 04:06:44 +0000283 _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
Gareth Hughes22144ab2001-03-12 00:48:37 +0000284
Brian Paul86b84272001-12-14 02:50:01 +0000285 /* This derived state also calculated in clip.c and
286 * from _mesa_update_state() on changes to EyeUserPlane
287 * and ctx->ProjectionMatrix respectively.
288 */
289 _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
290 ctx->Transform.EyeUserPlane[p],
Brian Paul30f51ae2001-12-18 04:06:44 +0000291 ctx->ProjectionMatrixStack.Top->inv );
Brian Paul86b84272001-12-14 02:50:01 +0000292 }
Brian Paulf66de792002-03-28 22:45:45 +0000293 else {
Brian Paul103bc0f2002-03-29 17:27:59 +0000294 ctx->Transform.ClipPlanesEnabled &= ~(1 << p);
Brian Paulf66de792002-03-28 22:45:45 +0000295 }
Brian Paul86b84272001-12-14 02:50:01 +0000296 }
297 break;
Keith Whitwell6dc85572003-07-17 13:43:59 +0000298#endif
Brian Paul86b84272001-12-14 02:50:01 +0000299 case GL_COLOR_MATERIAL:
300 if (ctx->Light.ColorMaterialEnabled == state)
301 return;
302 FLUSH_VERTICES(ctx, _NEW_LIGHT);
Brian Pauld40f9fa2003-03-21 13:18:33 +0000303 FLUSH_CURRENT(ctx, 0);
Brian Paul86b84272001-12-14 02:50:01 +0000304 ctx->Light.ColorMaterialEnabled = state;
305 if (state) {
Brian Paul86b84272001-12-14 02:50:01 +0000306 _mesa_update_color_material( ctx,
307 ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
308 }
309 break;
310 case GL_CULL_FACE:
311 if (ctx->Polygon.CullFlag == state)
312 return;
313 FLUSH_VERTICES(ctx, _NEW_POLYGON);
314 ctx->Polygon.CullFlag = state;
315 break;
Keith Whitwell352d4db2004-05-10 18:16:03 +0000316 case GL_CULL_VERTEX_EXT:
317 CHECK_EXTENSION(EXT_cull_vertex, cap);
318 if (ctx->Transform.CullVertexFlag == state)
319 return;
320 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
321 ctx->Transform.CullVertexFlag = state;
322 break;
Brian Paul86b84272001-12-14 02:50:01 +0000323 case GL_DEPTH_TEST:
Brian Paule4b23562005-05-04 20:11:35 +0000324 if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
Brian Paul86b84272001-12-14 02:50:01 +0000325 _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
326 return;
327 }
Brian8dcfcad72006-12-13 15:31:14 -0700328 if (ctx->Depth.Test == state)
Brian Paul86b84272001-12-14 02:50:01 +0000329 return;
330 FLUSH_VERTICES(ctx, _NEW_DEPTH);
331 ctx->Depth.Test = state;
332 break;
333 case GL_DITHER:
334 if (ctx->NoDither) {
335 state = GL_FALSE; /* MESA_NO_DITHER env var */
336 }
Brian8dcfcad72006-12-13 15:31:14 -0700337 if (ctx->Color.DitherFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000338 return;
339 FLUSH_VERTICES(ctx, _NEW_COLOR);
340 ctx->Color.DitherFlag = state;
341 break;
342 case GL_FOG:
Brian8dcfcad72006-12-13 15:31:14 -0700343 if (ctx->Fog.Enabled == state)
Brian Paul86b84272001-12-14 02:50:01 +0000344 return;
345 FLUSH_VERTICES(ctx, _NEW_FOG);
346 ctx->Fog.Enabled = state;
347 break;
348 case GL_HISTOGRAM:
Brian Paul02c03ef2002-06-18 16:53:46 +0000349 CHECK_EXTENSION(EXT_histogram, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000350 if (ctx->Pixel.HistogramEnabled == state)
351 return;
352 FLUSH_VERTICES(ctx, _NEW_PIXEL);
353 ctx->Pixel.HistogramEnabled = state;
354 break;
355 case GL_LIGHT0:
356 case GL_LIGHT1:
357 case GL_LIGHT2:
358 case GL_LIGHT3:
359 case GL_LIGHT4:
360 case GL_LIGHT5:
361 case GL_LIGHT6:
362 case GL_LIGHT7:
363 if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state)
364 return;
365 FLUSH_VERTICES(ctx, _NEW_LIGHT);
366 ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
367 if (state) {
368 insert_at_tail(&ctx->Light.EnabledList,
369 &ctx->Light.Light[cap-GL_LIGHT0]);
370 }
371 else {
372 remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
373 }
374 break;
375 case GL_LIGHTING:
376 if (ctx->Light.Enabled == state)
377 return;
Brian454043c2007-12-03 14:14:16 -0700378 FLUSH_VERTICES(ctx, _NEW_LIGHT);
379 ctx->Light.Enabled = state;
Brianed6d5ff2007-09-27 10:24:17 -0600380 if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
381 ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
382 else
383 ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
Brian Paul86b84272001-12-14 02:50:01 +0000384 break;
385 case GL_LINE_SMOOTH:
386 if (ctx->Line.SmoothFlag == state)
387 return;
388 FLUSH_VERTICES(ctx, _NEW_LINE);
389 ctx->Line.SmoothFlag = state;
Brianed6d5ff2007-09-27 10:24:17 -0600390 ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
Brian Paul86b84272001-12-14 02:50:01 +0000391 break;
392 case GL_LINE_STIPPLE:
393 if (ctx->Line.StippleFlag == state)
394 return;
395 FLUSH_VERTICES(ctx, _NEW_LINE);
396 ctx->Line.StippleFlag = state;
Brianed6d5ff2007-09-27 10:24:17 -0600397 ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
Brian Paul86b84272001-12-14 02:50:01 +0000398 break;
399 case GL_INDEX_LOGIC_OP:
400 if (ctx->Color.IndexLogicOpEnabled == state)
401 return;
402 FLUSH_VERTICES(ctx, _NEW_COLOR);
403 ctx->Color.IndexLogicOpEnabled = state;
404 break;
405 case GL_COLOR_LOGIC_OP:
406 if (ctx->Color.ColorLogicOpEnabled == state)
407 return;
408 FLUSH_VERTICES(ctx, _NEW_COLOR);
409 ctx->Color.ColorLogicOpEnabled = state;
410 break;
411 case GL_MAP1_COLOR_4:
412 if (ctx->Eval.Map1Color4 == state)
413 return;
414 FLUSH_VERTICES(ctx, _NEW_EVAL);
415 ctx->Eval.Map1Color4 = state;
416 break;
417 case GL_MAP1_INDEX:
418 if (ctx->Eval.Map1Index == state)
419 return;
420 FLUSH_VERTICES(ctx, _NEW_EVAL);
421 ctx->Eval.Map1Index = state;
422 break;
423 case GL_MAP1_NORMAL:
424 if (ctx->Eval.Map1Normal == state)
425 return;
426 FLUSH_VERTICES(ctx, _NEW_EVAL);
427 ctx->Eval.Map1Normal = state;
428 break;
429 case GL_MAP1_TEXTURE_COORD_1:
430 if (ctx->Eval.Map1TextureCoord1 == state)
431 return;
432 FLUSH_VERTICES(ctx, _NEW_EVAL);
433 ctx->Eval.Map1TextureCoord1 = state;
434 break;
435 case GL_MAP1_TEXTURE_COORD_2:
436 if (ctx->Eval.Map1TextureCoord2 == state)
437 return;
438 FLUSH_VERTICES(ctx, _NEW_EVAL);
439 ctx->Eval.Map1TextureCoord2 = state;
440 break;
441 case GL_MAP1_TEXTURE_COORD_3:
442 if (ctx->Eval.Map1TextureCoord3 == state)
443 return;
444 FLUSH_VERTICES(ctx, _NEW_EVAL);
445 ctx->Eval.Map1TextureCoord3 = state;
446 break;
447 case GL_MAP1_TEXTURE_COORD_4:
448 if (ctx->Eval.Map1TextureCoord4 == state)
449 return;
450 FLUSH_VERTICES(ctx, _NEW_EVAL);
451 ctx->Eval.Map1TextureCoord4 = state;
452 break;
453 case GL_MAP1_VERTEX_3:
454 if (ctx->Eval.Map1Vertex3 == state)
455 return;
456 FLUSH_VERTICES(ctx, _NEW_EVAL);
457 ctx->Eval.Map1Vertex3 = state;
458 break;
459 case GL_MAP1_VERTEX_4:
460 if (ctx->Eval.Map1Vertex4 == state)
461 return;
462 FLUSH_VERTICES(ctx, _NEW_EVAL);
463 ctx->Eval.Map1Vertex4 = state;
464 break;
465 case GL_MAP2_COLOR_4:
466 if (ctx->Eval.Map2Color4 == state)
467 return;
468 FLUSH_VERTICES(ctx, _NEW_EVAL);
469 ctx->Eval.Map2Color4 = state;
470 break;
471 case GL_MAP2_INDEX:
472 if (ctx->Eval.Map2Index == state)
473 return;
474 FLUSH_VERTICES(ctx, _NEW_EVAL);
475 ctx->Eval.Map2Index = state;
476 break;
477 case GL_MAP2_NORMAL:
478 if (ctx->Eval.Map2Normal == state)
479 return;
480 FLUSH_VERTICES(ctx, _NEW_EVAL);
481 ctx->Eval.Map2Normal = state;
482 break;
483 case GL_MAP2_TEXTURE_COORD_1:
484 if (ctx->Eval.Map2TextureCoord1 == state)
485 return;
486 FLUSH_VERTICES(ctx, _NEW_EVAL);
487 ctx->Eval.Map2TextureCoord1 = state;
488 break;
489 case GL_MAP2_TEXTURE_COORD_2:
490 if (ctx->Eval.Map2TextureCoord2 == state)
491 return;
492 FLUSH_VERTICES(ctx, _NEW_EVAL);
493 ctx->Eval.Map2TextureCoord2 = state;
494 break;
495 case GL_MAP2_TEXTURE_COORD_3:
496 if (ctx->Eval.Map2TextureCoord3 == state)
497 return;
498 FLUSH_VERTICES(ctx, _NEW_EVAL);
499 ctx->Eval.Map2TextureCoord3 = state;
500 break;
501 case GL_MAP2_TEXTURE_COORD_4:
502 if (ctx->Eval.Map2TextureCoord4 == state)
503 return;
504 FLUSH_VERTICES(ctx, _NEW_EVAL);
505 ctx->Eval.Map2TextureCoord4 = state;
506 break;
507 case GL_MAP2_VERTEX_3:
508 if (ctx->Eval.Map2Vertex3 == state)
509 return;
510 FLUSH_VERTICES(ctx, _NEW_EVAL);
511 ctx->Eval.Map2Vertex3 = state;
512 break;
513 case GL_MAP2_VERTEX_4:
514 if (ctx->Eval.Map2Vertex4 == state)
515 return;
516 FLUSH_VERTICES(ctx, _NEW_EVAL);
517 ctx->Eval.Map2Vertex4 = state;
518 break;
519 case GL_MINMAX:
520 if (ctx->Pixel.MinMaxEnabled == state)
521 return;
522 FLUSH_VERTICES(ctx, _NEW_PIXEL);
523 ctx->Pixel.MinMaxEnabled = state;
524 break;
525 case GL_NORMALIZE:
526 if (ctx->Transform.Normalize == state)
527 return;
528 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
529 ctx->Transform.Normalize = state;
530 break;
531 case GL_POINT_SMOOTH:
Brian8dcfcad72006-12-13 15:31:14 -0700532 if (ctx->Point.SmoothFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000533 return;
534 FLUSH_VERTICES(ctx, _NEW_POINT);
535 ctx->Point.SmoothFlag = state;
Brianed6d5ff2007-09-27 10:24:17 -0600536 ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
Brian Paul86b84272001-12-14 02:50:01 +0000537 break;
538 case GL_POLYGON_SMOOTH:
Brian8dcfcad72006-12-13 15:31:14 -0700539 if (ctx->Polygon.SmoothFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000540 return;
541 FLUSH_VERTICES(ctx, _NEW_POLYGON);
542 ctx->Polygon.SmoothFlag = state;
Brianed6d5ff2007-09-27 10:24:17 -0600543 ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
Brian Paul86b84272001-12-14 02:50:01 +0000544 break;
545 case GL_POLYGON_STIPPLE:
Brian8dcfcad72006-12-13 15:31:14 -0700546 if (ctx->Polygon.StippleFlag == state)
Brian Paul86b84272001-12-14 02:50:01 +0000547 return;
548 FLUSH_VERTICES(ctx, _NEW_POLYGON);
549 ctx->Polygon.StippleFlag = state;
Brianed6d5ff2007-09-27 10:24:17 -0600550 ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
Brian Paul86b84272001-12-14 02:50:01 +0000551 break;
552 case GL_POLYGON_OFFSET_POINT:
Brian8dcfcad72006-12-13 15:31:14 -0700553 if (ctx->Polygon.OffsetPoint == state)
Brian Paul86b84272001-12-14 02:50:01 +0000554 return;
555 FLUSH_VERTICES(ctx, _NEW_POLYGON);
556 ctx->Polygon.OffsetPoint = state;
557 break;
558 case GL_POLYGON_OFFSET_LINE:
Brian8dcfcad72006-12-13 15:31:14 -0700559 if (ctx->Polygon.OffsetLine == state)
Brian Paul86b84272001-12-14 02:50:01 +0000560 return;
561 FLUSH_VERTICES(ctx, _NEW_POLYGON);
562 ctx->Polygon.OffsetLine = state;
563 break;
564 case GL_POLYGON_OFFSET_FILL:
565 /*case GL_POLYGON_OFFSET_EXT:*/
Brian8dcfcad72006-12-13 15:31:14 -0700566 if (ctx->Polygon.OffsetFill == state)
Brian Paul86b84272001-12-14 02:50:01 +0000567 return;
568 FLUSH_VERTICES(ctx, _NEW_POLYGON);
569 ctx->Polygon.OffsetFill = state;
570 break;
571 case GL_RESCALE_NORMAL_EXT:
572 if (ctx->Transform.RescaleNormals == state)
573 return;
574 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
575 ctx->Transform.RescaleNormals = state;
576 break;
577 case GL_SCISSOR_TEST:
Brian8dcfcad72006-12-13 15:31:14 -0700578 if (ctx->Scissor.Enabled == state)
Brian Paul86b84272001-12-14 02:50:01 +0000579 return;
580 FLUSH_VERTICES(ctx, _NEW_SCISSOR);
581 ctx->Scissor.Enabled = state;
582 break;
583 case GL_SHARED_TEXTURE_PALETTE_EXT:
584 if (ctx->Texture.SharedPalette == state)
585 return;
586 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
587 ctx->Texture.SharedPalette = state;
588 break;
589 case GL_STENCIL_TEST:
Brian Paule4b23562005-05-04 20:11:35 +0000590 if (state && ctx->DrawBuffer->Visual.stencilBits == 0) {
Brian Paul86b84272001-12-14 02:50:01 +0000591 _mesa_warning(ctx,
592 "glEnable(GL_STENCIL_TEST) but no stencil buffer");
593 return;
594 }
Brian8dcfcad72006-12-13 15:31:14 -0700595 if (ctx->Stencil.Enabled == state)
Brian Paul86b84272001-12-14 02:50:01 +0000596 return;
597 FLUSH_VERTICES(ctx, _NEW_STENCIL);
598 ctx->Stencil.Enabled = state;
599 break;
Ian Romanick58dacc82007-05-09 21:45:27 -0700600 case GL_TEXTURE_1D:
601 if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) {
Brian Paul86b84272001-12-14 02:50:01 +0000602 return;
Ian Romanick58dacc82007-05-09 21:45:27 -0700603 }
Brian Paul86b84272001-12-14 02:50:01 +0000604 break;
Ian Romanick58dacc82007-05-09 21:45:27 -0700605 case GL_TEXTURE_2D:
606 if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) {
Brian Paul86b84272001-12-14 02:50:01 +0000607 return;
Ian Romanick58dacc82007-05-09 21:45:27 -0700608 }
Brian Paul86b84272001-12-14 02:50:01 +0000609 break;
Ian Romanick58dacc82007-05-09 21:45:27 -0700610 case GL_TEXTURE_3D:
611 if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) {
Brian Paul86b84272001-12-14 02:50:01 +0000612 return;
Ian Romanick58dacc82007-05-09 21:45:27 -0700613 }
Brian Paul86b84272001-12-14 02:50:01 +0000614 break;
Brian Paul86b84272001-12-14 02:50:01 +0000615 case GL_TEXTURE_GEN_Q: {
616 GLuint unit = ctx->Texture.CurrentUnit;
617 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
618 GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
619 if (state)
620 newenabled |= Q_BIT;
621 if (texUnit->TexGenEnabled == newenabled)
622 return;
623 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
624 texUnit->TexGenEnabled = newenabled;
625 break;
626 }
627 case GL_TEXTURE_GEN_R: {
628 GLuint unit = ctx->Texture.CurrentUnit;
629 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
630 GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
631 if (state)
632 newenabled |= R_BIT;
633 if (texUnit->TexGenEnabled == newenabled)
634 return;
635 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
636 texUnit->TexGenEnabled = newenabled;
637 break;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000638 }
Brian Paul86b84272001-12-14 02:50:01 +0000639 case GL_TEXTURE_GEN_S: {
640 GLuint unit = ctx->Texture.CurrentUnit;
641 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
642 GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
643 if (state)
644 newenabled |= S_BIT;
645 if (texUnit->TexGenEnabled == newenabled)
646 return;
647 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
648 texUnit->TexGenEnabled = newenabled;
649 break;
Keith Whitwellcab974c2000-12-26 05:09:27 +0000650 }
Brian Paul86b84272001-12-14 02:50:01 +0000651 case GL_TEXTURE_GEN_T: {
652 GLuint unit = ctx->Texture.CurrentUnit;
653 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
654 GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
655 if (state)
656 newenabled |= T_BIT;
657 if (texUnit->TexGenEnabled == newenabled)
658 return;
659 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
660 texUnit->TexGenEnabled = newenabled;
661 break;
662 }
Keith Whitwell46b09882001-02-16 18:14:41 +0000663
Brian Paul86b84272001-12-14 02:50:01 +0000664 /*
665 * CLIENT STATE!!!
666 */
667 case GL_VERTEX_ARRAY:
668 case GL_NORMAL_ARRAY:
669 case GL_COLOR_ARRAY:
670 case GL_INDEX_ARRAY:
671 case GL_TEXTURE_COORD_ARRAY:
672 case GL_EDGE_FLAG_ARRAY:
673 case GL_FOG_COORDINATE_ARRAY_EXT:
674 case GL_SECONDARY_COLOR_ARRAY_EXT:
Brian Paul1cf2c8a2008-06-25 08:45:14 -0600675 case GL_POINT_SIZE_ARRAY_OES:
Brian Paul86b84272001-12-14 02:50:01 +0000676 client_state( ctx, cap, state );
677 return;
jtgafb833d1999-08-19 00:55:39 +0000678
Brian Paul13811372000-04-12 00:27:37 +0000679 /* GL_SGI_color_table */
Brian Paul86b84272001-12-14 02:50:01 +0000680 case GL_COLOR_TABLE_SGI:
Brian Paul02c03ef2002-06-18 16:53:46 +0000681 CHECK_EXTENSION(SGI_color_table, cap);
Brian7573b582007-03-16 09:36:12 -0600682 if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] == state)
Brian Paul86b84272001-12-14 02:50:01 +0000683 return;
684 FLUSH_VERTICES(ctx, _NEW_PIXEL);
Brian7573b582007-03-16 09:36:12 -0600685 ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] = state;
Brian Paul86b84272001-12-14 02:50:01 +0000686 break;
687 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
Brian Paul02c03ef2002-06-18 16:53:46 +0000688 CHECK_EXTENSION(SGI_color_table, cap);
Brian7573b582007-03-16 09:36:12 -0600689 if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] == state)
Brian Paul86b84272001-12-14 02:50:01 +0000690 return;
691 FLUSH_VERTICES(ctx, _NEW_PIXEL);
Brian7573b582007-03-16 09:36:12 -0600692 ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] = state;
Brian Paul86b84272001-12-14 02:50:01 +0000693 break;
694 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
Brian Paul02c03ef2002-06-18 16:53:46 +0000695 CHECK_EXTENSION(SGI_color_table, cap);
Brian7573b582007-03-16 09:36:12 -0600696 if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] == state)
Brian Paul86b84272001-12-14 02:50:01 +0000697 return;
698 FLUSH_VERTICES(ctx, _NEW_PIXEL);
Brian7573b582007-03-16 09:36:12 -0600699 ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] = state;
Brian Paul86b84272001-12-14 02:50:01 +0000700 break;
Brian Paul418ac002003-01-21 21:47:45 +0000701 case GL_TEXTURE_COLOR_TABLE_SGI:
702 CHECK_EXTENSION(SGI_texture_color_table, cap);
Brian Paul45b47d02003-01-26 14:37:15 +0000703 if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state)
Brian Paul418ac002003-01-21 21:47:45 +0000704 return;
705 FLUSH_VERTICES(ctx, _NEW_TEXTURE);
Brian Paul45b47d02003-01-26 14:37:15 +0000706 ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state;
Brian Paul418ac002003-01-21 21:47:45 +0000707 break;
Brian Paul13811372000-04-12 00:27:37 +0000708
Brian Paul82b02f02000-05-07 20:37:40 +0000709 /* GL_EXT_convolution */
Brian Paul86b84272001-12-14 02:50:01 +0000710 case GL_CONVOLUTION_1D:
Brian Paul02c03ef2002-06-18 16:53:46 +0000711 CHECK_EXTENSION(EXT_convolution, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000712 if (ctx->Pixel.Convolution1DEnabled == state)
713 return;
714 FLUSH_VERTICES(ctx, _NEW_PIXEL);
715 ctx->Pixel.Convolution1DEnabled = state;
716 break;
717 case GL_CONVOLUTION_2D:
Brian Paul02c03ef2002-06-18 16:53:46 +0000718 CHECK_EXTENSION(EXT_convolution, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000719 if (ctx->Pixel.Convolution2DEnabled == state)
720 return;
721 FLUSH_VERTICES(ctx, _NEW_PIXEL);
722 ctx->Pixel.Convolution2DEnabled = state;
723 break;
724 case GL_SEPARABLE_2D:
Brian Paul02c03ef2002-06-18 16:53:46 +0000725 CHECK_EXTENSION(EXT_convolution, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000726 if (ctx->Pixel.Separable2DEnabled == state)
727 return;
728 FLUSH_VERTICES(ctx, _NEW_PIXEL);
729 ctx->Pixel.Separable2DEnabled = state;
730 break;
Brian Paul82b02f02000-05-07 20:37:40 +0000731
Brian Paul86fc3702000-05-22 16:33:20 +0000732 /* GL_ARB_texture_cube_map */
Brian Paul86b84272001-12-14 02:50:01 +0000733 case GL_TEXTURE_CUBE_MAP_ARB:
Ian Romanick58dacc82007-05-09 21:45:27 -0700734 CHECK_EXTENSION(ARB_texture_cube_map, cap);
735 if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) {
736 return;
Brian Paul86b84272001-12-14 02:50:01 +0000737 }
738 break;
739
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000740 /* GL_EXT_secondary_color */
Brian Paul86b84272001-12-14 02:50:01 +0000741 case GL_COLOR_SUM_EXT:
Roland Scheideggerda168132006-03-02 12:06:57 +0000742 CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000743 if (ctx->Fog.ColorSumEnabled == state)
744 return;
745 FLUSH_VERTICES(ctx, _NEW_FOG);
746 ctx->Fog.ColorSumEnabled = state;
Brian Paul86b84272001-12-14 02:50:01 +0000747 break;
Brian Paul06d05af2000-12-08 00:20:15 +0000748
Brian Paul736fcbe2001-05-29 15:23:48 +0000749 /* GL_ARB_multisample */
Brian Paul86b84272001-12-14 02:50:01 +0000750 case GL_MULTISAMPLE_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.Enabled == state)
753 return;
754 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
755 ctx->Multisample.Enabled = state;
756 break;
757 case GL_SAMPLE_ALPHA_TO_COVERAGE_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.SampleAlphaToCoverage == state)
760 return;
761 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
762 ctx->Multisample.SampleAlphaToCoverage = state;
763 break;
764 case GL_SAMPLE_ALPHA_TO_ONE_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.SampleAlphaToOne == state)
767 return;
768 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
769 ctx->Multisample.SampleAlphaToOne = state;
770 break;
771 case GL_SAMPLE_COVERAGE_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.SampleCoverage == state)
774 return;
775 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
776 ctx->Multisample.SampleCoverage = state;
777 break;
778 case GL_SAMPLE_COVERAGE_INVERT_ARB:
Brian Paul02c03ef2002-06-18 16:53:46 +0000779 CHECK_EXTENSION(ARB_multisample, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000780 if (ctx->Multisample.SampleCoverageInvert == state)
781 return;
782 FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
783 ctx->Multisample.SampleCoverageInvert = state;
784 break;
Brian Paul8c2f6c52001-06-26 01:32:48 +0000785
786 /* GL_IBM_rasterpos_clip */
Brian Paul86b84272001-12-14 02:50:01 +0000787 case GL_RASTER_POSITION_UNCLIPPED_IBM:
Brian Paul02c03ef2002-06-18 16:53:46 +0000788 CHECK_EXTENSION(IBM_rasterpos_clip, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000789 if (ctx->Transform.RasterPositionUnclipped == state)
790 return;
791 FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
792 ctx->Transform.RasterPositionUnclipped = state;
793 break;
Brian Paul736fcbe2001-05-29 15:23:48 +0000794
Brian Paul6c408b42002-05-27 17:04:52 +0000795 /* GL_NV_point_sprite */
796 case GL_POINT_SPRITE_NV:
Ian Romanick63736722003-08-23 00:12:46 +0000797 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap);
Brian Paul6c408b42002-05-27 17:04:52 +0000798 if (ctx->Point.PointSprite == state)
Brian Paul86b84272001-12-14 02:50:01 +0000799 return;
800 FLUSH_VERTICES(ctx, _NEW_POINT);
Brian Paul6c408b42002-05-27 17:04:52 +0000801 ctx->Point.PointSprite = state;
Brian Paul86b84272001-12-14 02:50:01 +0000802 break;
Keith Whitwellfe5d67d2000-10-27 16:44:40 +0000803
Roland Scheidegger93da6732006-03-01 23:11:14 +0000804#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
Roland Scheideggere1e03b32006-03-03 15:03:04 +0000805 case GL_VERTEX_PROGRAM_ARB:
806 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000807 if (ctx->VertexProgram.Enabled == 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.Enabled = state;
811 break;
Roland Scheideggere1e03b32006-03-03 15:03:04 +0000812 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
813 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000814 if (ctx->VertexProgram.PointSizeEnabled == 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.PointSizeEnabled = state;
818 break;
Roland Scheideggere1e03b32006-03-03 15:03:04 +0000819 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB:
820 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap);
Brian Paul86b84272001-12-14 02:50:01 +0000821 if (ctx->VertexProgram.TwoSideEnabled == state)
822 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000823 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul86b84272001-12-14 02:50:01 +0000824 ctx->VertexProgram.TwoSideEnabled = state;
825 break;
Roland Scheidegger93da6732006-03-01 23:11:14 +0000826#endif
827#if FEATURE_NV_vertex_program
Brian Paul86b84272001-12-14 02:50:01 +0000828 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
829 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
830 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
831 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
832 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
833 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
834 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
835 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
836 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
837 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
838 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
839 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
840 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
841 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
842 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
843 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
Brian Paul02c03ef2002-06-18 16:53:46 +0000844 CHECK_EXTENSION(NV_vertex_program, cap);
Brian Paulbc42c192002-01-05 21:53:20 +0000845 {
846 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
847 FLUSH_VERTICES(ctx, _NEW_EVAL);
848 ctx->Eval.Map1Attrib[map] = state;
849 }
Brian Paul86b84272001-12-14 02:50:01 +0000850 break;
851 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
852 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
853 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
854 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
855 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
856 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
857 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
858 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
859 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
860 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
861 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
862 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
863 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
864 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
865 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
866 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
Brian Paul02c03ef2002-06-18 16:53:46 +0000867 CHECK_EXTENSION(NV_vertex_program, cap);
Brian Paulbc42c192002-01-05 21:53:20 +0000868 {
869 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
870 FLUSH_VERTICES(ctx, _NEW_EVAL);
871 ctx->Eval.Map2Attrib[map] = state;
872 }
Brian Paul86b84272001-12-14 02:50:01 +0000873 break;
Brian Paul8dfc5b92002-10-16 17:57:51 +0000874#endif /* FEATURE_NV_vertex_program */
Brian Paul86b84272001-12-14 02:50:01 +0000875
Brian Paul610d5992003-01-14 04:55:45 +0000876#if FEATURE_NV_fragment_program
877 case GL_FRAGMENT_PROGRAM_NV:
878 CHECK_EXTENSION(NV_fragment_program, cap);
879 if (ctx->FragmentProgram.Enabled == state)
880 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000881 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul610d5992003-01-14 04:55:45 +0000882 ctx->FragmentProgram.Enabled = state;
883 break;
884#endif /* FEATURE_NV_fragment_program */
885
Brian Paul8afe7de2002-06-15 03:03:06 +0000886 /* GL_NV_texture_rectangle */
887 case GL_TEXTURE_RECTANGLE_NV:
Brian Paul5f60a0b2002-09-06 02:56:08 +0000888 CHECK_EXTENSION(NV_texture_rectangle, cap);
Ian Romanick58dacc82007-05-09 21:45:27 -0700889 if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) {
890 return;
Brian Paul8afe7de2002-06-15 03:03:06 +0000891 }
892 break;
893
Brian Paul5f60a0b2002-09-06 02:56:08 +0000894 /* GL_EXT_stencil_two_side */
895 case GL_STENCIL_TEST_TWO_SIDE_EXT:
896 CHECK_EXTENSION(EXT_stencil_two_side, cap);
897 if (ctx->Stencil.TestTwoSide == state)
898 return;
899 FLUSH_VERTICES(ctx, _NEW_STENCIL);
900 ctx->Stencil.TestTwoSide = state;
Brianed6d5ff2007-09-27 10:24:17 -0600901 if (state)
902 ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
903 else
904 ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL;
Brian Paul5f60a0b2002-09-06 02:56:08 +0000905 break;
906
Brian Paul77eec612003-04-18 01:56:11 +0000907#if FEATURE_ARB_fragment_program
908 case GL_FRAGMENT_PROGRAM_ARB:
909 CHECK_EXTENSION(ARB_fragment_program, cap);
910 if (ctx->FragmentProgram.Enabled == state)
911 return;
Keith Whitwell3abf7462004-01-23 14:46:27 +0000912 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
Brian Paul77eec612003-04-18 01:56:11 +0000913 ctx->FragmentProgram.Enabled = state;
914 break;
915#endif /* FEATURE_ARB_fragment_program */
916
Brian Paule5b244f2003-04-21 15:02:17 +0000917 /* GL_EXT_depth_bounds_test */
918 case GL_DEPTH_BOUNDS_TEST_EXT:
919 CHECK_EXTENSION(EXT_depth_bounds_test, cap);
Brian Paule4b23562005-05-04 20:11:35 +0000920 if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
Brian Paule5b244f2003-04-21 15:02:17 +0000921 _mesa_warning(ctx,
922 "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
923 return;
924 }
925 if (ctx->Depth.BoundsTest == state)
926 return;
927 FLUSH_VERTICES(ctx, _NEW_DEPTH);
928 ctx->Depth.BoundsTest = state;
929 break;
930
Brian Paul08ff0592003-07-21 04:22:40 +0000931 /* GL_MESA_program_debug */
932 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
933 CHECK_EXTENSION(MESA_program_debug, cap);
934 ctx->FragmentProgram.CallbackEnabled = state;
935 break;
936 case GL_VERTEX_PROGRAM_CALLBACK_MESA:
937 CHECK_EXTENSION(MESA_program_debug, cap);
938 ctx->VertexProgram.CallbackEnabled = state;
939 break;
940
Dave Airlie7f752fe2004-12-19 03:06:59 +0000941#if FEATURE_ATI_fragment_shader
942 case GL_FRAGMENT_SHADER_ATI:
943 CHECK_EXTENSION(ATI_fragment_shader, cap);
944 if (ctx->ATIFragmentShader.Enabled == state)
945 return;
946 FLUSH_VERTICES(ctx, _NEW_PROGRAM);
947 ctx->ATIFragmentShader.Enabled = state;
948 break;
949#endif
Ian Romanickbb372f12007-05-16 15:34:22 -0700950
951 /* GL_MESA_texture_array */
952 case GL_TEXTURE_1D_ARRAY_EXT:
953 CHECK_EXTENSION(MESA_texture_array, cap);
954 if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) {
955 return;
956 }
957 break;
958
959 case GL_TEXTURE_2D_ARRAY_EXT:
960 CHECK_EXTENSION(MESA_texture_array, cap);
961 if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) {
962 return;
963 }
964 break;
965
Brian Paul86b84272001-12-14 02:50:01 +0000966 default:
Brian Paul4e9676f2002-06-29 19:48:15 +0000967 _mesa_error(ctx, GL_INVALID_ENUM,
968 "%s(0x%x)", state ? "glEnable" : "glDisable", cap);
Brian Paul86b84272001-12-14 02:50:01 +0000969 return;
jtgafb833d1999-08-19 00:55:39 +0000970 }
971
972 if (ctx->Driver.Enable) {
Brian8dcfcad72006-12-13 15:31:14 -0700973 ctx->Driver.Enable( ctx, cap, state );
jtgafb833d1999-08-19 00:55:39 +0000974 }
975}
976
977
Keith Whitwell6dc85572003-07-17 13:43:59 +0000978/**
Brian8dcfcad72006-12-13 15:31:14 -0700979 * Enable GL capability. Called by glEnable()
980 * \param cap state to enable.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000981 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000982void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000983_mesa_Enable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000984{
Brian Paulfbd8f211999-11-11 01:22:25 +0000985 GET_CURRENT_CONTEXT(ctx);
Keith Whitwell376d0222000-12-27 22:52:45 +0000986 ASSERT_OUTSIDE_BEGIN_END(ctx);
987
Brian Paulfbd8f211999-11-11 01:22:25 +0000988 _mesa_set_enable( ctx, cap, GL_TRUE );
jtgafb833d1999-08-19 00:55:39 +0000989}
990
991
Keith Whitwell6dc85572003-07-17 13:43:59 +0000992/**
Brian8dcfcad72006-12-13 15:31:14 -0700993 * Disable GL capability. Called by glDisable()
994 * \param cap state to disable.
Keith Whitwell6dc85572003-07-17 13:43:59 +0000995 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +0000996void GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +0000997_mesa_Disable( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +0000998{
Brian Paulfbd8f211999-11-11 01:22:25 +0000999 GET_CURRENT_CONTEXT(ctx);
Keith Whitwell376d0222000-12-27 22:52:45 +00001000 ASSERT_OUTSIDE_BEGIN_END(ctx);
1001
Brian Paulfbd8f211999-11-11 01:22:25 +00001002 _mesa_set_enable( ctx, cap, GL_FALSE );
jtgafb833d1999-08-19 00:55:39 +00001003}
1004
1005
Brian Paul86b84272001-12-14 02:50:01 +00001006#undef CHECK_EXTENSION
1007#define CHECK_EXTENSION(EXTNAME) \
1008 if (!ctx->Extensions.EXTNAME) { \
1009 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1010 return GL_FALSE; \
1011 }
1012
Roland Scheideggerda168132006-03-02 12:06:57 +00001013#undef CHECK_EXTENSION2
1014#define CHECK_EXTENSION2(EXT1, EXT2) \
1015 if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
1016 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
1017 return GL_FALSE; \
1018 }
jtgafb833d1999-08-19 00:55:39 +00001019
Brian8dcfcad72006-12-13 15:31:14 -07001020
Keith Whitwell6dc85572003-07-17 13:43:59 +00001021/**
Ian Romanick58dacc82007-05-09 21:45:27 -07001022 * Helper function to determine whether a texture target is enabled.
1023 */
1024static GLboolean
Ian Romanickc9e723e2007-05-10 08:20:04 -07001025is_texture_enabled(GLcontext *ctx, GLbitfield bit)
Ian Romanick58dacc82007-05-09 21:45:27 -07001026{
1027 const struct gl_texture_unit *const texUnit =
1028 &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
1029 return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE;
1030}
1031
1032
1033/**
Brian8dcfcad72006-12-13 15:31:14 -07001034 * Return simple enable/disable state.
Keith Whitwell6dc85572003-07-17 13:43:59 +00001035 *
Brian8dcfcad72006-12-13 15:31:14 -07001036 * \param cap state variable to query.
Keith Whitwell6dc85572003-07-17 13:43:59 +00001037 *
1038 * Returns the state of the specified capability from the current GL context.
1039 * For the capabilities associated with extensions verifies that those
1040 * extensions are effectively present before reporting.
1041 */
Kendall Bennettc40d1dd2003-10-21 22:22:17 +00001042GLboolean GLAPIENTRY
Brian Paulfbd8f211999-11-11 01:22:25 +00001043_mesa_IsEnabled( GLenum cap )
jtgafb833d1999-08-19 00:55:39 +00001044{
Brian Paulfbd8f211999-11-11 01:22:25 +00001045 GET_CURRENT_CONTEXT(ctx);
jtgafb833d1999-08-19 00:55:39 +00001046 switch (cap) {
1047 case GL_ALPHA_TEST:
1048 return ctx->Color.AlphaEnabled;
1049 case GL_AUTO_NORMAL:
1050 return ctx->Eval.AutoNormal;
1051 case GL_BLEND:
1052 return ctx->Color.BlendEnabled;
1053 case GL_CLIP_PLANE0:
1054 case GL_CLIP_PLANE1:
1055 case GL_CLIP_PLANE2:
1056 case GL_CLIP_PLANE3:
1057 case GL_CLIP_PLANE4:
1058 case GL_CLIP_PLANE5:
Brian Paul103bc0f2002-03-29 17:27:59 +00001059 return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1;
jtgafb833d1999-08-19 00:55:39 +00001060 case GL_COLOR_MATERIAL:
1061 return ctx->Light.ColorMaterialEnabled;
1062 case GL_CULL_FACE:
1063 return ctx->Polygon.CullFlag;
1064 case GL_DEPTH_TEST:
1065 return ctx->Depth.Test;
1066 case GL_DITHER:
1067 return ctx->Color.DitherFlag;
1068 case GL_FOG:
1069 return ctx->Fog.Enabled;
1070 case GL_LIGHTING:
1071 return ctx->Light.Enabled;
1072 case GL_LIGHT0:
1073 case GL_LIGHT1:
1074 case GL_LIGHT2:
1075 case GL_LIGHT3:
1076 case GL_LIGHT4:
1077 case GL_LIGHT5:
1078 case GL_LIGHT6:
1079 case GL_LIGHT7:
1080 return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
1081 case GL_LINE_SMOOTH:
1082 return ctx->Line.SmoothFlag;
1083 case GL_LINE_STIPPLE:
1084 return ctx->Line.StippleFlag;
1085 case GL_INDEX_LOGIC_OP:
1086 return ctx->Color.IndexLogicOpEnabled;
1087 case GL_COLOR_LOGIC_OP:
1088 return ctx->Color.ColorLogicOpEnabled;
1089 case GL_MAP1_COLOR_4:
1090 return ctx->Eval.Map1Color4;
1091 case GL_MAP1_INDEX:
1092 return ctx->Eval.Map1Index;
1093 case GL_MAP1_NORMAL:
1094 return ctx->Eval.Map1Normal;
1095 case GL_MAP1_TEXTURE_COORD_1:
1096 return ctx->Eval.Map1TextureCoord1;
1097 case GL_MAP1_TEXTURE_COORD_2:
1098 return ctx->Eval.Map1TextureCoord2;
1099 case GL_MAP1_TEXTURE_COORD_3:
1100 return ctx->Eval.Map1TextureCoord3;
1101 case GL_MAP1_TEXTURE_COORD_4:
1102 return ctx->Eval.Map1TextureCoord4;
1103 case GL_MAP1_VERTEX_3:
1104 return ctx->Eval.Map1Vertex3;
1105 case GL_MAP1_VERTEX_4:
1106 return ctx->Eval.Map1Vertex4;
1107 case GL_MAP2_COLOR_4:
1108 return ctx->Eval.Map2Color4;
1109 case GL_MAP2_INDEX:
1110 return ctx->Eval.Map2Index;
1111 case GL_MAP2_NORMAL:
1112 return ctx->Eval.Map2Normal;
Jouk Jansen5e3bc0c2000-11-22 07:32:16 +00001113 case GL_MAP2_TEXTURE_COORD_1:
jtgafb833d1999-08-19 00:55:39 +00001114 return ctx->Eval.Map2TextureCoord1;
1115 case GL_MAP2_TEXTURE_COORD_2:
1116 return ctx->Eval.Map2TextureCoord2;
1117 case GL_MAP2_TEXTURE_COORD_3:
1118 return ctx->Eval.Map2TextureCoord3;
1119 case GL_MAP2_TEXTURE_COORD_4:
1120 return ctx->Eval.Map2TextureCoord4;
1121 case GL_MAP2_VERTEX_3:
1122 return ctx->Eval.Map2Vertex3;
1123 case GL_MAP2_VERTEX_4:
1124 return ctx->Eval.Map2Vertex4;
1125 case GL_NORMALIZE:
1126 return ctx->Transform.Normalize;
1127 case GL_POINT_SMOOTH:
1128 return ctx->Point.SmoothFlag;
1129 case GL_POLYGON_SMOOTH:
1130 return ctx->Polygon.SmoothFlag;
1131 case GL_POLYGON_STIPPLE:
1132 return ctx->Polygon.StippleFlag;
1133 case GL_POLYGON_OFFSET_POINT:
1134 return ctx->Polygon.OffsetPoint;
1135 case GL_POLYGON_OFFSET_LINE:
1136 return ctx->Polygon.OffsetLine;
1137 case GL_POLYGON_OFFSET_FILL:
1138 /*case GL_POLYGON_OFFSET_EXT:*/
1139 return ctx->Polygon.OffsetFill;
1140 case GL_RESCALE_NORMAL_EXT:
1141 return ctx->Transform.RescaleNormals;
1142 case GL_SCISSOR_TEST:
1143 return ctx->Scissor.Enabled;
1144 case GL_SHARED_TEXTURE_PALETTE_EXT:
1145 return ctx->Texture.SharedPalette;
1146 case GL_STENCIL_TEST:
1147 return ctx->Stencil.Enabled;
1148 case GL_TEXTURE_1D:
Ian Romanick58dacc82007-05-09 21:45:27 -07001149 return is_texture_enabled(ctx, TEXTURE_1D_BIT);
jtgafb833d1999-08-19 00:55:39 +00001150 case GL_TEXTURE_2D:
Ian Romanick58dacc82007-05-09 21:45:27 -07001151 return is_texture_enabled(ctx, TEXTURE_2D_BIT);
jtgafb833d1999-08-19 00:55:39 +00001152 case GL_TEXTURE_3D:
Ian Romanickc9e723e2007-05-10 08:20:04 -07001153 return is_texture_enabled(ctx, TEXTURE_3D_BIT);
jtgafb833d1999-08-19 00:55:39 +00001154 case GL_TEXTURE_GEN_Q:
1155 {
Brian Paul86b84272001-12-14 02:50:01 +00001156 const struct gl_texture_unit *texUnit;
1157 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001158 return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
1159 }
1160 case GL_TEXTURE_GEN_R:
1161 {
Brian Paul86b84272001-12-14 02:50:01 +00001162 const struct gl_texture_unit *texUnit;
1163 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001164 return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
1165 }
1166 case GL_TEXTURE_GEN_S:
1167 {
Brian Paul86b84272001-12-14 02:50:01 +00001168 const struct gl_texture_unit *texUnit;
1169 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001170 return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
1171 }
1172 case GL_TEXTURE_GEN_T:
1173 {
Brian Paul86b84272001-12-14 02:50:01 +00001174 const struct gl_texture_unit *texUnit;
1175 texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
jtgafb833d1999-08-19 00:55:39 +00001176 return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
1177 }
1178
1179 /*
1180 * CLIENT STATE!!!
1181 */
1182 case GL_VERTEX_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001183 return (ctx->Array.ArrayObj->Vertex.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001184 case GL_NORMAL_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001185 return (ctx->Array.ArrayObj->Normal.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001186 case GL_COLOR_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001187 return (ctx->Array.ArrayObj->Color.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001188 case GL_INDEX_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001189 return (ctx->Array.ArrayObj->Index.Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001190 case GL_TEXTURE_COORD_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001191 return (ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled != 0);
jtgafb833d1999-08-19 00:55:39 +00001192 case GL_EDGE_FLAG_ARRAY:
Ian Romanickee34e6e2006-06-12 16:26:29 +00001193 return (ctx->Array.ArrayObj->EdgeFlag.Enabled != 0);
Brian Paul6ee7a022002-01-22 18:40:46 +00001194 case GL_FOG_COORDINATE_ARRAY_EXT:
1195 CHECK_EXTENSION(EXT_fog_coord);
Ian Romanickee34e6e2006-06-12 16:26:29 +00001196 return (ctx->Array.ArrayObj->FogCoord.Enabled != 0);
Brian Paul6ee7a022002-01-22 18:40:46 +00001197 case GL_SECONDARY_COLOR_ARRAY_EXT:
1198 CHECK_EXTENSION(EXT_secondary_color);
Ian Romanickee34e6e2006-06-12 16:26:29 +00001199 return (ctx->Array.ArrayObj->SecondaryColor.Enabled != 0);
Brian Paul1cf2c8a2008-06-25 08:45:14 -06001200#if FEATURE_point_size_array
1201 case GL_POINT_SIZE_ARRAY_OES:
1202 return (ctx->Array.ArrayObj->PointSize.Enabled != 0);
1203#endif
Brian Paul1b2ff692000-03-11 23:23:26 +00001204
Brian Paul86b84272001-12-14 02:50:01 +00001205 /* GL_EXT_histogram */
1206 case GL_HISTOGRAM:
1207 CHECK_EXTENSION(EXT_histogram);
1208 return ctx->Pixel.HistogramEnabled;
1209 case GL_MINMAX:
1210 CHECK_EXTENSION(EXT_histogram);
1211 return ctx->Pixel.MinMaxEnabled;
1212
Brian Paul13811372000-04-12 00:27:37 +00001213 /* GL_SGI_color_table */
1214 case GL_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001215 CHECK_EXTENSION(SGI_color_table);
Brian7573b582007-03-16 09:36:12 -06001216 return ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION];
Brian Paul13811372000-04-12 00:27:37 +00001217 case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001218 CHECK_EXTENSION(SGI_color_table);
Brian7573b582007-03-16 09:36:12 -06001219 return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION];
Brian Paul13811372000-04-12 00:27:37 +00001220 case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
Brian Paul86b84272001-12-14 02:50:01 +00001221 CHECK_EXTENSION(SGI_color_table);
Brian7573b582007-03-16 09:36:12 -06001222 return ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX];
Brian Paul2b2e9252000-04-07 16:27:26 +00001223
Brian Paul45b47d02003-01-26 14:37:15 +00001224 /* GL_SGI_texture_color_table */
1225 case GL_TEXTURE_COLOR_TABLE_SGI:
1226 CHECK_EXTENSION(SGI_texture_color_table);
1227 return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled;
1228
Brian Paul82b02f02000-05-07 20:37:40 +00001229 /* GL_EXT_convolution */
1230 case GL_CONVOLUTION_1D:
Brian Paul86b84272001-12-14 02:50:01 +00001231 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001232 return ctx->Pixel.Convolution1DEnabled;
1233 case GL_CONVOLUTION_2D:
Brian Paul86b84272001-12-14 02:50:01 +00001234 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001235 return ctx->Pixel.Convolution2DEnabled;
1236 case GL_SEPARABLE_2D:
Brian Paul86b84272001-12-14 02:50:01 +00001237 CHECK_EXTENSION(EXT_convolution);
Brian Paul82b02f02000-05-07 20:37:40 +00001238 return ctx->Pixel.Separable2DEnabled;
1239
Brian Paul86fc3702000-05-22 16:33:20 +00001240 /* GL_ARB_texture_cube_map */
1241 case GL_TEXTURE_CUBE_MAP_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001242 CHECK_EXTENSION(ARB_texture_cube_map);
Ian Romanick58dacc82007-05-09 21:45:27 -07001243 return is_texture_enabled(ctx, TEXTURE_CUBE_BIT);
Brian Paul86fc3702000-05-22 16:33:20 +00001244
Roland Scheideggerda168132006-03-02 12:06:57 +00001245 /* GL_EXT_secondary_color */
1246 case GL_COLOR_SUM_EXT:
1247 CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program);
1248 return ctx->Fog.ColorSumEnabled;
1249
Brian Paul736fcbe2001-05-29 15:23:48 +00001250 /* GL_ARB_multisample */
1251 case GL_MULTISAMPLE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001252 CHECK_EXTENSION(ARB_multisample);
1253 return ctx->Multisample.Enabled;
Brian Paul736fcbe2001-05-29 15:23:48 +00001254 case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001255 CHECK_EXTENSION(ARB_multisample);
1256 return ctx->Multisample.SampleAlphaToCoverage;
Brian Paul736fcbe2001-05-29 15:23:48 +00001257 case GL_SAMPLE_ALPHA_TO_ONE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001258 CHECK_EXTENSION(ARB_multisample);
1259 return ctx->Multisample.SampleAlphaToOne;
Brian Paul736fcbe2001-05-29 15:23:48 +00001260 case GL_SAMPLE_COVERAGE_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001261 CHECK_EXTENSION(ARB_multisample);
1262 return ctx->Multisample.SampleCoverage;
Brian Paul736fcbe2001-05-29 15:23:48 +00001263 case GL_SAMPLE_COVERAGE_INVERT_ARB:
Brian Paul86b84272001-12-14 02:50:01 +00001264 CHECK_EXTENSION(ARB_multisample);
1265 return ctx->Multisample.SampleCoverageInvert;
Brian Paul736fcbe2001-05-29 15:23:48 +00001266
Brian Paul8c2f6c52001-06-26 01:32:48 +00001267 /* GL_IBM_rasterpos_clip */
1268 case GL_RASTER_POSITION_UNCLIPPED_IBM:
Brian Paul86b84272001-12-14 02:50:01 +00001269 CHECK_EXTENSION(IBM_rasterpos_clip);
1270 return ctx->Transform.RasterPositionUnclipped;
Brian Paul8c2f6c52001-06-26 01:32:48 +00001271
Brian Paul6c408b42002-05-27 17:04:52 +00001272 /* GL_NV_point_sprite */
1273 case GL_POINT_SPRITE_NV:
Roland Scheideggerda168132006-03-02 12:06:57 +00001274 CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite)
Brian Paul6c408b42002-05-27 17:04:52 +00001275 return ctx->Point.PointSprite;
Brian Paul06d05af2000-12-08 00:20:15 +00001276
Roland Scheidegger93da6732006-03-01 23:11:14 +00001277#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
Roland Scheideggerda168132006-03-02 12:06:57 +00001278 case GL_VERTEX_PROGRAM_ARB:
1279 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
Brian Paul86b84272001-12-14 02:50:01 +00001280 return ctx->VertexProgram.Enabled;
Roland Scheideggerda168132006-03-02 12:06:57 +00001281 case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
1282 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
Brian Paul86b84272001-12-14 02:50:01 +00001283 return ctx->VertexProgram.PointSizeEnabled;
Roland Scheideggerda168132006-03-02 12:06:57 +00001284 case GL_VERTEX_PROGRAM_TWO_SIDE_ARB:
1285 CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program);
Brian Paul86b84272001-12-14 02:50:01 +00001286 return ctx->VertexProgram.TwoSideEnabled;
Roland Scheidegger93da6732006-03-01 23:11:14 +00001287#endif
1288#if FEATURE_NV_vertex_program
Brian Paul86b84272001-12-14 02:50:01 +00001289 case GL_VERTEX_ATTRIB_ARRAY0_NV:
1290 case GL_VERTEX_ATTRIB_ARRAY1_NV:
1291 case GL_VERTEX_ATTRIB_ARRAY2_NV:
1292 case GL_VERTEX_ATTRIB_ARRAY3_NV:
1293 case GL_VERTEX_ATTRIB_ARRAY4_NV:
1294 case GL_VERTEX_ATTRIB_ARRAY5_NV:
1295 case GL_VERTEX_ATTRIB_ARRAY6_NV:
1296 case GL_VERTEX_ATTRIB_ARRAY7_NV:
1297 case GL_VERTEX_ATTRIB_ARRAY8_NV:
1298 case GL_VERTEX_ATTRIB_ARRAY9_NV:
1299 case GL_VERTEX_ATTRIB_ARRAY10_NV:
1300 case GL_VERTEX_ATTRIB_ARRAY11_NV:
1301 case GL_VERTEX_ATTRIB_ARRAY12_NV:
1302 case GL_VERTEX_ATTRIB_ARRAY13_NV:
1303 case GL_VERTEX_ATTRIB_ARRAY14_NV:
1304 case GL_VERTEX_ATTRIB_ARRAY15_NV:
1305 CHECK_EXTENSION(NV_vertex_program);
1306 {
1307 GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
Ian Romanickee34e6e2006-06-12 16:26:29 +00001308 return (ctx->Array.ArrayObj->VertexAttrib[n].Enabled != 0);
Brian Paul86b84272001-12-14 02:50:01 +00001309 }
1310 case GL_MAP1_VERTEX_ATTRIB0_4_NV:
1311 case GL_MAP1_VERTEX_ATTRIB1_4_NV:
1312 case GL_MAP1_VERTEX_ATTRIB2_4_NV:
1313 case GL_MAP1_VERTEX_ATTRIB3_4_NV:
1314 case GL_MAP1_VERTEX_ATTRIB4_4_NV:
1315 case GL_MAP1_VERTEX_ATTRIB5_4_NV:
1316 case GL_MAP1_VERTEX_ATTRIB6_4_NV:
1317 case GL_MAP1_VERTEX_ATTRIB7_4_NV:
1318 case GL_MAP1_VERTEX_ATTRIB8_4_NV:
1319 case GL_MAP1_VERTEX_ATTRIB9_4_NV:
1320 case GL_MAP1_VERTEX_ATTRIB10_4_NV:
1321 case GL_MAP1_VERTEX_ATTRIB11_4_NV:
1322 case GL_MAP1_VERTEX_ATTRIB12_4_NV:
1323 case GL_MAP1_VERTEX_ATTRIB13_4_NV:
1324 case GL_MAP1_VERTEX_ATTRIB14_4_NV:
1325 case GL_MAP1_VERTEX_ATTRIB15_4_NV:
1326 CHECK_EXTENSION(NV_vertex_program);
Brian Paulbc42c192002-01-05 21:53:20 +00001327 {
1328 const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
1329 return ctx->Eval.Map1Attrib[map];
1330 }
Brian Paul86b84272001-12-14 02:50:01 +00001331 case GL_MAP2_VERTEX_ATTRIB0_4_NV:
1332 case GL_MAP2_VERTEX_ATTRIB1_4_NV:
1333 case GL_MAP2_VERTEX_ATTRIB2_4_NV:
1334 case GL_MAP2_VERTEX_ATTRIB3_4_NV:
1335 case GL_MAP2_VERTEX_ATTRIB4_4_NV:
1336 case GL_MAP2_VERTEX_ATTRIB5_4_NV:
1337 case GL_MAP2_VERTEX_ATTRIB6_4_NV:
1338 case GL_MAP2_VERTEX_ATTRIB7_4_NV:
1339 case GL_MAP2_VERTEX_ATTRIB8_4_NV:
1340 case GL_MAP2_VERTEX_ATTRIB9_4_NV:
1341 case GL_MAP2_VERTEX_ATTRIB10_4_NV:
1342 case GL_MAP2_VERTEX_ATTRIB11_4_NV:
1343 case GL_MAP2_VERTEX_ATTRIB12_4_NV:
1344 case GL_MAP2_VERTEX_ATTRIB13_4_NV:
1345 case GL_MAP2_VERTEX_ATTRIB14_4_NV:
1346 case GL_MAP2_VERTEX_ATTRIB15_4_NV:
1347 CHECK_EXTENSION(NV_vertex_program);
Brian Paulbc42c192002-01-05 21:53:20 +00001348 {
1349 const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
1350 return ctx->Eval.Map2Attrib[map];
1351 }
Brian Paul8dfc5b92002-10-16 17:57:51 +00001352#endif /* FEATURE_NV_vertex_program */
Brian Paul86b84272001-12-14 02:50:01 +00001353
Brian Paul610d5992003-01-14 04:55:45 +00001354#if FEATURE_NV_fragment_program
1355 case GL_FRAGMENT_PROGRAM_NV:
1356 CHECK_EXTENSION(NV_fragment_program);
1357 return ctx->FragmentProgram.Enabled;
1358#endif /* FEATURE_NV_fragment_program */
1359
Brian Paul8afe7de2002-06-15 03:03:06 +00001360 /* GL_NV_texture_rectangle */
1361 case GL_TEXTURE_RECTANGLE_NV:
1362 CHECK_EXTENSION(NV_texture_rectangle);
Ian Romanick58dacc82007-05-09 21:45:27 -07001363 return is_texture_enabled(ctx, TEXTURE_RECT_BIT);
Brian Paul8afe7de2002-06-15 03:03:06 +00001364
Brian Paul5f60a0b2002-09-06 02:56:08 +00001365 /* GL_EXT_stencil_two_side */
1366 case GL_STENCIL_TEST_TWO_SIDE_EXT:
1367 CHECK_EXTENSION(EXT_stencil_two_side);
1368 return ctx->Stencil.TestTwoSide;
1369
Brian Paul77eec612003-04-18 01:56:11 +00001370#if FEATURE_ARB_fragment_program
1371 case GL_FRAGMENT_PROGRAM_ARB:
1372 return ctx->FragmentProgram.Enabled;
1373#endif /* FEATURE_ARB_fragment_program */
1374
Brian Paule5b244f2003-04-21 15:02:17 +00001375 /* GL_EXT_depth_bounds_test */
1376 case GL_DEPTH_BOUNDS_TEST_EXT:
1377 CHECK_EXTENSION(EXT_depth_bounds_test);
1378 return ctx->Depth.BoundsTest;
1379
Brian Paul08ff0592003-07-21 04:22:40 +00001380 /* GL_MESA_program_debug */
1381 case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
1382 CHECK_EXTENSION(MESA_program_debug);
1383 return ctx->FragmentProgram.CallbackEnabled;
1384 case GL_VERTEX_PROGRAM_CALLBACK_MESA:
1385 CHECK_EXTENSION(MESA_program_debug);
1386 return ctx->VertexProgram.CallbackEnabled;
Dave Airlie7f752fe2004-12-19 03:06:59 +00001387#if FEATURE_ATI_fragment_shader
1388 case GL_FRAGMENT_SHADER_ATI:
1389 CHECK_EXTENSION(ATI_fragment_shader);
1390 return ctx->ATIFragmentShader.Enabled;
1391#endif /* FEATURE_ATI_fragment_shader */
jtgafb833d1999-08-19 00:55:39 +00001392 default:
Brian Paul4e9676f2002-06-29 19:48:15 +00001393 _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap);
jtgafb833d1999-08-19 00:55:39 +00001394 return GL_FALSE;
1395 }
1396}