Add GLAPIENTRY function decorations for correct operation on Windows.
[mesa.git] / src / mesa / main / enable.c
index 747c3f63c1b92e0564276beb8b712bb00968953e..64cc4d17ca7538dbe5a1d78acf1b2e6da838a65a 100644 (file)
@@ -1,3 +1,8 @@
+/**
+ * \file enable.c
+ * Enable/disable/query GL capabilities.
+ */
+
 /*
  * Mesa 3-D graphics library
  * Version:  5.1
       return;                                                          \
    }
 
+#define CHECK_EXTENSION2(EXT1, EXT2, CAP)                              \
+   if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) {               \
+      _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)",       \
+                  state ? "Enable" : "Disable", CAP);                  \
+      return;                                                          \
+   }
 
 
 static void
@@ -135,8 +146,17 @@ client_state( GLcontext *ctx, GLenum cap, GLboolean state )
 }
 
 
-
-void
+/**
+ * Enable GL capability.
+ *
+ * \param cap capability.
+ *
+ * \sa glEnable().
+ *
+ * Get's the current context, assures that we're outside glBegin()/glEnd() and
+ * calls client_state().
+ */
+void GLAPIENTRY
 _mesa_EnableClientState( GLenum cap )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -145,8 +165,17 @@ _mesa_EnableClientState( GLenum cap )
 }
 
 
-
-void
+/**
+ * Disable GL capability.
+ *
+ * \param cap capability.
+ *
+ * \sa glDisable().
+ *
+ * Get's the current context, assures that we're outside glBegin()/glEnd() and
+ * calls client_state().
+ */
+void GLAPIENTRY
 _mesa_DisableClientState( GLenum cap )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -164,8 +193,17 @@ _mesa_DisableClientState( GLenum cap )
    }
 
 
-/*
- * Perform glEnable and glDisable calls.
+/**
+ * Perform glEnable() and glDisable() calls.
+ *
+ * \param ctx GL context.
+ * \param cap capability.
+ * \param state whether to enable or disable the specified capability.
+ *
+ * Updates the current context and flushes the vertices as needed. For
+ * capabilities associated with extensions it verifies that those extensions
+ * are effectivly present before updating. Notifies the driver via
+ * dd_function_table::Enable.
  */
 void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
 {
@@ -193,10 +231,14 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
             return;
          FLUSH_VERTICES(ctx, _NEW_COLOR);
          ctx->Color.BlendEnabled = state;
-         /* The following needed to accomodate 1.0 RGB logic op blending */
-         ctx->Color.ColorLogicOpEnabled =
-            (ctx->Color.BlendEquation == GL_LOGIC_OP && state);
-         break;
+         /* This is needed to support 1.1's RGB logic ops AND
+          * 1.0's blending logicops.
+          */
+         ctx->Color._LogicOpEnabled =
+            (ctx->Color.ColorLogicOpEnabled ||
+             (state && ctx->Color.BlendEquationRGB == GL_LOGIC_OP));
+         break;
+#if FEATURE_userclip
       case GL_CLIP_PLANE0:
       case GL_CLIP_PLANE1:
       case GL_CLIP_PLANE2:
@@ -230,6 +272,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
             }               
          }
          break;
+#endif
       case GL_COLOR_MATERIAL:
          if (ctx->Light.ColorMaterialEnabled == state)
             return;
@@ -310,13 +353,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          else
           ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
  
