| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame^] | 1 | /* $Id: enable.c,v 1.36 2000/12/08 00:20:15 brianp Exp $ */ |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * Mesa 3-D graphics library |
| Brian Paul | eb326f5 | 2000-10-21 01:29:12 +0000 | [diff] [blame] | 5 | * Version: 3.5 |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 6 | * |
| Brian Paul | eb326f5 | 2000-10-21 01:29:12 +0000 | [diff] [blame] | 7 | * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 8 | * |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 9 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 10 | * copy of this software and associated documentation files (the "Software"), |
| 11 | * to deal in the Software without restriction, including without limitation |
| 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 13 | * and/or sell copies of the Software, and to permit persons to whom the |
| 14 | * Software is furnished to do so, subject to the following conditions: |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 15 | * |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 16 | * The above copyright notice and this permission notice shall be included |
| 17 | * in all copies or substantial portions of the Software. |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 18 | * |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | */ |
| 26 | |
| 27 | |
| 28 | #ifdef PC_HEADER |
| 29 | #include "all.h" |
| 30 | #else |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 31 | #include "glheader.h" |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 32 | #include "context.h" |
| 33 | #include "enable.h" |
| 34 | #include "light.h" |
| 35 | #include "macros.h" |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 36 | #include "mmath.h" |
| 37 | #include "simple_list.h" |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 38 | #include "mtypes.h" |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 39 | #include "enums.h" |
| Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 40 | |
| 41 | #include "math/m_matrix.h" |
| 42 | #include "math/m_xform.h" |
| 43 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 44 | #endif |
| 45 | |
| 46 | |
| 47 | |
| 48 | /* |
| 49 | * Perform glEnable and glDisable calls. |
| 50 | */ |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 51 | void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 52 | { |
| 53 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "gl_enable/disable" ); |
| 54 | |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 55 | if (MESA_VERBOSE & VERBOSE_API) |
| 56 | fprintf(stderr, "%s %s (newstate is %x)\n", |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 57 | state ? "glEnable" : "glDisable", |
| 58 | gl_lookup_enum_by_nr(cap), |
| 59 | ctx->NewState); |
| 60 | |
| 61 | switch (cap) { |
| 62 | case GL_ALPHA_TEST: |
| 63 | if (ctx->Color.AlphaEnabled!=state) { |
| 64 | ctx->Color.AlphaEnabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 65 | ctx->NewState |= _NEW_COLOR; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 66 | } |
| 67 | break; |
| 68 | case GL_AUTO_NORMAL: |
| 69 | ctx->Eval.AutoNormal = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 70 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 71 | break; |
| 72 | case GL_BLEND: |
| 73 | if (ctx->Color.BlendEnabled!=state) { |
| 74 | ctx->Color.BlendEnabled = state; |
| 75 | /* The following needed to accomodate 1.0 RGB logic op blending */ |
| 76 | if (ctx->Color.BlendEquation==GL_LOGIC_OP && state) { |
| 77 | ctx->Color.ColorLogicOpEnabled = GL_TRUE; |
| 78 | } |
| 79 | else { |
| 80 | ctx->Color.ColorLogicOpEnabled = GL_FALSE; |
| 81 | } |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 82 | ctx->NewState |= _NEW_COLOR; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 83 | } |
| 84 | break; |
| 85 | case GL_CLIP_PLANE0: |
| 86 | case GL_CLIP_PLANE1: |
| 87 | case GL_CLIP_PLANE2: |
| 88 | case GL_CLIP_PLANE3: |
| 89 | case GL_CLIP_PLANE4: |
| 90 | case GL_CLIP_PLANE5: |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 91 | if (ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0] != state) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 92 | { |
| 93 | GLuint p = cap-GL_CLIP_PLANE0; |
| 94 | |
| 95 | ctx->Transform.ClipEnabled[p] = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 96 | ctx->NewState |= _NEW_TRANSFORM; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 97 | |
| 98 | if (state) { |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 99 | ctx->_Enabled |= ENABLE_USERCLIP; |
| 100 | ctx->Transform._AnyClip++; |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 101 | |
| Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 102 | if (ctx->ProjectionMatrix.flags & MAT_DIRTY) { |
| Keith Whitwell | ad2ac21 | 2000-11-24 10:25:05 +0000 | [diff] [blame] | 103 | _math_matrix_analyse( &ctx->ProjectionMatrix ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 104 | } |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 105 | |
| Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 106 | /* This derived state also calculated in clip.c and |
| 107 | * from gl_update_state() on changes to EyeUserPlane |
| 108 | * and ctx->ProjectionMatrix respectively. |
| 109 | */ |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 110 | gl_transform_vector( ctx->Transform._ClipUserPlane[p], |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 111 | ctx->Transform.EyeUserPlane[p], |
| 112 | ctx->ProjectionMatrix.inv ); |
| 113 | } else { |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 114 | if (--ctx->Transform._AnyClip == 0) |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 115 | ctx->_Enabled &= ~ENABLE_USERCLIP; |
| 116 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 117 | } |
| 118 | break; |
| 119 | case GL_COLOR_MATERIAL: |
| 120 | if (ctx->Light.ColorMaterialEnabled!=state) { |
| Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 121 | ctx->Light.ColorMaterialEnabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 122 | ctx->NewState |= _NEW_LIGHT; |
| Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 123 | |
| 124 | if (state) { |
| 125 | FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT ); |
| Brian Paul | 1930053 | 2000-10-29 19:02:23 +0000 | [diff] [blame] | 126 | gl_update_color_material( ctx, ctx->Current.Color ); |
| Keith Whitwell | 23caf20 | 2000-11-16 21:05:34 +0000 | [diff] [blame] | 127 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 128 | } |
| 129 | break; |
| 130 | case GL_CULL_FACE: |
| 131 | if (ctx->Polygon.CullFlag!=state) { |
| 132 | ctx->Polygon.CullFlag = state; |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 133 | /* ctx->_TriangleCaps ^= DD_TRI_CULL; */ |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 134 | ctx->NewState |= _NEW_POLYGON; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 135 | } |
| 136 | break; |
| 137 | case GL_DEPTH_TEST: |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 138 | if (state && ctx->Visual.DepthBits==0) { |
| 139 | _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer"); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 140 | return; |
| 141 | } |
| 142 | if (ctx->Depth.Test!=state) { |
| 143 | ctx->Depth.Test = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 144 | ctx->NewState |= _NEW_DEPTH; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 145 | } |
| 146 | break; |
| 147 | case GL_DITHER: |
| 148 | if (ctx->NoDither) { |
| 149 | /* MESA_NO_DITHER env var */ |
| 150 | state = GL_FALSE; |
| 151 | } |
| 152 | if (ctx->Color.DitherFlag!=state) { |
| 153 | ctx->Color.DitherFlag = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 154 | ctx->NewState |= _NEW_COLOR; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 155 | } |
| 156 | break; |
| 157 | case GL_FOG: |
| 158 | if (ctx->Fog.Enabled!=state) { |
| 159 | ctx->Fog.Enabled = state; |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 160 | ctx->_Enabled ^= ENABLE_FOG; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 161 | ctx->NewState |= _NEW_FOG; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 162 | } |
| 163 | break; |
| Brian Paul | 1a1cf7e | 2000-05-04 13:48:49 +0000 | [diff] [blame] | 164 | case GL_HISTOGRAM: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 165 | if (ctx->Extensions.EXT_histogram) { |
| Brian Paul | 8e05391 | 2000-08-30 18:21:06 +0000 | [diff] [blame] | 166 | ctx->Pixel.HistogramEnabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 167 | ctx->NewState |= _NEW_PIXEL; |
| Brian Paul | 8e05391 | 2000-08-30 18:21:06 +0000 | [diff] [blame] | 168 | } |
| 169 | else { |
| 170 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 171 | return; |
| 172 | } |
| Brian Paul | 1a1cf7e | 2000-05-04 13:48:49 +0000 | [diff] [blame] | 173 | break; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 174 | case GL_LIGHT0: |
| 175 | case GL_LIGHT1: |
| 176 | case GL_LIGHT2: |
| 177 | case GL_LIGHT3: |
| 178 | case GL_LIGHT4: |
| 179 | case GL_LIGHT5: |
| 180 | case GL_LIGHT6: |
| 181 | case GL_LIGHT7: |
| Brian Paul | 8e05391 | 2000-08-30 18:21:06 +0000 | [diff] [blame] | 182 | if (ctx->Light.Light[cap-GL_LIGHT0].Enabled != state) { |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 183 | ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 184 | if (state) { |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 185 | insert_at_tail(&ctx->Light.EnabledList, |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 186 | &ctx->Light.Light[cap-GL_LIGHT0]); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 187 | } |
| Brian Paul | 72ef753 | 2000-11-27 18:59:09 +0000 | [diff] [blame] | 188 | else { |
| 189 | remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); |
| 190 | } |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 191 | ctx->NewState |= _NEW_LIGHT; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 192 | } |
| 193 | break; |
| 194 | case GL_LIGHTING: |
| 195 | if (ctx->Light.Enabled!=state) { |
| 196 | ctx->Light.Enabled = state; |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 197 | ctx->_Enabled &= ~ENABLE_LIGHT; |
| Brian Paul | 2c318aa | 1999-10-20 22:16:45 +0000 | [diff] [blame] | 198 | if (state) |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 199 | ctx->_Enabled |= ENABLE_LIGHT; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 200 | ctx->NewState |= _NEW_LIGHT; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 201 | } |
| 202 | break; |
| 203 | case GL_LINE_SMOOTH: |
| 204 | if (ctx->Line.SmoothFlag!=state) { |
| 205 | ctx->Line.SmoothFlag = state; |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 206 | ctx->_TriangleCaps ^= DD_LINE_SMOOTH; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 207 | ctx->NewState |= _NEW_LINE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 208 | } |
| 209 | break; |
| 210 | case GL_LINE_STIPPLE: |
| 211 | if (ctx->Line.StippleFlag!=state) { |
| 212 | ctx->Line.StippleFlag = state; |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 213 | ctx->_TriangleCaps ^= DD_LINE_STIPPLE; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 214 | ctx->NewState |= _NEW_LINE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 215 | } |
| 216 | break; |
| 217 | case GL_INDEX_LOGIC_OP: |
| 218 | if (ctx->Color.IndexLogicOpEnabled!=state) { |
| 219 | ctx->Color.IndexLogicOpEnabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 220 | ctx->NewState |= _NEW_COLOR; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 221 | } |
| 222 | break; |
| 223 | case GL_COLOR_LOGIC_OP: |
| 224 | if (ctx->Color.ColorLogicOpEnabled!=state) { |
| 225 | ctx->Color.ColorLogicOpEnabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 226 | ctx->NewState |= _NEW_COLOR; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 227 | } |
| 228 | break; |
| 229 | case GL_MAP1_COLOR_4: |
| 230 | ctx->Eval.Map1Color4 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 231 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 232 | break; |
| 233 | case GL_MAP1_INDEX: |
| 234 | ctx->Eval.Map1Index = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 235 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 236 | break; |
| 237 | case GL_MAP1_NORMAL: |
| 238 | ctx->Eval.Map1Normal = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 239 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 240 | break; |
| 241 | case GL_MAP1_TEXTURE_COORD_1: |
| 242 | ctx->Eval.Map1TextureCoord1 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 243 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 244 | break; |
| 245 | case GL_MAP1_TEXTURE_COORD_2: |
| 246 | ctx->Eval.Map1TextureCoord2 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 247 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 248 | break; |
| 249 | case GL_MAP1_TEXTURE_COORD_3: |
| 250 | ctx->Eval.Map1TextureCoord3 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 251 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 252 | break; |
| 253 | case GL_MAP1_TEXTURE_COORD_4: |
| 254 | ctx->Eval.Map1TextureCoord4 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 255 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 256 | break; |
| 257 | case GL_MAP1_VERTEX_3: |
| 258 | ctx->Eval.Map1Vertex3 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 259 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 260 | break; |
| 261 | case GL_MAP1_VERTEX_4: |
| 262 | ctx->Eval.Map1Vertex4 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 263 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 264 | break; |
| 265 | case GL_MAP2_COLOR_4: |
| 266 | ctx->Eval.Map2Color4 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 267 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 268 | break; |
| 269 | case GL_MAP2_INDEX: |
| 270 | ctx->Eval.Map2Index = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 271 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 272 | break; |
| 273 | case GL_MAP2_NORMAL: |
| 274 | ctx->Eval.Map2Normal = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 275 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 276 | break; |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 277 | case GL_MAP2_TEXTURE_COORD_1: |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 278 | ctx->Eval.Map2TextureCoord1 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 279 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 280 | break; |
| 281 | case GL_MAP2_TEXTURE_COORD_2: |
| 282 | ctx->Eval.Map2TextureCoord2 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 283 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 284 | break; |
| 285 | case GL_MAP2_TEXTURE_COORD_3: |
| 286 | ctx->Eval.Map2TextureCoord3 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 287 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 288 | break; |
| 289 | case GL_MAP2_TEXTURE_COORD_4: |
| 290 | ctx->Eval.Map2TextureCoord4 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 291 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 292 | break; |
| 293 | case GL_MAP2_VERTEX_3: |
| 294 | ctx->Eval.Map2Vertex3 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 295 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 296 | break; |
| 297 | case GL_MAP2_VERTEX_4: |
| 298 | ctx->Eval.Map2Vertex4 = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 299 | ctx->NewState |= _NEW_EVAL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 300 | break; |
| Brian Paul | 1a1cf7e | 2000-05-04 13:48:49 +0000 | [diff] [blame] | 301 | case GL_MINMAX: |
| 302 | ctx->Pixel.MinMaxEnabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 303 | ctx->NewState |= _NEW_PIXEL; |
| Brian Paul | 1a1cf7e | 2000-05-04 13:48:49 +0000 | [diff] [blame] | 304 | break; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 305 | case GL_NORMALIZE: |
| 306 | if (ctx->Transform.Normalize != state) { |
| 307 | ctx->Transform.Normalize = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 308 | ctx->NewState |= _NEW_TRANSFORM; |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 309 | ctx->_Enabled ^= ENABLE_NORMALIZE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 310 | } |
| 311 | break; |
| 312 | case GL_POINT_SMOOTH: |
| 313 | if (ctx->Point.SmoothFlag!=state) { |
| 314 | ctx->Point.SmoothFlag = state; |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 315 | ctx->_TriangleCaps ^= DD_POINT_SMOOTH; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 316 | ctx->NewState |= _NEW_POINT; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 317 | } |
| 318 | break; |
| 319 | case GL_POLYGON_SMOOTH: |
| 320 | if (ctx->Polygon.SmoothFlag!=state) { |
| 321 | ctx->Polygon.SmoothFlag = state; |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 322 | ctx->_TriangleCaps ^= DD_TRI_SMOOTH; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 323 | ctx->NewState |= _NEW_POLYGON; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 324 | } |
| 325 | break; |
| 326 | case GL_POLYGON_STIPPLE: |
| 327 | if (ctx->Polygon.StippleFlag!=state) { |
| 328 | ctx->Polygon.StippleFlag = state; |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 329 | ctx->_TriangleCaps ^= DD_TRI_STIPPLE; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 330 | ctx->NewState |= _NEW_POLYGON; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 331 | } |
| 332 | break; |
| 333 | case GL_POLYGON_OFFSET_POINT: |
| 334 | if (ctx->Polygon.OffsetPoint!=state) { |
| 335 | ctx->Polygon.OffsetPoint = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 336 | ctx->NewState |= _NEW_POLYGON; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 337 | } |
| 338 | break; |
| 339 | case GL_POLYGON_OFFSET_LINE: |
| 340 | if (ctx->Polygon.OffsetLine!=state) { |
| 341 | ctx->Polygon.OffsetLine = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 342 | ctx->NewState |= _NEW_POLYGON; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 343 | } |
| 344 | break; |
| 345 | case GL_POLYGON_OFFSET_FILL: |
| 346 | /*case GL_POLYGON_OFFSET_EXT:*/ |
| 347 | if (ctx->Polygon.OffsetFill!=state) { |
| 348 | ctx->Polygon.OffsetFill = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 349 | ctx->NewState |= _NEW_POLYGON; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 350 | } |
| 351 | break; |
| 352 | case GL_RESCALE_NORMAL_EXT: |
| 353 | if (ctx->Transform.RescaleNormals != state) { |
| 354 | ctx->Transform.RescaleNormals = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 355 | ctx->NewState |= _NEW_TRANSFORM; |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 356 | ctx->_Enabled ^= ENABLE_RESCALE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 357 | } |
| 358 | break; |
| 359 | case GL_SCISSOR_TEST: |
| 360 | if (ctx->Scissor.Enabled!=state) { |
| 361 | ctx->Scissor.Enabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 362 | ctx->NewState |= _NEW_SCISSOR; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 363 | } |
| 364 | break; |
| 365 | case GL_SHARED_TEXTURE_PALETTE_EXT: |
| 366 | ctx->Texture.SharedPalette = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 367 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 368 | break; |
| 369 | case GL_STENCIL_TEST: |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 370 | if (state && ctx->Visual.StencilBits==0) { |
| 371 | _mesa_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer"); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 372 | return; |
| 373 | } |
| 374 | if (ctx->Stencil.Enabled!=state) { |
| 375 | ctx->Stencil.Enabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 376 | ctx->NewState |= _NEW_STENCIL; |
| Keith Whitwell | 14940c4 | 2000-11-05 18:40:57 +0000 | [diff] [blame] | 377 | ctx->_TriangleCaps ^= DD_STENCIL; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 378 | } |
| 379 | break; |
| 380 | case GL_TEXTURE_1D: |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 381 | if (ctx->Visual.RGBAflag) { |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 382 | const GLuint curr = ctx->Texture.CurrentUnit; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 383 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 384 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 385 | if (state) { |
| 386 | texUnit->Enabled |= TEXTURE0_1D; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 387 | } |
| 388 | else { |
| 389 | texUnit->Enabled &= ~TEXTURE0_1D; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 390 | } |
| 391 | } |
| 392 | break; |
| 393 | case GL_TEXTURE_2D: |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 394 | if (ctx->Visual.RGBAflag) { |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 395 | const GLuint curr = ctx->Texture.CurrentUnit; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 396 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 397 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 398 | if (state) { |
| 399 | texUnit->Enabled |= TEXTURE0_2D; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 400 | } |
| 401 | else { |
| 402 | texUnit->Enabled &= ~TEXTURE0_2D; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 403 | } |
| 404 | } |
| 405 | break; |
| 406 | case GL_TEXTURE_3D: |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 407 | if (ctx->Visual.RGBAflag) { |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 408 | const GLuint curr = ctx->Texture.CurrentUnit; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 409 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 410 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 411 | if (state) { |
| 412 | texUnit->Enabled |= TEXTURE0_3D; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 413 | } |
| 414 | else { |
| 415 | texUnit->Enabled &= ~TEXTURE0_3D; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 416 | } |
| 417 | } |
| 418 | break; |
| 419 | case GL_TEXTURE_GEN_Q: |
| 420 | { |
| 421 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 422 | if (state) |
| 423 | texUnit->TexGenEnabled |= Q_BIT; |
| 424 | else |
| 425 | texUnit->TexGenEnabled &= ~Q_BIT; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 426 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 427 | } |
| 428 | break; |
| 429 | case GL_TEXTURE_GEN_R: |
| 430 | { |
| 431 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 432 | if (state) |
| 433 | texUnit->TexGenEnabled |= R_BIT; |
| 434 | else |
| 435 | texUnit->TexGenEnabled &= ~R_BIT; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 436 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 437 | } |
| 438 | break; |
| 439 | case GL_TEXTURE_GEN_S: |
| 440 | { |
| 441 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 442 | if (state) |
| 443 | texUnit->TexGenEnabled |= S_BIT; |
| 444 | else |
| 445 | texUnit->TexGenEnabled &= ~S_BIT; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 446 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 447 | } |
| 448 | break; |
| 449 | case GL_TEXTURE_GEN_T: |
| 450 | { |
| 451 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 452 | if (state) |
| 453 | texUnit->TexGenEnabled |= T_BIT; |
| 454 | else |
| 455 | texUnit->TexGenEnabled &= ~T_BIT; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 456 | ctx->NewState |= _NEW_TEXTURE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 457 | } |
| 458 | break; |
| 459 | |
| 460 | /* |
| 461 | * CLIENT STATE!!! |
| 462 | */ |
| 463 | case GL_VERTEX_ARRAY: |
| 464 | ctx->Array.Vertex.Enabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 465 | ctx->NewState |= _NEW_ARRAY; |
| 466 | break; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 467 | case GL_NORMAL_ARRAY: |
| 468 | ctx->Array.Normal.Enabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 469 | ctx->NewState |= _NEW_ARRAY; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 470 | break; |
| 471 | case GL_COLOR_ARRAY: |
| 472 | ctx->Array.Color.Enabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 473 | ctx->NewState |= _NEW_ARRAY; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 474 | break; |
| 475 | case GL_INDEX_ARRAY: |
| 476 | ctx->Array.Index.Enabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 477 | ctx->NewState |= _NEW_ARRAY; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 478 | break; |
| 479 | case GL_TEXTURE_COORD_ARRAY: |
| Brian Paul | 45224fa | 1999-09-07 22:31:30 +0000 | [diff] [blame] | 480 | ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 481 | ctx->NewState |= _NEW_ARRAY; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 482 | break; |
| 483 | case GL_EDGE_FLAG_ARRAY: |
| 484 | ctx->Array.EdgeFlag.Enabled = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 485 | ctx->NewState |= _NEW_ARRAY; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 486 | break; |
| 487 | |
| Brian Paul | 1b2ff69 | 2000-03-11 23:23:26 +0000 | [diff] [blame] | 488 | /* GL_HP_occlusion_test */ |
| 489 | case GL_OCCLUSION_TEST_HP: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 490 | if (ctx->Extensions.HP_occlusion_test) { |
| Brian Paul | 1b2ff69 | 2000-03-11 23:23:26 +0000 | [diff] [blame] | 491 | ctx->Depth.OcclusionTest = state; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 492 | ctx->NewState |= _NEW_DEPTH; |
| Brian Paul | 7e67fb4 | 2000-04-04 15:14:10 +0000 | [diff] [blame] | 493 | if (state) |
| 494 | ctx->OcclusionResult = ctx->OcclusionResultSaved; |
| 495 | else |
| 496 | ctx->OcclusionResultSaved = ctx->OcclusionResult; |
| Brian Paul | 1b2ff69 | 2000-03-11 23:23:26 +0000 | [diff] [blame] | 497 | } |
| 498 | else { |
| 499 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 500 | return; |
| 501 | } |
| 502 | break; |
| 503 | |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 504 | /* GL_SGIS_pixel_texture */ |
| 505 | case GL_PIXEL_TEXTURE_SGIS: |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame^] | 506 | if (ctx->Extensions.SGIS_pixel_texture) { |
| 507 | ctx->Pixel.PixelTextureEnabled = state; |
| 508 | ctx->NewState |= _NEW_PIXEL; |
| 509 | } |
| 510 | else { |
| 511 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 512 | return; |
| 513 | } |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 514 | break; |
| 515 | |
| 516 | /* GL_SGIX_pixel_texture */ |
| 517 | case GL_PIXEL_TEX_GEN_SGIX: |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame^] | 518 | if (ctx->Extensions.SGIX_pixel_texture) { |
| 519 | ctx->Pixel.PixelTextureEnabled = state; |
| 520 | ctx->NewState |= _NEW_PIXEL; |
| 521 | } |
| 522 | else { |
| 523 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 524 | return; |
| 525 | } |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 526 | break; |
| 527 | |
| Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 528 | /* GL_SGI_color_table */ |
| 529 | case GL_COLOR_TABLE_SGI: |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame^] | 530 | if (ctx->Extensions.SGI_color_table) { |
| 531 | ctx->Pixel.ColorTableEnabled = state; |
| 532 | ctx->NewState |= _NEW_PIXEL; |
| 533 | } |
| 534 | else { |
| 535 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 536 | return; |
| 537 | } |
| Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 538 | break; |
| 539 | case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame^] | 540 | if (ctx->Extensions.SGI_color_table) { |
| 541 | ctx->Pixel.PostConvolutionColorTableEnabled = state; |
| 542 | ctx->NewState |= _NEW_PIXEL; |
| 543 | } |
| 544 | else { |
| 545 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 546 | return; |
| 547 | } |
| Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 548 | break; |
| 549 | case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame^] | 550 | if (ctx->Extensions.SGI_color_table) { |
| 551 | ctx->Pixel.PostColorMatrixColorTableEnabled = state; |
| 552 | ctx->NewState |= _NEW_PIXEL; |
| 553 | } |
| 554 | else { |
| 555 | gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); |
| 556 | return; |
| 557 | } |
| Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 558 | break; |
| 559 | |
| Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 560 | /* GL_EXT_convolution */ |
| 561 | case GL_CONVOLUTION_1D: |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame^] | 562 | if (ctx->Extensions.EXT_convolution) { |
| 563 | ctx->Pixel.Convolution1DEnabled = state; |
| 564 | ctx->NewState |= _NEW_PIXEL; |
| 565 | } |
| 566 | else { |
| 567 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 568 | return; |
| 569 | } |
| Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 570 | break; |
| 571 | case GL_CONVOLUTION_2D: |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame^] | 572 | if (ctx->Extensions.EXT_convolution) { |
| 573 | ctx->Pixel.Convolution2DEnabled = state; |
| 574 | ctx->NewState |= _NEW_PIXEL; |
| 575 | } |
| 576 | else { |
| 577 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 578 | return; |
| 579 | } |
| Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 580 | break; |
| 581 | case GL_SEPARABLE_2D: |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame^] | 582 | if (ctx->Extensions.EXT_convolution) { |
| 583 | ctx->Pixel.Separable2DEnabled = state; |
| 584 | ctx->NewState |= _NEW_PIXEL; |
| 585 | } |
| 586 | else { |
| 587 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 588 | return; |
| 589 | } |
| Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 590 | break; |
| 591 | |
| Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 592 | /* GL_ARB_texture_cube_map */ |
| 593 | case GL_TEXTURE_CUBE_MAP_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 594 | if (ctx->Extensions.ARB_texture_cube_map) { |
| Brian Paul | b1394fa | 2000-09-26 20:53:53 +0000 | [diff] [blame] | 595 | if (ctx->Visual.RGBAflag) { |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 596 | const GLuint curr = ctx->Texture.CurrentUnit; |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 597 | struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 598 | ctx->NewState |= _NEW_TEXTURE; |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 599 | if (state) { |
| 600 | texUnit->Enabled |= TEXTURE0_CUBE; |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 601 | } |
| 602 | else { |
| 603 | texUnit->Enabled &= ~TEXTURE0_CUBE; |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 604 | } |
| Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 605 | } |
| 606 | } |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 607 | else { |
| Brian Paul | eb326f5 | 2000-10-21 01:29:12 +0000 | [diff] [blame] | 608 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 609 | return; |
| 610 | } |
| Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 611 | break; |
| Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 612 | |
| Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 613 | /* GL_EXT_secondary_color */ |
| 614 | case GL_COLOR_SUM_EXT: |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame^] | 615 | if (ctx->Extensions.EXT_secondary_color) { |
| 616 | ctx->Fog.ColorSumEnabled = state; |
| 617 | if (state) |
| 618 | SET_BITS(ctx->_TriangleCaps, DD_SEPERATE_SPECULAR); |
| 619 | else if (ctx->Light.Model.ColorControl == GL_SINGLE_COLOR) |
| 620 | CLEAR_BITS(ctx->_TriangleCaps, DD_SEPERATE_SPECULAR); |
| 621 | ctx->NewState |= _NEW_FOG; |
| 622 | } |
| 623 | else { |
| 624 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 625 | return; |
| 626 | } |
| 627 | break; |
| 628 | |
| 629 | /* GL_MESA_sprite_point */ |
| 630 | case GL_SPRITE_POINT_MESA: |
| 631 | if (ctx->Extensions.MESA_sprite_point) { |
| 632 | ctx->Point.SpriteMode = state; |
| 633 | ctx->NewState |= _NEW_POINT; |
| 634 | } |
| 635 | else { |
| 636 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| 637 | return; |
| 638 | } |
| Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 639 | break; |
| 640 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 641 | default: |
| Brian Paul | eb326f5 | 2000-10-21 01:29:12 +0000 | [diff] [blame] | 642 | gl_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable"); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 643 | return; |
| 644 | } |
| 645 | |
| 646 | if (ctx->Driver.Enable) { |
| 647 | (*ctx->Driver.Enable)( ctx, cap, state ); |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | |
| 652 | |
| 653 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 654 | void |
| 655 | _mesa_Enable( GLenum cap ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 656 | { |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 657 | GET_CURRENT_CONTEXT(ctx); |
| 658 | _mesa_set_enable( ctx, cap, GL_TRUE ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | |
| 662 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 663 | void |
| 664 | _mesa_Disable( GLenum cap ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 665 | { |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 666 | GET_CURRENT_CONTEXT(ctx); |
| 667 | _mesa_set_enable( ctx, cap, GL_FALSE ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | |
| 671 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 672 | GLboolean |
| 673 | _mesa_IsEnabled( GLenum cap ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 674 | { |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 675 | GET_CURRENT_CONTEXT(ctx); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 676 | switch (cap) { |
| 677 | case GL_ALPHA_TEST: |
| 678 | return ctx->Color.AlphaEnabled; |
| 679 | case GL_AUTO_NORMAL: |
| 680 | return ctx->Eval.AutoNormal; |
| 681 | case GL_BLEND: |
| 682 | return ctx->Color.BlendEnabled; |
| 683 | case GL_CLIP_PLANE0: |
| 684 | case GL_CLIP_PLANE1: |
| 685 | case GL_CLIP_PLANE2: |
| 686 | case GL_CLIP_PLANE3: |
| 687 | case GL_CLIP_PLANE4: |
| 688 | case GL_CLIP_PLANE5: |
| 689 | return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0]; |
| 690 | case GL_COLOR_MATERIAL: |
| 691 | return ctx->Light.ColorMaterialEnabled; |
| 692 | case GL_CULL_FACE: |
| 693 | return ctx->Polygon.CullFlag; |
| 694 | case GL_DEPTH_TEST: |
| 695 | return ctx->Depth.Test; |
| 696 | case GL_DITHER: |
| 697 | return ctx->Color.DitherFlag; |
| 698 | case GL_FOG: |
| 699 | return ctx->Fog.Enabled; |
| Brian Paul | 1a1cf7e | 2000-05-04 13:48:49 +0000 | [diff] [blame] | 700 | case GL_HISTOGRAM: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 701 | if (ctx->Extensions.EXT_histogram) { |
| Brian Paul | 8e05391 | 2000-08-30 18:21:06 +0000 | [diff] [blame] | 702 | return ctx->Pixel.HistogramEnabled; |
| 703 | } |
| 704 | else { |
| 705 | gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); |
| 706 | return GL_FALSE; |
| 707 | } |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 708 | case GL_LIGHTING: |
| 709 | return ctx->Light.Enabled; |
| 710 | case GL_LIGHT0: |
| 711 | case GL_LIGHT1: |
| 712 | case GL_LIGHT2: |
| 713 | case GL_LIGHT3: |
| 714 | case GL_LIGHT4: |
| 715 | case GL_LIGHT5: |
| 716 | case GL_LIGHT6: |
| 717 | case GL_LIGHT7: |
| 718 | return ctx->Light.Light[cap-GL_LIGHT0].Enabled; |
| 719 | case GL_LINE_SMOOTH: |
| 720 | return ctx->Line.SmoothFlag; |
| 721 | case GL_LINE_STIPPLE: |
| 722 | return ctx->Line.StippleFlag; |
| 723 | case GL_INDEX_LOGIC_OP: |
| 724 | return ctx->Color.IndexLogicOpEnabled; |
| 725 | case GL_COLOR_LOGIC_OP: |
| 726 | return ctx->Color.ColorLogicOpEnabled; |
| 727 | case GL_MAP1_COLOR_4: |
| 728 | return ctx->Eval.Map1Color4; |
| 729 | case GL_MAP1_INDEX: |
| 730 | return ctx->Eval.Map1Index; |
| 731 | case GL_MAP1_NORMAL: |
| 732 | return ctx->Eval.Map1Normal; |
| 733 | case GL_MAP1_TEXTURE_COORD_1: |
| 734 | return ctx->Eval.Map1TextureCoord1; |
| 735 | case GL_MAP1_TEXTURE_COORD_2: |
| 736 | return ctx->Eval.Map1TextureCoord2; |
| 737 | case GL_MAP1_TEXTURE_COORD_3: |
| 738 | return ctx->Eval.Map1TextureCoord3; |
| 739 | case GL_MAP1_TEXTURE_COORD_4: |
| 740 | return ctx->Eval.Map1TextureCoord4; |
| 741 | case GL_MAP1_VERTEX_3: |
| 742 | return ctx->Eval.Map1Vertex3; |
| 743 | case GL_MAP1_VERTEX_4: |
| 744 | return ctx->Eval.Map1Vertex4; |
| 745 | case GL_MAP2_COLOR_4: |
| 746 | return ctx->Eval.Map2Color4; |
| 747 | case GL_MAP2_INDEX: |
| 748 | return ctx->Eval.Map2Index; |
| 749 | case GL_MAP2_NORMAL: |
| 750 | return ctx->Eval.Map2Normal; |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 751 | case GL_MAP2_TEXTURE_COORD_1: |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 752 | return ctx->Eval.Map2TextureCoord1; |
| 753 | case GL_MAP2_TEXTURE_COORD_2: |
| 754 | return ctx->Eval.Map2TextureCoord2; |
| 755 | case GL_MAP2_TEXTURE_COORD_3: |
| 756 | return ctx->Eval.Map2TextureCoord3; |
| 757 | case GL_MAP2_TEXTURE_COORD_4: |
| 758 | return ctx->Eval.Map2TextureCoord4; |
| 759 | case GL_MAP2_VERTEX_3: |
| 760 | return ctx->Eval.Map2Vertex3; |
| 761 | case GL_MAP2_VERTEX_4: |
| 762 | return ctx->Eval.Map2Vertex4; |
| Brian Paul | 1a1cf7e | 2000-05-04 13:48:49 +0000 | [diff] [blame] | 763 | case GL_MINMAX: |
| 764 | return ctx->Pixel.MinMaxEnabled; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 765 | case GL_NORMALIZE: |
| 766 | return ctx->Transform.Normalize; |
| 767 | case GL_POINT_SMOOTH: |
| 768 | return ctx->Point.SmoothFlag; |
| 769 | case GL_POLYGON_SMOOTH: |
| 770 | return ctx->Polygon.SmoothFlag; |
| 771 | case GL_POLYGON_STIPPLE: |
| 772 | return ctx->Polygon.StippleFlag; |
| 773 | case GL_POLYGON_OFFSET_POINT: |
| 774 | return ctx->Polygon.OffsetPoint; |
| 775 | case GL_POLYGON_OFFSET_LINE: |
| 776 | return ctx->Polygon.OffsetLine; |
| 777 | case GL_POLYGON_OFFSET_FILL: |
| 778 | /*case GL_POLYGON_OFFSET_EXT:*/ |
| 779 | return ctx->Polygon.OffsetFill; |
| 780 | case GL_RESCALE_NORMAL_EXT: |
| 781 | return ctx->Transform.RescaleNormals; |
| 782 | case GL_SCISSOR_TEST: |
| 783 | return ctx->Scissor.Enabled; |
| 784 | case GL_SHARED_TEXTURE_PALETTE_EXT: |
| 785 | return ctx->Texture.SharedPalette; |
| 786 | case GL_STENCIL_TEST: |
| 787 | return ctx->Stencil.Enabled; |
| 788 | case GL_TEXTURE_1D: |
| 789 | { |
| 790 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 791 | return (texUnit->Enabled & TEXTURE0_1D) ? GL_TRUE : GL_FALSE; |
| 792 | } |
| 793 | case GL_TEXTURE_2D: |
| 794 | { |
| 795 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 796 | return (texUnit->Enabled & TEXTURE0_2D) ? GL_TRUE : GL_FALSE; |
| 797 | } |
| 798 | case GL_TEXTURE_3D: |
| 799 | { |
| 800 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| Brian Paul | 65b5e1e | 1999-08-19 13:24:27 +0000 | [diff] [blame] | 801 | return (texUnit->Enabled & TEXTURE0_3D) ? GL_TRUE : GL_FALSE; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 802 | } |
| 803 | case GL_TEXTURE_GEN_Q: |
| 804 | { |
| 805 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 806 | return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE; |
| 807 | } |
| 808 | case GL_TEXTURE_GEN_R: |
| 809 | { |
| 810 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 811 | return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE; |
| 812 | } |
| 813 | case GL_TEXTURE_GEN_S: |
| 814 | { |
| 815 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 816 | return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE; |
| 817 | } |
| 818 | case GL_TEXTURE_GEN_T: |
| 819 | { |
| 820 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 821 | return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE; |
| 822 | } |
| 823 | |
| 824 | /* |
| 825 | * CLIENT STATE!!! |
| 826 | */ |
| 827 | case GL_VERTEX_ARRAY: |
| 828 | return ctx->Array.Vertex.Enabled; |
| 829 | case GL_NORMAL_ARRAY: |
| 830 | return ctx->Array.Normal.Enabled; |
| 831 | case GL_COLOR_ARRAY: |
| 832 | return ctx->Array.Color.Enabled; |
| 833 | case GL_INDEX_ARRAY: |
| 834 | return ctx->Array.Index.Enabled; |
| 835 | case GL_TEXTURE_COORD_ARRAY: |
| Brian Paul | 45224fa | 1999-09-07 22:31:30 +0000 | [diff] [blame] | 836 | return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 837 | case GL_EDGE_FLAG_ARRAY: |
| 838 | return ctx->Array.EdgeFlag.Enabled; |
| Brian Paul | 1b2ff69 | 2000-03-11 23:23:26 +0000 | [diff] [blame] | 839 | |
| 840 | /* GL_HP_occlusion_test */ |
| 841 | case GL_OCCLUSION_TEST_HP: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 842 | if (ctx->Extensions.HP_occlusion_test) { |
| Brian Paul | 1b2ff69 | 2000-03-11 23:23:26 +0000 | [diff] [blame] | 843 | return ctx->Depth.OcclusionTest; |
| 844 | } |
| 845 | else { |
| 846 | gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" ); |
| 847 | return GL_FALSE; |
| 848 | } |
| 849 | |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 850 | /* GL_SGIS_pixel_texture */ |
| 851 | case GL_PIXEL_TEXTURE_SGIS: |
| 852 | return ctx->Pixel.PixelTextureEnabled; |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 853 | |
| 854 | /* GL_SGIX_pixel_texture */ |
| 855 | case GL_PIXEL_TEX_GEN_SGIX: |
| 856 | return ctx->Pixel.PixelTextureEnabled; |
| Brian Paul | 1381137 | 2000-04-12 00:27:37 +0000 | [diff] [blame] | 857 | |
| 858 | /* GL_SGI_color_table */ |
| 859 | case GL_COLOR_TABLE_SGI: |
| 860 | return ctx->Pixel.ColorTableEnabled; |
| 861 | case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: |
| 862 | return ctx->Pixel.PostConvolutionColorTableEnabled; |
| 863 | case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: |
| 864 | return ctx->Pixel.PostColorMatrixColorTableEnabled; |
| Brian Paul | 2b2e925 | 2000-04-07 16:27:26 +0000 | [diff] [blame] | 865 | |
| Brian Paul | 82b02f0 | 2000-05-07 20:37:40 +0000 | [diff] [blame] | 866 | /* GL_EXT_convolution */ |
| 867 | case GL_CONVOLUTION_1D: |
| 868 | return ctx->Pixel.Convolution1DEnabled; |
| 869 | case GL_CONVOLUTION_2D: |
| 870 | return ctx->Pixel.Convolution2DEnabled; |
| 871 | case GL_SEPARABLE_2D: |
| 872 | return ctx->Pixel.Separable2DEnabled; |
| 873 | |
| Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 874 | /* GL_ARB_texture_cube_map */ |
| 875 | case GL_TEXTURE_CUBE_MAP_ARB: |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 876 | if (ctx->Extensions.ARB_texture_cube_map) { |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 877 | const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; |
| 878 | return (texUnit->Enabled & TEXTURE0_CUBE) ? GL_TRUE : GL_FALSE; |
| Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 879 | } |
| Brian Paul | fc4b443 | 2000-05-23 15:17:12 +0000 | [diff] [blame] | 880 | else { |
| 881 | gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); |
| 882 | return GL_FALSE; |
| 883 | } |
| Brian Paul | 86fc370 | 2000-05-22 16:33:20 +0000 | [diff] [blame] | 884 | |
| Brian Paul | 06d05af | 2000-12-08 00:20:15 +0000 | [diff] [blame^] | 885 | /* GL_MESA_sprite_point */ |
| 886 | case GL_SPRITE_POINT_MESA: |
| 887 | return ctx->Point.SpriteMode; |
| 888 | |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 889 | default: |
| 890 | gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" ); |
| 891 | return GL_FALSE; |
| 892 | } |
| 893 | } |
| 894 | |
| 895 | |
| 896 | |
| 897 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 898 | static void |
| 899 | client_state( GLcontext *ctx, GLenum cap, GLboolean state ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 900 | { |
| Jouk Jansen | 5e3bc0c | 2000-11-22 07:32:16 +0000 | [diff] [blame] | 901 | ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, |
| 902 | (state |
| 903 | ? "glEnableClientState" |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 904 | : "glDisableClientState") ); |
| 905 | |
| 906 | switch (cap) { |
| 907 | case GL_VERTEX_ARRAY: |
| 908 | ctx->Array.Vertex.Enabled = state; |
| 909 | break; |
| 910 | case GL_NORMAL_ARRAY: |
| 911 | ctx->Array.Normal.Enabled = state; |
| 912 | break; |
| 913 | case GL_COLOR_ARRAY: |
| 914 | ctx->Array.Color.Enabled = state; |
| 915 | break; |
| 916 | case GL_INDEX_ARRAY: |
| 917 | ctx->Array.Index.Enabled = state; |
| 918 | break; |
| 919 | case GL_TEXTURE_COORD_ARRAY: |
| Brian Paul | 45224fa | 1999-09-07 22:31:30 +0000 | [diff] [blame] | 920 | ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled = state; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 921 | break; |
| 922 | case GL_EDGE_FLAG_ARRAY: |
| 923 | ctx->Array.EdgeFlag.Enabled = state; |
| 924 | break; |
| Keith Whitwell | fe5d67d | 2000-10-27 16:44:40 +0000 | [diff] [blame] | 925 | case GL_FOG_COORDINATE_ARRAY_EXT: |
| 926 | ctx->Array.FogCoord.Enabled = state; |
| 927 | break; |
| 928 | case GL_SECONDARY_COLOR_ARRAY_EXT: |
| 929 | ctx->Array.SecondaryColor.Enabled = state; |
| 930 | break; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 931 | default: |
| 932 | gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" ); |
| 933 | } |
| 934 | |
| Keith Whitwell | a96308c | 2000-10-30 13:31:59 +0000 | [diff] [blame] | 935 | ctx->NewState |= _NEW_ARRAY; |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | |
| 939 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 940 | void |
| 941 | _mesa_EnableClientState( GLenum cap ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 942 | { |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 943 | GET_CURRENT_CONTEXT(ctx); |
| 944 | client_state( ctx, cap, GL_TRUE ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | |
| 948 | |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 949 | void |
| 950 | _mesa_DisableClientState( GLenum cap ) |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 951 | { |
| Brian Paul | fbd8f21 | 1999-11-11 01:22:25 +0000 | [diff] [blame] | 952 | GET_CURRENT_CONTEXT(ctx); |
| 953 | client_state( ctx, cap, GL_FALSE ); |
| jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 954 | } |
| 955 | |