home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 5 / MA_Cover_5.iso / ppc / mesa / src / enable.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-31  |  17.7 KB  |  681 lines

  1. /* $Id: enable.c,v 1.23 1997/10/29 02:23:54 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  2.5
  6.  * Copyright (C) 1995-1997  Brian Paul
  7.  *
  8.  * This library is free software; you can redistribute it and/or
  9.  * modify it under the terms of the GNU Library General Public
  10.  * License as published by the Free Software Foundation; either
  11.  * version 2 of the License, or (at your option) any later version.
  12.  *
  13.  * This library is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  * Library General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU Library General Public
  19.  * License along with this library; if not, write to the Free
  20.  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  */
  22.  
  23.  
  24. /*
  25.  * $Log: enable.c,v $
  26.  * Revision 1.23  1997/10/29 02:23:54  brianp
  27.  * added UseGlobalTexturePalette() dd function (David Bucciarelli v20 3dfx)
  28.  *
  29.  * Revision 1.22  1997/10/16 01:59:08  brianp
  30.  * added GL_EXT_shared_texture_palette extension
  31.  *
  32.  * Revision 1.21  1997/07/24 01:25:01  brianp
  33.  * changed precompiled header symbol from PCH to PC_HEADER
  34.  *
  35.  * Revision 1.20  1997/06/20 02:20:32  brianp
  36.  * replaced Current.IntColor with Current.ByteColor
  37.  *
  38.  * Revision 1.19  1997/05/31 16:57:14  brianp
  39.  * added MESA_NO_RASTER env var support
  40.  *
  41.  * Revision 1.18  1997/05/28 03:24:22  brianp
  42.  * added precompiled header (PCH) support
  43.  *
  44.  * Revision 1.17  1997/04/24 01:49:30  brianp
  45.  * call gl_set_color_function() instead of directly setting pointers
  46.  *
  47.  * Revision 1.16  1997/04/12 16:54:05  brianp
  48.  * new NEW_POLYGON state flag
  49.  *
  50.  * Revision 1.15  1997/04/12 16:20:27  brianp
  51.  * removed call to Driver.Dither()
  52.  *
  53.  * Revision 1.14  1997/04/02 03:10:36  brianp
  54.  * changed some #include's
  55.  *
  56.  * Revision 1.13  1997/02/27 19:59:08  brianp
  57.  * issue a warning if enable depth or stencil test without such a buffer
  58.  *
  59.  * Revision 1.12  1997/02/09 19:53:43  brianp
  60.  * now use TEXTURE_xD enable constants
  61.  *
  62.  * Revision 1.11  1997/02/09 18:49:37  brianp
  63.  * added GL_EXT_texture3D support
  64.  *
  65.  * Revision 1.10  1997/01/28 22:13:42  brianp
  66.  * now there's separate state for CI and RGBA logic op enabled
  67.  *
  68.  * Revision 1.9  1996/12/18 20:00:57  brianp
  69.  * gl_set_material() now takes a bitmask instead of face and pname
  70.  *
  71.  * Revision 1.8  1996/12/11 20:16:49  brianp
  72.  * more work on the GL_COLOR_MATERIAL bug
  73.  *
  74.  * Revision 1.7  1996/12/09 22:51:51  brianp
  75.  * update API Color4f and Color4ub pointers for GL_COLOR_MATERIAL
  76.  *
  77.  * Revision 1.6  1996/12/07 10:21:07  brianp
  78.  * call gl_set_material() instead of gl_Materialfv()
  79.  *
  80.  * Revision 1.5  1996/11/09 03:11:18  brianp
  81.  * added missing GL_EXT_vertex_array caps to gl_enable()
  82.  *
  83.  * Revision 1.4  1996/10/11 03:44:09  brianp
  84.  * added comments for GL_POLYGON_OFFSET_EXT symbol
  85.  *
  86.  * Revision 1.3  1996/09/27 01:26:40  brianp
  87.  * removed unused variables
  88.  *
  89.  * Revision 1.2  1996/09/15 14:17:30  brianp
  90.  * now use GLframebuffer and GLvisual
  91.  *
  92.  * Revision 1.1  1996/09/13 01:38:16  brianp
  93.  * Initial revision
  94.  *
  95.  */
  96.  
  97.  
  98. #ifdef PC_HEADER
  99. #include "all.h"
  100. #else
  101. #include <string.h>
  102. #include <stdio.h>
  103. #include "context.h"
  104. #include "depth.h"
  105. #include "enable.h"
  106. #include "light.h"
  107. #include "dlist.h"
  108. #include "macros.h"
  109. #include "stencil.h"
  110. #include "types.h"
  111. #include "vbfill.h"
  112. #endif
  113.  
  114.  
  115.  
  116. /*
  117.  * Perform glEnable and glDisable calls.
  118.  */
  119. static void gl_enable( GLcontext* ctx, GLenum cap, GLboolean state )
  120. {
  121.    GLuint p;
  122.  
  123.    if (INSIDE_BEGIN_END(ctx)) {
  124.       if (state) {
  125.      gl_error( ctx, GL_INVALID_OPERATION, "glEnable" );
  126.       }
  127.       else {
  128.      gl_error( ctx, GL_INVALID_OPERATION, "glDisable" );
  129.       }
  130.       return;
  131.    }
  132.  
  133.    switch (cap) {
  134.       case GL_ALPHA_TEST:
  135.      if (ctx->Color.AlphaEnabled!=state) {
  136.         ctx->Color.AlphaEnabled = state;
  137.         ctx->NewState |= NEW_RASTER_OPS;
  138.      }
  139.      break;
  140.       case GL_AUTO_NORMAL:
  141.      ctx->Eval.AutoNormal = state;
  142.      break;
  143.       case GL_BLEND:
  144.      if (ctx->Color.BlendEnabled!=state) {
  145.         ctx->Color.BlendEnabled = state;
  146.         /* The following needed to accomodate 1.0 RGB logic op blending */
  147.         if (ctx->Color.BlendEquation==GL_LOGIC_OP && state) {
  148.            ctx->Color.ColorLogicOpEnabled = GL_TRUE;
  149.         }
  150.         else {
  151.            ctx->Color.ColorLogicOpEnabled = GL_FALSE;
  152.         }
  153.         ctx->NewState |= NEW_RASTER_OPS;
  154.      }
  155.      break;
  156.       case GL_CLIP_PLANE0:
  157.       case GL_CLIP_PLANE1:
  158.       case GL_CLIP_PLANE2:
  159.       case GL_CLIP_PLANE3:
  160.       case GL_CLIP_PLANE4:
  161.       case GL_CLIP_PLANE5:
  162.      ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0] = state;
  163.      /* Check if any clip planes enabled */
  164.      ctx->Transform.AnyClip = GL_FALSE;
  165.      for (p=0;p<MAX_CLIP_PLANES;p++) {
  166.         if (ctx->Transform.ClipEnabled[p]) {
  167.            ctx->Transform.AnyClip = GL_TRUE;
  168.            break;
  169.         }
  170.      }
  171.      break;
  172.       case GL_COLOR_MATERIAL:
  173.      if (ctx->Light.ColorMaterialEnabled!=state) {
  174.         ctx->Light.ColorMaterialEnabled = state;
  175.         if (state) {
  176.            GLfloat color[4];
  177.            color[0] = ctx->Current.ByteColor[0] * ctx->Visual->InvRedScale;
  178.            color[1] = ctx->Current.ByteColor[1] * ctx->Visual->InvGreenScale;
  179.            color[2] = ctx->Current.ByteColor[2] * ctx->Visual->InvBlueScale;
  180.            color[3] = ctx->Current.ByteColor[3] * ctx->Visual->InvAlphaScale;
  181.            /* update material with current color */
  182.            gl_set_material( ctx, ctx->Light.ColorMaterialBitmask, color );
  183.         }
  184.         gl_set_color_function(ctx);
  185.         ctx->NewState |= NEW_LIGHTING;
  186.      }
  187.      break;
  188.       case GL_CULL_FACE:
  189.      if (ctx->Polygon.CullFlag!=state) {
  190.         ctx->Polygon.CullFlag = state;
  191.         ctx->NewState |= NEW_POLYGON;
  192.      }
  193.      break;
  194.       case GL_DEPTH_TEST:
  195.      if (state && ctx->Visual->DepthBits==0) {
  196.         gl_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
  197.         return;
  198.      }
  199.      if (ctx->Depth.Test!=state) {
  200.         ctx->Depth.Test = state;
  201.         ctx->NewState |= NEW_RASTER_OPS;
  202.      }
  203.      break;
  204.       case GL_DITHER:
  205.      if (ctx->NoDither) {
  206.         /* MESA_NO_DITHER env var */
  207.         state = GL_FALSE;
  208.      }
  209.      if (ctx->Color.DitherFlag!=state) {
  210.         ctx->Color.DitherFlag = state;
  211.         ctx->NewState |= NEW_RASTER_OPS;
  212.      }
  213.      break;
  214.       case GL_FOG:
  215.      if (ctx->Fog.Enabled!=state) {
  216.         ctx->Fog.Enabled = state;
  217.         ctx->NewState |= NEW_RASTER_OPS;
  218.      }
  219.      break;
  220.       case GL_LIGHT0:
  221.       case GL_LIGHT1:
  222.       case GL_LIGHT2:
  223.       case GL_LIGHT3:
  224.       case GL_LIGHT4:
  225.       case GL_LIGHT5:
  226.       case GL_LIGHT6:
  227.       case GL_LIGHT7:
  228.      ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
  229.      ctx->NewState |= NEW_LIGHTING;
  230.      break;
  231.       case GL_LIGHTING:
  232.      if (ctx->Light.Enabled!=state) {
  233.         ctx->Light.Enabled = state;
  234.         ctx->NewState |= NEW_LIGHTING;
  235.      }
  236.      break;
  237.       case GL_LINE_SMOOTH:
  238.      if (ctx->Line.SmoothFlag!=state) {
  239.         ctx->Line.SmoothFlag = state;
  240.         ctx->NewState |= NEW_RASTER_OPS;
  241.      }
  242.      break;
  243.       case GL_LINE_STIPPLE:
  244.      if (ctx->Line.StippleFlag!=state) {
  245.         ctx->Line.StippleFlag = state;
  246.         ctx->NewState |= NEW_RASTER_OPS;
  247.      }
  248.      break;
  249.       case GL_INDEX_LOGIC_OP:
  250.      if (ctx->Color.IndexLogicOpEnabled!=state) {
  251.         ctx->NewState |= NEW_RASTER_OPS;
  252.      }
  253.      ctx->Color.IndexLogicOpEnabled = state;
  254.      break;
  255.       case GL_COLOR_LOGIC_OP:
  256.      if (ctx->Color.ColorLogicOpEnabled!=state) {
  257.         ctx->NewState |= NEW_RASTER_OPS;
  258.      }
  259.      ctx->Color.ColorLogicOpEnabled = state;
  260.      break;
  261.       case GL_MAP1_COLOR_4:
  262.      ctx->Eval.Map1Color4 = state;
  263.      break;
  264.       case GL_MAP1_INDEX:
  265.      ctx->Eval.Map1Index = state;
  266.      break;
  267.       case GL_MAP1_NORMAL:
  268.      ctx->Eval.Map1Normal = state;
  269.      break;
  270.       case GL_MAP1_TEXTURE_COORD_1:
  271.      ctx->Eval.Map1TextureCoord1 = state;
  272.      break;
  273.       case GL_MAP1_TEXTURE_COORD_2:
  274.      ctx->Eval.Map1TextureCoord2 = state;
  275.      break;
  276.       case GL_MAP1_TEXTURE_COORD_3:
  277.      ctx->Eval.Map1TextureCoord3 = state;
  278.      break;
  279.       case GL_MAP1_TEXTURE_COORD_4:
  280.      ctx->Eval.Map1TextureCoord4 = state;
  281.      break;
  282.       case GL_MAP1_VERTEX_3:
  283.      ctx->Eval.Map1Vertex3 = state;
  284.      break;
  285.       case GL_MAP1_VERTEX_4:
  286.      ctx->Eval.Map1Vertex4 = state;
  287.      break;
  288.       case GL_MAP2_COLOR_4:
  289.      ctx->Eval.Map2Color4 = state;
  290.      break;
  291.       case GL_MAP2_INDEX:
  292.      ctx->Eval.Map2Index = state;
  293.      break;
  294.       case GL_MAP2_NORMAL:
  295.      ctx->Eval.Map2Normal = state;
  296.      break;
  297.       case GL_MAP2_TEXTURE_COORD_1: 
  298.      ctx->Eval.Map2TextureCoord1 = state;
  299.      break;
  300.       case GL_MAP2_TEXTURE_COORD_2:
  301.      ctx->Eval.Map2TextureCoord2 = state;
  302.      break;
  303.       case GL_MAP2_TEXTURE_COORD_3:
  304.      ctx->Eval.Map2TextureCoord3 = state;
  305.      break;
  306.       case GL_MAP2_TEXTURE_COORD_4:
  307.      ctx->Eval.Map2TextureCoord4 = state;
  308.      break;
  309.       case GL_MAP2_VERTEX_3:
  310.      ctx->Eval.Map2Vertex3 = state;
  311.      break;
  312.       case GL_MAP2_VERTEX_4:
  313.      ctx->Eval.Map2Vertex4 = state;
  314.      break;
  315.       case GL_NORMALIZE:
  316.      ctx->Transform.Normalize = state;
  317.      break;
  318.       case GL_POINT_SMOOTH:
  319.      if (ctx->Point.SmoothFlag!=state) {
  320.         ctx->Point.SmoothFlag = state;
  321.         ctx->NewState |= NEW_RASTER_OPS;
  322.      }
  323.      break;
  324.       case GL_POLYGON_SMOOTH:
  325.      if (ctx->Polygon.SmoothFlag!=state) {
  326.         ctx->Polygon.SmoothFlag = state;
  327.         ctx->NewState |= NEW_RASTER_OPS;
  328.      }
  329.      break;
  330.       case GL_POLYGON_STIPPLE:
  331.      if (ctx->Polygon.StippleFlag!=state) {
  332.         ctx->Polygon.StippleFlag = state;
  333.         ctx->NewState |= NEW_RASTER_OPS;
  334.      }
  335.      break;
  336.       case GL_POLYGON_OFFSET_POINT:
  337.      if (ctx->Polygon.OffsetPoint!=state) {
  338.         ctx->Polygon.OffsetPoint = state;
  339.         ctx->NewState |= NEW_POLYGON;
  340.      }
  341.      break;
  342.       case GL_POLYGON_OFFSET_LINE:
  343.      if (ctx->Polygon.OffsetLine!=state) {
  344.         ctx->Polygon.OffsetLine = state;
  345.         ctx->NewState |= NEW_POLYGON;
  346.      }
  347.      break;
  348.       case GL_POLYGON_OFFSET_FILL:
  349.       /*case GL_POLYGON_OFFSET_EXT:*/
  350.      if (ctx->Polygon.OffsetFill!=state) {
  351.         ctx->Polygon.OffsetFill = state;
  352.         ctx->NewState |= NEW_POLYGON;
  353.      }
  354.      break;
  355.       case GL_SCISSOR_TEST:
  356.      if (ctx->Scissor.Enabled!=state) {
  357.         ctx->Scissor.Enabled = state;
  358.         ctx->NewState |= NEW_RASTER_OPS;
  359.      }
  360.      break;
  361.       case GL_SHARED_TEXTURE_PALETTE_EXT:
  362.      ctx->Texture.SharedPalette = state;
  363.      if (ctx->Driver.UseGlobalTexturePalette)
  364.         (*ctx->Driver.UseGlobalTexturePalette)( ctx, state );
  365.      break;
  366.       case GL_STENCIL_TEST:
  367.      if (state && ctx->Visual->StencilBits==0) {
  368.         gl_warning(ctx, "glEnable(GL_STENCIL_TEST) but no stencil buffer");
  369.         return;
  370.      }
  371.      if (ctx->Stencil.Enabled!=state) {
  372.         ctx->Stencil.Enabled = state;
  373.         ctx->NewState |= NEW_RASTER_OPS;
  374.      }
  375.      break;
  376.       case GL_TEXTURE_1D:
  377.      if (ctx->Visual->RGBAflag) {
  378.         /* texturing only works in RGB mode */
  379.         if (state) {
  380.            ctx->Texture.Enabled |= TEXTURE_1D;
  381.         }
  382.         else {
  383.            ctx->Texture.Enabled &= (~TEXTURE_1D);
  384.         }
  385.         ctx->NewState |= (NEW_RASTER_OPS | NEW_TEXTURING);
  386.      }
  387.      break;
  388.       case GL_TEXTURE_2D:
  389.      if (ctx->Visual->RGBAflag) {
  390.         /* texturing only works in RGB mode */
  391.         if (state) {
  392.            ctx->Texture.Enabled |= TEXTURE_2D;
  393.         }
  394.         else {
  395.            ctx->Texture.Enabled &= (~TEXTURE_2D);
  396.         }
  397.         ctx->NewState |= (NEW_RASTER_OPS | NEW_TEXTURING);
  398.      }
  399.      break;
  400.       case GL_TEXTURE_3D_EXT:
  401.      if (ctx->Visual->RGBAflag) {
  402.         /* texturing only works in RGB mode */
  403.         if (state) {
  404.            ctx->Texture.Enabled |= TEXTURE_3D;
  405.         }
  406.         else {
  407.            ctx->Texture.Enabled &= (~TEXTURE_3D);
  408.         }
  409.         ctx->NewState |= (NEW_RASTER_OPS | NEW_TEXTURING);
  410.      }
  411.      break;
  412.       case GL_TEXTURE_GEN_Q:
  413.      if (state) {
  414.         ctx->Texture.TexGenEnabled |= Q_BIT;
  415.      }
  416.      else {
  417.         ctx->Texture.TexGenEnabled &= ~Q_BIT;
  418.      }
  419.      ctx->NewState |= NEW_TEXTURING;
  420.      break;
  421.       case GL_TEXTURE_GEN_R:
  422.      if (state) {
  423.         ctx->Texture.TexGenEnabled |= R_BIT;
  424.      }
  425.      else {
  426.         ctx->Texture.TexGenEnabled &= ~R_BIT;
  427.      }
  428.      ctx->NewState |= NEW_TEXTURING;
  429.      break;
  430.       case GL_TEXTURE_GEN_S:
  431.      if (state) {
  432.         ctx->Texture.TexGenEnabled |= S_BIT;
  433.      }
  434.      else {
  435.         ctx->Texture.TexGenEnabled &= ~S_BIT;
  436.      }
  437.      ctx->NewState |= NEW_TEXTURING;
  438.      break;
  439.       case GL_TEXTURE_GEN_T:
  440.      if (state) {
  441.         ctx->Texture.TexGenEnabled |= T_BIT;
  442.      }
  443.      else {
  444.         ctx->Texture.TexGenEnabled &= ~T_BIT;
  445.      }
  446.      ctx->NewState |= NEW_TEXTURING;
  447.      break;
  448.  
  449.       /*
  450.        * CLIENT STATE!!!
  451.        */
  452.       case GL_VERTEX_ARRAY:
  453.      ctx->Array.VertexEnabled = state;
  454.      break;
  455.       case GL_NORMAL_ARRAY:
  456.      ctx->Array.NormalEnabled = state;
  457.      break;
  458.       case GL_COLOR_ARRAY:
  459.      ctx->Array.ColorEnabled = state;
  460.      break;
  461.       case GL_INDEX_ARRAY:
  462.      ctx->Array.IndexEnabled = state;
  463.      break;
  464.       case GL_TEXTURE_COORD_ARRAY:
  465.      ctx->Array.TexCoordEnabled = state;
  466.      break;
  467.       case GL_EDGE_FLAG_ARRAY:
  468.      ctx->Array.EdgeFlagEnabled = state;
  469.      break;
  470.  
  471.       default:
  472.      if (state) {
  473.         gl_error( ctx, GL_INVALID_ENUM, "glEnable" );
  474.      }
  475.      else {
  476.         gl_error( ctx, GL_INVALID_ENUM, "glDisable" );
  477.      }
  478.      break;
  479.    }
  480. }
  481.  
  482.  
  483.  
  484.  
  485. void gl_Enable( GLcontext* ctx, GLenum cap )
  486. {
  487.    gl_enable( ctx, cap, GL_TRUE );
  488. }
  489.  
  490.  
  491.  
  492. void gl_Disable( GLcontext* ctx, GLenum cap )
  493. {
  494.    gl_enable( ctx, cap, GL_FALSE );
  495. }
  496.  
  497.  
  498.  
  499. GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap )
  500. {
  501.    switch (cap) {
  502.       case GL_ALPHA_TEST:
  503.      return ctx->Color.AlphaEnabled;
  504.       case GL_AUTO_NORMAL:
  505.      return ctx->Eval.AutoNormal;
  506.       case GL_BLEND:
  507.      return ctx->Color.BlendEnabled;
  508.       case GL_CLIP_PLANE0:
  509.       case GL_CLIP_PLANE1:
  510.       case GL_CLIP_PLANE2:
  511.       case GL_CLIP_PLANE3:
  512.       case GL_CLIP_PLANE4:
  513.       case GL_CLIP_PLANE5:
  514.      return ctx->Transform.ClipEnabled[cap-GL_CLIP_PLANE0];
  515.       case GL_COLOR_MATERIAL:
  516.      return ctx->Light.ColorMaterialEnabled;
  517.       case GL_CULL_FACE:
  518.      return ctx->Polygon.CullFlag;
  519.       case GL_DEPTH_TEST:
  520.      return ctx->Depth.Test;
  521.       case GL_DITHER:
  522.      return ctx->Color.DitherFlag;
  523.       case GL_FOG:
  524.      return ctx->Fog.Enabled;
  525.       case GL_LIGHTING:
  526.      return ctx->Light.Enabled;
  527.       case GL_LIGHT0:
  528.       case GL_LIGHT1:
  529.       case GL_LIGHT2:
  530.       case GL_LIGHT3:
  531.       case GL_LIGHT4:
  532.       case GL_LIGHT5:
  533.       case GL_LIGHT6:
  534.       case GL_LIGHT7:
  535.      return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
  536.       case GL_LINE_SMOOTH:
  537.      return ctx->Line.SmoothFlag;
  538.       case GL_LINE_STIPPLE:
  539.      return ctx->Line.StippleFlag;
  540.       case GL_INDEX_LOGIC_OP:
  541.      return ctx->Color.IndexLogicOpEnabled;
  542.       case GL_COLOR_LOGIC_OP:
  543.      return ctx->Color.ColorLogicOpEnabled;
  544.       case GL_MAP1_COLOR_4:
  545.      return ctx->Eval.Map1Color4;
  546.       case GL_MAP1_INDEX:
  547.      return ctx->Eval.Map1Index;
  548.       case GL_MAP1_NORMAL:
  549.      return ctx->Eval.Map1Normal;
  550.       case GL_MAP1_TEXTURE_COORD_1:
  551.      return ctx->Eval.Map1TextureCoord1;
  552.       case GL_MAP1_TEXTURE_COORD_2:
  553.      return ctx->Eval.Map1TextureCoord2;
  554.       case GL_MAP1_TEXTURE_COORD_3:
  555.      return ctx->Eval.Map1TextureCoord3;
  556.       case GL_MAP1_TEXTURE_COORD_4:
  557.      return ctx->Eval.Map1TextureCoord4;
  558.       case GL_MAP1_VERTEX_3:
  559.      return ctx->Eval.Map1Vertex3;
  560.       case GL_MAP1_VERTEX_4:
  561.      return ctx->Eval.Map1Vertex4;
  562.       case GL_MAP2_COLOR_4:
  563.      return ctx->Eval.Map2Color4;
  564.       case GL_MAP2_INDEX:
  565.      return ctx->Eval.Map2Index;
  566.       case GL_MAP2_NORMAL:
  567.      return ctx->Eval.Map2Normal;
  568.       case GL_MAP2_TEXTURE_COORD_1: 
  569.      return ctx->Eval.Map2TextureCoord1;
  570.       case GL_MAP2_TEXTURE_COORD_2:
  571.      return ctx->Eval.Map2TextureCoord2;
  572.       case GL_MAP2_TEXTURE_COORD_3:
  573.      return ctx->Eval.Map2TextureCoord3;
  574.       case GL_MAP2_TEXTURE_COORD_4:
  575.      return ctx->Eval.Map2TextureCoord4;
  576.       case GL_MAP2_VERTEX_3:
  577.      return ctx->Eval.Map2Vertex3;
  578.       case GL_MAP2_VERTEX_4:
  579.      return ctx->Eval.Map2Vertex4;
  580.       case GL_NORMALIZE:
  581.      return ctx->Transform.Normalize;
  582.       case GL_POINT_SMOOTH:
  583.      return ctx->Point.SmoothFlag;
  584.       case GL_POLYGON_SMOOTH:
  585.      return ctx->Polygon.SmoothFlag;
  586.       case GL_POLYGON_STIPPLE:
  587.      return ctx->Polygon.StippleFlag;
  588.       case GL_POLYGON_OFFSET_POINT:
  589.      return ctx->Polygon.OffsetPoint;
  590.       case GL_POLYGON_OFFSET_LINE:
  591.      return ctx->Polygon.OffsetLine;
  592.       case GL_POLYGON_OFFSET_FILL:
  593.       /*case GL_POLYGON_OFFSET_EXT:*/
  594.      return ctx->Polygon.OffsetFill;
  595.       case GL_SCISSOR_TEST:
  596.      return ctx->Scissor.Enabled;
  597.       case GL_SHARED_TEXTURE_PALETTE_EXT:
  598.      return ctx->Texture.SharedPalette;
  599.      break;
  600.       case GL_STENCIL_TEST:
  601.      return ctx->Stencil.Enabled;
  602.       case GL_TEXTURE_1D:
  603.      return (ctx->Texture.Enabled & TEXTURE_1D) ? GL_TRUE : GL_FALSE;
  604.       case GL_TEXTURE_2D:
  605.      return (ctx->Texture.Enabled & TEXTURE_2D) ? GL_TRUE : GL_FALSE;
  606.       case GL_TEXTURE_3D_EXT:
  607.      return (ctx->Texture.Enabled & TEXTURE_3D) ? GL_TRUE : GL_FALSE;
  608.       case GL_TEXTURE_GEN_Q:
  609.      return (ctx->Texture.TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
  610.       case GL_TEXTURE_GEN_R:
  611.      return (ctx->Texture.TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
  612.       case GL_TEXTURE_GEN_S:
  613.      return (ctx->Texture.TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
  614.       case GL_TEXTURE_GEN_T:
  615.      return (ctx->Texture.TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
  616.  
  617.       /*
  618.        * CLIENT STATE!!!
  619.        */
  620.       case GL_VERTEX_ARRAY:
  621.      return ctx->Array.VertexEnabled;
  622.       case GL_NORMAL_ARRAY:
  623.      return ctx->Array.NormalEnabled;
  624.       case GL_COLOR_ARRAY:
  625.      return ctx->Array.ColorEnabled;
  626.       case GL_INDEX_ARRAY:
  627.      return ctx->Array.IndexEnabled;
  628.       case GL_TEXTURE_COORD_ARRAY:
  629.      return ctx->Array.TexCoordEnabled;
  630.       case GL_EDGE_FLAG_ARRAY:
  631.      return ctx->Array.EdgeFlagEnabled;
  632.       default:
  633.      gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
  634.      return GL_FALSE;
  635.    }
  636. }
  637.  
  638.  
  639.  
  640.  
  641. void gl_client_state( GLcontext *ctx, GLenum cap, GLboolean state )
  642. {
  643.    switch (cap) {
  644.       case GL_VERTEX_ARRAY:
  645.      ctx->Array.VertexEnabled = state;
  646.      break;
  647.       case GL_NORMAL_ARRAY:
  648.      ctx->Array.NormalEnabled = state;
  649.      break;
  650.       case GL_COLOR_ARRAY:
  651.      ctx->Array.ColorEnabled = state;
  652.      break;
  653.       case GL_INDEX_ARRAY:
  654.      ctx->Array.IndexEnabled = state;
  655.      break;
  656.       case GL_TEXTURE_COORD_ARRAY:
  657.      ctx->Array.TexCoordEnabled = state;
  658.      break;
  659.       case GL_EDGE_FLAG_ARRAY:
  660.      ctx->Array.EdgeFlagEnabled = state;
  661.      break;
  662.       default:
  663.      gl_error( ctx, GL_INVALID_ENUM, "glEnable/DisableClientState" );
  664.    }
  665. }
  666.  
  667.  
  668.  
  669. void gl_EnableClientState( GLcontext *ctx, GLenum cap )
  670. {
  671.    gl_client_state( ctx, cap, GL_TRUE );
  672. }
  673.  
  674.  
  675.  
  676. void gl_DisableClientState( GLcontext *ctx, GLenum cap )
  677. {
  678.    gl_client_state( ctx, cap, GL_FALSE );
  679. }
  680.  
  681.