-         if ((ctx->Light.Enabled &&
-              ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
-             || ctx->Fog.ColorSumEnabled)
-            ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
-         else
-            ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
-
          break;
       case GL_LINE_SMOOTH:
          if (ctx->Line.SmoothFlag == state)
@@ -343,6 +379,12 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
             return;
          FLUSH_VERTICES(ctx, _NEW_COLOR);
          ctx->Color.ColorLogicOpEnabled = state;
+         /* This is needed to support 1.1's RGB logic ops AND
+          * 1.0's blending logicops.
+          */
+         ctx->Color._LogicOpEnabled =
+            (state || (ctx->Color.BlendEnabled &&
+                       ctx->Color.BlendEquationRGB == GL_LOGIC_OP));
          break;
       case GL_MAP1_COLOR_4:
          if (ctx->Eval.Map1Color4 == state)
@@ -742,14 +784,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
             return;
          FLUSH_VERTICES(ctx, _NEW_FOG);
          ctx->Fog.ColorSumEnabled = state;
-
-         if ((ctx->Light.Enabled &&
-              ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
-             || ctx->Fog.ColorSumEnabled)
-            ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
-         else
-            ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
-
          break;
 
       /* GL_ARB_multisample */
@@ -800,7 +834,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
 
       /* GL_NV_point_sprite */
       case GL_POINT_SPRITE_NV:
-         CHECK_EXTENSION(NV_point_sprite, cap);
+         CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap);
          if (ctx->Point.PointSprite == state)
             return;
          FLUSH_VERTICES(ctx, _NEW_POINT);
@@ -812,21 +846,21 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          CHECK_EXTENSION(NV_vertex_program, cap);
          if (ctx->VertexProgram.Enabled == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_TRANSFORM | _NEW_PROGRAM);  /* XXX OK? */
+         FLUSH_VERTICES(ctx, _NEW_PROGRAM); 
          ctx->VertexProgram.Enabled = state;
          break;
       case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
          CHECK_EXTENSION(NV_vertex_program, cap);
          if (ctx->VertexProgram.PointSizeEnabled == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_POINT | _NEW_PROGRAM);
+         FLUSH_VERTICES(ctx, _NEW_PROGRAM);
          ctx->VertexProgram.PointSizeEnabled = state;
          break;
       case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
          CHECK_EXTENSION(NV_vertex_program, cap);
          if (ctx->VertexProgram.TwoSideEnabled == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_PROGRAM);  /* XXX OK? */
+         FLUSH_VERTICES(ctx, _NEW_PROGRAM); 
          ctx->VertexProgram.TwoSideEnabled = state;
          break;
       case GL_MAP1_VERTEX_ATTRIB0_4_NV:
@@ -882,7 +916,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          CHECK_EXTENSION(NV_fragment_program, cap);
          if (ctx->FragmentProgram.Enabled == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_TEXTURE);
+         FLUSH_VERTICES(ctx, _NEW_PROGRAM);
          ctx->FragmentProgram.Enabled = state;
          break;
 #endif /* FEATURE_NV_fragment_program */
@@ -918,7 +952,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          CHECK_EXTENSION(ARB_fragment_program, cap);
          if (ctx->FragmentProgram.Enabled == state)
             return;
-         FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_TEXTURE);
+         FLUSH_VERTICES(ctx, _NEW_PROGRAM);
          ctx->FragmentProgram.Enabled = state;
          break;
 #endif /* FEATURE_ARB_fragment_program */
@@ -937,6 +971,16 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
          ctx->Depth.BoundsTest = state;
          break;
 
+      /* GL_MESA_program_debug */
+      case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
+         CHECK_EXTENSION(MESA_program_debug, cap);
+         ctx->FragmentProgram.CallbackEnabled = state;
+         break;
+      case GL_VERTEX_PROGRAM_CALLBACK_MESA:
+         CHECK_EXTENSION(MESA_program_debug, cap);
+         ctx->VertexProgram.CallbackEnabled = state;
+         break;
+
       default:
          _mesa_error(ctx, GL_INVALID_ENUM,
                      "%s(0x%x)", state ? "glEnable" : "glDisable", cap);
@@ -949,7 +993,17 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
 }
 
 
-void
+/**
+ * Enable GL capability.
+ *
+ * \param cap capability.
+ *
+ * \sa glEnable().
+ *
+ * Get's the current context, assures that we're outside glBegin()/glEnd() and
+ * calls _mesa_set_enable().
+ */
+void GLAPIENTRY
 _mesa_Enable( GLenum cap )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -959,7 +1013,17 @@ _mesa_Enable( GLenum cap )
 }
 
 
-void
+/**
+ * Disable GL capability.
+ *
+ * \param cap capability.
+ *
+ * \sa glDisable().
+ *
+ * Get's the current context, assures that we're outside glBegin()/glEnd() and
+ * calls _mesa_set_enable().
+ */
+void GLAPIENTRY
 _mesa_Disable( GLenum cap )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -977,7 +1041,16 @@ _mesa_Disable( GLenum cap )
    }
 
 
-GLboolean
+/**
+ * Test whether a capability is enabled.
+ *
+ * \param cap capability.
+ *
+ * Returns the state of the specified capability from the current GL context.
+ * For the capabilities associated with extensions verifies that those
+ * extensions are effectively present before reporting.
+ */
+GLboolean GLAPIENTRY
 _mesa_IsEnabled( GLenum cap )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -1338,6 +1411,14 @@ _mesa_IsEnabled( GLenum cap )
          CHECK_EXTENSION(EXT_depth_bounds_test);
          return ctx->Depth.BoundsTest;
 
+      /* GL_MESA_program_debug */
+      case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
+         CHECK_EXTENSION(MESA_program_debug);
+         return ctx->FragmentProgram.CallbackEnabled;
+      case GL_VERTEX_PROGRAM_CALLBACK_MESA:
+         CHECK_EXTENSION(MESA_program_debug);
+         return ctx->VertexProgram.CallbackEnabled;
+
       default:
          _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap);
         return GL_FALSE;