use BCOPY macro on FreeBSD
[mesa.git] / src / mesa / main / enable.c
index 29d08283af8260123319993b9f8a63214d458d00..0e1a5781bddfed3a8e3a8ac71455a89769d5f62a 100644 (file)
@@ -1,8 +1,8 @@
-/* $Id: enable.c,v 1.4 1999/09/07 22:31:30 brianp Exp $ */
+/* $Id: enable.c,v 1.12 2000/03/11 23:23:26 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) {
@@ -341,6 +337,7 @@ void gl_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
         if (ctx->Stencil.Enabled!=state) {
             ctx->Stencil.Enabled = state;
             ctx->NewState |= NEW_RASTER_OPS;
+           ctx->TriangleCaps ^= DD_STENCIL;
          }
         break;
       case GL_TEXTURE_1D:
@@ -454,6 +451,18 @@ 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;
+            ctx->NewState |= NEW_RASTER_OPS;
+         }
+         else {
+            gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
+            return;
+         }
+         break;
+
       default:
         if (state) {
            gl_error( ctx, GL_INVALID_ENUM, "glEnable" );
@@ -472,22 +481,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;
@@ -641,6 +656,17 @@ 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;
+         }
+
       default:
         gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
         return GL_FALSE;
@@ -650,7 +676,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 
@@ -685,15 +712,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 );
 }