work on GL_SGI_color_table
[mesa.git] / src / mesa / main / enable.c
index ac916d6a41b0ef7de73763a4f6ad6eb6722357e6..8c71d87cd0fb37699b85f964275aab63ce5ce364 100644 (file)
@@ -1,8 +1,8 @@
-/* $Id: enable.c,v 1.5 1999/09/18 20:41:23 keithw Exp $ */
+/* $Id: enable.c,v 1.15 2000/04/12 00:27:37 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.1
+ * Version:  3.3
  * 
  * Copyright (C) 1999  Brian Paul   All Rights Reserved.
  * 
@@ -28,8 +28,7 @@
 #ifdef PC_HEADER
 #include "all.h"
 #else
-#include <string.h>
-#include <stdio.h>
+#include "glheader.h"
 #include "context.h"
 #include "enable.h"
 #include "light.h"
@@ -41,9 +40,6 @@
 #include "vbfill.h"
 #include "xform.h"
 #include "enums.h"
-#ifdef XFree86Server
-#include "GL/xf86glx.h"
-#endif
 #endif
 
 
@@ -51,7 +47,7 @@
 /*
  * Perform glEnable and glDisable calls.
  */
-void gl_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
+void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
 {
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "gl_enable/disable" );
 
@@ -120,6 +116,8 @@ void gl_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          if (ctx->Light.ColorMaterialEnabled!=state) {
             ctx->Light.ColorMaterialEnabled = state;
            ctx->NewState |= NEW_LIGHTING;
+            if (state)
+               gl_update_color_material( ctx, ctx->Current.ByteColor );
          }
         break;
       case GL_CULL_FACE:
@@ -186,7 +184,7 @@ void gl_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          if (ctx->Light.Enabled!=state) {
             ctx->Light.Enabled = state;
            ctx->Enabled &= ~ENABLE_LIGHT;
-           if (state && !is_empty_list(&ctx->Light.EnabledList))
+            if (state)
               ctx->Enabled |= ENABLE_LIGHT;
             ctx->NewState |= NEW_LIGHTING;
          }
@@ -330,8 +328,6 @@ void gl_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
         break;
       case GL_SHARED_TEXTURE_PALETTE_EXT:
          ctx->Texture.SharedPalette = state;
-         if (ctx->Driver.UseGlobalTexturePalette)
-            (*ctx->Driver.UseGlobalTexturePalette)( ctx, state );
          break;
       case GL_STENCIL_TEST:
         if (state && ctx->Visual->StencilBits==0) {
@@ -455,6 +451,43 @@ void gl_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          ctx->Array.EdgeFlag.Enabled = state;
          break;
 
+      /* GL_HP_occlusion_test */
+      case GL_OCCLUSION_TEST_HP:
+         if (ctx->Extensions.HaveHpOcclusionTest) {
+            ctx->Depth.OcclusionTest = state;
+            if (state)
+               ctx->OcclusionResult = ctx->OcclusionResultSaved;
+            else
+               ctx->OcclusionResultSaved = ctx->OcclusionResult;
+            ctx->NewState |= NEW_RASTER_OPS;
+         }
+         else {
+            gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
+            return;
+         }
+         break;
+
+      /* GL_SGIS_pixel_texture */
+      case GL_PIXEL_TEXTURE_SGIS:
+         ctx->Pixel.PixelTextureEnabled = state;
+         break;
+
+      /* GL_SGIX_pixel_texture */
+      case GL_PIXEL_TEX_GEN_SGIX:
+         ctx->Pixel.PixelTextureEnabled = state;
+         break;
+
+      /* GL_SGI_color_table */
+      case GL_COLOR_TABLE_SGI:
+         ctx->Pixel.ColorTableEnabled = state;
+         break;
+      case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
+         ctx->Pixel.PostConvolutionColorTableEnabled = state;
+         break;
+      case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
+         ctx->Pixel.PostColorMatrixColorTableEnabled = state;
+         break;
+
       default:
         if (state) {
            gl_error( ctx, GL_INVALID_ENUM, "glEnable" );
@@ -473,22 +506,28 @@ void gl_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
 
 
 
-void gl_Enable( GLcontext* ctx, GLenum cap )
+void
+_mesa_Enable( GLenum cap )
 {
-   gl_set_enable( ctx, cap, GL_TRUE );
+   GET_CURRENT_CONTEXT(ctx);
+   _mesa_set_enable( ctx, cap, GL_TRUE );
 }
 
 
 
-void gl_Disable( GLcontext* ctx, GLenum cap )
+void
+_mesa_Disable( GLenum cap )
 {
-   gl_set_enable( ctx, cap, GL_FALSE );
+   GET_CURRENT_CONTEXT(ctx);
+   _mesa_set_enable( ctx, cap, GL_FALSE );
 }
 
 
 
-GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap )
+GLboolean
+_mesa_IsEnabled( GLenum cap )
 {
+   GET_CURRENT_CONTEXT(ctx);
    switch (cap) {
       case GL_ALPHA_TEST:
          return ctx->Color.AlphaEnabled;
@@ -642,6 +681,33 @@ GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap )
          return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
       case GL_EDGE_FLAG_ARRAY:
          return ctx->Array.EdgeFlag.Enabled;
+
+      /* GL_HP_occlusion_test */
+      case GL_OCCLUSION_TEST_HP:
+         if (ctx->Extensions.HaveHpOcclusionTest) {
+            return ctx->Depth.OcclusionTest;
+         }
+         else {
+            gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
+            return GL_FALSE;
+         }
+
+      /* GL_SGIS_pixel_texture */
+      case GL_PIXEL_TEXTURE_SGIS:
+         return ctx->Pixel.PixelTextureEnabled;
+
+      /* GL_SGIX_pixel_texture */
+      case GL_PIXEL_TEX_GEN_SGIX:
+         return ctx->Pixel.PixelTextureEnabled;
+
+      /* GL_SGI_color_table */
+      case GL_COLOR_TABLE_SGI:
+         return ctx->Pixel.ColorTableEnabled;
+      case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
+         return ctx->Pixel.PostConvolutionColorTableEnabled;
+      case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
+         return ctx->Pixel.PostColorMatrixColorTableEnabled;
+
       default:
         gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
         return GL_FALSE;
@@ -651,7 +717,8 @@ GLboolean gl_IsEnabled( GLcontext* ctx, GLenum cap )
 
 
 
-static void gl_client_state( GLcontext *ctx, GLenum cap, GLboolean state )
+static void
+client_state( GLcontext *ctx, GLenum cap, GLboolean state )
 {
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, 
                                       (state 
@@ -686,15 +753,19 @@ static void gl_client_state( GLcontext *ctx, GLenum cap, GLboolean state )
 
 
 
-void gl_EnableClientState( GLcontext *ctx, GLenum cap )
+void
+_mesa_EnableClientState( GLenum cap )
 {
-   gl_client_state( ctx, cap, GL_TRUE );
+   GET_CURRENT_CONTEXT(ctx);
+   client_state( ctx, cap, GL_TRUE );
 }
 
 
 
-void gl_DisableClientState( GLcontext *ctx, GLenum cap )
+void
+_mesa_DisableClientState( GLenum cap )
 {
-   gl_client_state( ctx, cap, GL_FALSE );
+   GET_CURRENT_CONTEXT(ctx);
+   client_state( ctx, cap, GL_FALSE );
 }