infrastructure for GL_ARB_multisample
authorBrian Paul <brian.paul@tungstengraphics.com>
Tue, 29 May 2001 15:23:48 +0000 (15:23 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Tue, 29 May 2001 15:23:48 +0000 (15:23 +0000)
src/mesa/glapi/glapi.c
src/mesa/main/attrib.c
src/mesa/main/buffers.c
src/mesa/main/buffers.h
src/mesa/main/context.c
src/mesa/main/dlist.c
src/mesa/main/enable.c
src/mesa/main/extensions.c
src/mesa/main/get.c
src/mesa/main/mtypes.h
src/mesa/main/state.c

index 18c9642c065e8e642623a92a5e44901dc104a5c9..b2a10133b25db60a6d3d45bc95ed12e97f4ac9df 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: glapi.c,v 1.53 2001/03/28 17:39:12 brianp Exp $ */
+/* $Id: glapi.c,v 1.54 2001/05/29 15:23:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -912,7 +912,6 @@ static struct name_address_offset static_functions[] = {
 #else
 #define NAME(X) (GLvoid *) NotImplemented
 #endif
-        { "glSamplePassARB", NAME(glSamplePassARB), _gloffset_SamplePassARB },
         { "glSampleCoverageARB", NAME(glSampleCoverageARB), _gloffset_SampleCoverageARB },
 #undef NAME
 
index 772e304d09bb3c0fa682e0575eee2386945bc2be..145ff9e93888aa5c301050d02eb7ee60adb4daa9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.50 2001/05/03 14:11:18 brianp Exp $ */
+/* $Id: attrib.c,v 1.51 2001/05/29 15:23:48 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -233,6 +233,11 @@ _mesa_PushAttrib(GLbitfield mask)
       attr->RescaleNormals = ctx->Transform.RescaleNormals;
       attr->Scissor = ctx->Scissor.Enabled;
       attr->Stencil = ctx->Stencil.Enabled;
+      attr->MultisampleEnabled = ctx->Multisample.Enabled;
+      attr->SampleAlphaToCoverage = ctx->Multisample.SampleAlphaToCoverage;
+      attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne;
+      attr->SampleCoverage = ctx->Multisample.SampleCoverage;
+      attr->SampleCoverageInvert = ctx->Multisample.SampleCoverageInvert;
       for (i=0; i<MAX_TEXTURE_UNITS; i++) {
          attr->Texture[i] = ctx->Texture.Unit[i].Enabled;
          attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled;
@@ -411,6 +416,17 @@ _mesa_PushAttrib(GLbitfield mask)
       head = newnode;
    }
 
+   /* GL_ARB_multisample */
+   if (mask & GL_MULTISAMPLE_BIT_ARB) {
+      struct gl_multisample_attrib *attr;
+      attr = MALLOC_STRUCT( gl_multisample_attrib );
+      MEMCPY( attr, &ctx->Multisample, sizeof(struct gl_multisample_attrib) );
+      newnode = new_attrib_node( GL_MULTISAMPLE_BIT_ARB );
+      newnode->data = attr;
+      newnode->next = head;
+      head = newnode;
+   }
+
    ctx->AttribStack[ctx->AttribStackDepth] = head;
    ctx->AttribStackDepth++;
 }
@@ -506,6 +522,20 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
                    GL_POLYGON_STIPPLE);
    TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST);
    TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST);
+   TEST_AND_UPDATE(ctx->Multisample.Enabled, enable->MultisampleEnabled,
+                   GL_MULTISAMPLE_ARB);
+   TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage,
+                   enable->SampleAlphaToCoverage,
+                   GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
+   TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToOne,
+                   enable->SampleAlphaToOne,
+                   GL_SAMPLE_ALPHA_TO_ONE_ARB);
+   TEST_AND_UPDATE(ctx->Multisample.SampleCoverage,
+                   enable->SampleCoverage,
+                   GL_SAMPLE_COVERAGE_ARB);
+   TEST_AND_UPDATE(ctx->Multisample.SampleCoverageInvert,
+                   enable->SampleCoverageInvert,
+                   GL_SAMPLE_COVERAGE_INVERT_ARB);
 #undef TEST_AND_UPDATE
 
    /* texture unit enables */
@@ -993,11 +1023,20 @@ _mesa_PopAttrib(void)
          case GL_VIEWPORT_BIT:
             {
                const struct gl_viewport_attrib *vp;
-               vp = (const struct gl_viewport_attrib *)attr->data;
+               vp = (const struct gl_viewport_attrib *) attr->data;
                _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height);
                _mesa_DepthRange(vp->Near, vp->Far);
             }
             break;
+         case GL_MULTISAMPLE_BIT_ARB:
+            {
+               const struct gl_multisample_attrib *ms;
+               ms = (const struct gl_multisample_attrib *) attr->data;
+               _mesa_SampleCoverageARB(ms->SampleCoverageValue,
+                                       ms->SampleCoverageInvert);
+            }
+            break;
+
          default:
             _mesa_problem( ctx, "Bad attrib flag in PopAttrib");
             break;
index c2737ad5f057a2bfd3860014788e9c40e371fb88..82afb401a82b1cae77a9bf0fac57e9147681a7ed 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: buffers.c,v 1.28 2001/03/12 00:48:37 gareth Exp $ */
+/* $Id: buffers.c,v 1.29 2001/05/29 15:23:48 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -370,3 +370,24 @@ _mesa_ResizeBuffersMESA( void )
 
    ctx->Driver.ResizeBuffersMESA( ctx );
 }
+
+
+/*
+ * XXX move somewhere else someday?
+ */
+void
+_mesa_SampleCoverageARB(GLclampf value, GLboolean invert)
+{
+   GLcontext *ctx = _mesa_get_current_context();
+
+   if (!ctx->Extensions.ARB_multisample) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleCoverageARB");
+      return;
+   }
+
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
+   ctx->Multisample.SampleCoverageValue = CLAMP(value, 0.0, 1.0);
+   ctx->Multisample.SampleCoverageInvert = invert;
+   ctx->NewState |= _NEW_MULTISAMPLE;
+}
+                          
index a453c3e1a29d4f99c101a9b7f31a7d584f87b8b9..ca0cdafd05e7375c56025d6ea295c744e8318961 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: buffers.h,v 1.3 2001/03/12 00:48:37 gareth Exp $ */
+/* $Id: buffers.h,v 1.4 2001/05/29 15:23:48 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -51,5 +51,8 @@ _mesa_ReadBuffer( GLenum mode );
 extern void
 _mesa_ResizeBuffersMESA( void );
 
+extern void
+_mesa_SampleCoverageARB(GLclampf value, GLboolean invert);
+
 
 #endif
index d7cdf10b00a49c6126eaf692d2992aed7bdd5b80..4ff1941f1301a89618aaeccc91cef4852b3a3e78 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.138 2001/05/21 16:41:03 brianp Exp $ */
+/* $Id: context.c,v 1.139 2001/05/29 15:23:48 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -988,6 +988,14 @@ init_attrib_groups( GLcontext *ctx )
    /* Display List group */
    ctx->List.ListBase = 0;
 
+   /* Multisample */
+   ctx->Multisample.Enabled = GL_FALSE;
+   ctx->Multisample.SampleAlphaToCoverage = GL_FALSE;
+   ctx->Multisample.SampleAlphaToOne = GL_FALSE;
+   ctx->Multisample.SampleCoverage = GL_FALSE;
+   ctx->Multisample.SampleCoverageValue = 1.0;
+   ctx->Multisample.SampleCoverageInvert = GL_FALSE;
+
    /* Pixel group */
    ctx->Pixel.RedBias = 0.0;
    ctx->Pixel.RedScale = 1.0;
index 3ac0667afad0fbf6eb7723c35513136114047931..c889b67f8bc5b992f9852889de11b4f8a8080412 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: dlist.c,v 1.71 2001/05/14 08:57:36 keithw Exp $ */
+/* $Id: dlist.c,v 1.72 2001/05/29 15:23:48 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -246,6 +246,8 @@ typedef enum {
         OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D,
         OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D,
         OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
+        /* GL_ARB_multisample */
+        OPCODE_SAMPLE_COVERAGE,
        /* The following three are meta instructions */
        OPCODE_ERROR,           /* raise compiled-in error */
        OPCODE_CONTINUE,
@@ -627,6 +629,8 @@ void _mesa_init_lists( void )
       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D] = 8;
       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D] = 10;
       InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D] = 12;
+      /* GL_ARB_multisample */
+      InstSize[OPCODE_SAMPLE_COVERAGE] = 3;
       /* GL_ARB_multitexture */
       InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
       InstSize[OPCODE_CLIENT_ACTIVE_TEXTURE] = 2;
@@ -3887,6 +3891,24 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
 }
 
 
+/* GL_ARB_multisample */
+static void
+save_SampleCoverageARB(GLclampf value, GLboolean invert)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = ALLOC_INSTRUCTION( ctx, OPCODE_SAMPLE_COVERAGE, 2 );
+   if (n) {
+      n[1].f = value;
+      n[2].b = invert;
+   }
+   if (ctx->ExecuteFlag) {
+      (*ctx->Exec->SampleCoverageARB)( value, invert );
+   }
+}
+
+
 /* GL_SGIS_pixel_texture */
 
 static void
@@ -4608,6 +4630,9 @@ execute_list( GLcontext *ctx, GLuint list )
                                         n[4].i, n[5].i, n[6].i, n[7].i, n[8].i,
                                         n[9].e, n[10].i, n[11].data);
             break;
+         case OPCODE_SAMPLE_COVERAGE: /* GL_ARB_multisample */
+            (*ctx->Exec->SampleCoverageARB)(n[1].f, n[2].b);
+            break;
         case OPCODE_CONTINUE:
            n = (Node *) n[1].next;
            break;
@@ -5870,6 +5895,9 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
    table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB;
    table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB;
 
+   /* GL_ARB_multisample */
+   table->SampleCoverageARB = save_SampleCoverageARB;
+
    /* ARB 12. GL_ARB_texture_compression */
    table->CompressedTexImage3DARB = save_CompressedTexImage3DARB;
    table->CompressedTexImage2DARB = save_CompressedTexImage2DARB;
index 173b4b0f227ed2b57cf440dea4558b88c1a02337..4516f48f84019c59e12e6c3921a19ea49cd75534 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.48 2001/03/29 21:16:25 keithw Exp $ */
+/* $Id: enable.c,v 1.49 2001/05/29 15:23:48 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -733,6 +733,63 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
 
       break;
 
+      /* GL_ARB_multisample */
+   case GL_MULTISAMPLE_ARB:
+      if (!ctx->Extensions.ARB_multisample) {
+         _mesa_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
+         return;
+      }
+      if (ctx->Multisample.Enabled == state)
+         return;
+      FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+      ctx->Multisample.Enabled = state;
+      ctx->NewState |= _NEW_MULTISAMPLE;
+      break;
+   case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
+      if (!ctx->Extensions.ARB_multisample) {
+         _mesa_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
+         return;
+      }
+      if (ctx->Multisample.SampleAlphaToCoverage == state)
+         return;
+      FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+      ctx->Multisample.SampleAlphaToCoverage = state;
+      ctx->NewState |= _NEW_MULTISAMPLE;
+      break;
+   case GL_SAMPLE_ALPHA_TO_ONE_ARB:
+      if (!ctx->Extensions.ARB_multisample) {
+         _mesa_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
+         return;
+      }
+      if (ctx->Multisample.SampleAlphaToOne == state)
+         return;
+      FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+      ctx->Multisample.SampleAlphaToOne = state;
+      ctx->NewState |= _NEW_MULTISAMPLE;
+      break;
+   case GL_SAMPLE_COVERAGE_ARB:
+      if (!ctx->Extensions.ARB_multisample) {
+         _mesa_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
+         return;
+      }
+      if (ctx->Multisample.SampleCoverage == state)
+         return;
+      FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+      ctx->Multisample.SampleCoverage = state;
+      ctx->NewState |= _NEW_MULTISAMPLE;
+      break;
+   case GL_SAMPLE_COVERAGE_INVERT_ARB:
+      if (!ctx->Extensions.ARB_multisample) {
+         _mesa_error(ctx, GL_INVALID_ENUM, state ? "glEnable" : "glDisable");
+         return;
+      }
+      if (ctx->Multisample.SampleCoverageInvert == state)
+         return;
+      FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+      ctx->Multisample.SampleCoverageInvert = state;
+      ctx->NewState |= _NEW_MULTISAMPLE;
+      break;
+
       /* GL_MESA_sprite_point */
    case GL_SPRITE_POINT_MESA:
       if (!ctx->Extensions.MESA_sprite_point) {
@@ -993,6 +1050,48 @@ _mesa_IsEnabled( GLenum cap )
             return GL_FALSE;
          }
 
+      /* GL_ARB_multisample */
+      case GL_MULTISAMPLE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            return ctx->Multisample.Enabled;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
+            return GL_FALSE;
+         }
+      case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            return ctx->Multisample.SampleAlphaToCoverage;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
+            return GL_FALSE;
+         }
+      case GL_SAMPLE_ALPHA_TO_ONE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            return ctx->Multisample.SampleAlphaToOne;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
+            return GL_FALSE;
+         }
+      case GL_SAMPLE_COVERAGE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            return ctx->Multisample.SampleCoverage;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
+            return GL_FALSE;
+         }
+      case GL_SAMPLE_COVERAGE_INVERT_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            return ctx->Multisample.SampleCoverageInvert;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled");
+            return GL_FALSE;
+         }
+
       /* GL_MESA_sprite_point */
       case GL_SPRITE_POINT_MESA:
          return ctx->Point.SpriteMode;
index 1d14a82288d54e359720b47414bb797531897e7b..fc26efbb62f370693def33f051dd912bfc9d6782 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: extensions.c,v 1.60 2001/05/24 14:47:56 brianp Exp $ */
+/* $Id: extensions.c,v 1.61 2001/05/29 15:23:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -57,6 +57,7 @@ static struct {
    int flag_offset;
 } default_extensions[] = {
    { OFF, "GL_ARB_imaging",                    F(ARB_imaging) },
+   { OFF, "GL_ARB_multisample",                F(ARB_multisample) },
    { OFF, "GL_ARB_multitexture",               F(ARB_multitexture) },
    { OFF, "GL_ARB_texture_border_clamp",       F(ARB_texture_border_clamp) },
    { OFF, "GL_ARB_texture_compression",        F(ARB_texture_compression) },
index b16343831db270b2890acea6163156612ad18c26..cdd86ebf087295fa332d75b2ce971464390345a7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.60 2001/05/21 16:41:03 brianp Exp $ */
+/* $Id: get.c,v 1.61 2001/05/29 15:23:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -1269,6 +1269,72 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
          }
         break;
 
+      /* GL_ARB_multisample */
+      case GL_MULTISAMPLE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = ctx->Multisample.Enabled;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+            return;
+         }
+      case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = ctx->Multisample.SampleAlphaToCoverage;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+            return;
+         }
+      case GL_SAMPLE_ALPHA_TO_ONE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = ctx->Multisample.SampleAlphaToOne;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = ctx->Multisample.SampleCoverage;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_VALUE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = FLOAT_TO_BOOL(ctx->Multisample.SampleCoverageValue);
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_INVERT_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = ctx->Multisample.SampleCoverageInvert;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+            return;
+         }
+      case GL_SAMPLE_BUFFERS_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = 0; /* XXX fix someday */
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+            return;
+         }
+      case GL_SAMPLES_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = 0; /* XXX fix someday */
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv");
+            return;
+         }
+
       /* GL_MESA_sprite_point */
       case GL_SPRITE_POINT_MESA:
          if (ctx->Extensions.MESA_sprite_point) {
@@ -2484,6 +2550,72 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
          }
         break;
 
+      /* GL_ARB_multisample */
+      case GL_MULTISAMPLE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLdouble) ctx->Multisample.Enabled;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
+            return;
+         }
+      case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLdouble) ctx->Multisample.SampleAlphaToCoverage;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
+            return;
+         }
+      case GL_SAMPLE_ALPHA_TO_ONE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLdouble) ctx->Multisample.SampleAlphaToOne;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLdouble) ctx->Multisample.SampleCoverage;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_VALUE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = ctx->Multisample.SampleCoverageValue;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_INVERT_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLdouble) ctx->Multisample.SampleCoverageInvert;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
+            return;
+         }
+      case GL_SAMPLE_BUFFERS_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = 0.0; /* XXX fix someday */
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
+            return;
+         }
+      case GL_SAMPLES_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = 0.0; /* XXX fix someday */
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetDoublev");
+            return;
+         }
+
       /* GL_MESA_sprite_point */
       case GL_SPRITE_POINT_MESA:
          if (ctx->Extensions.MESA_sprite_point) {
@@ -3673,6 +3805,72 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
          }
         break;
 
+      /* GL_ARB_multisample */
+      case GL_MULTISAMPLE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLfloat) ctx->Multisample.Enabled;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
+            return;
+         }
+      case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLfloat) ctx->Multisample.SampleAlphaToCoverage;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
+            return;
+         }
+      case GL_SAMPLE_ALPHA_TO_ONE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLfloat) ctx->Multisample.SampleAlphaToOne;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLfloat) ctx->Multisample.SampleCoverage;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_VALUE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = ctx->Multisample.SampleCoverageValue;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_INVERT_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLfloat) ctx->Multisample.SampleCoverageInvert;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
+            return;
+         }
+      case GL_SAMPLE_BUFFERS_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = 0.0; /* XXX fix someday */
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
+            return;
+         }
+      case GL_SAMPLES_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = 0.0; /* XXX fix someday */
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv");
+            return;
+         }
+
       /* GL_MESA_sprite_point */
       case GL_SPRITE_POINT_MESA:
          if (ctx->Extensions.MESA_sprite_point) {
@@ -4911,6 +5109,72 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
          }
         break;
 
+      /* GL_ARB_multisample */
+      case GL_MULTISAMPLE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLint) ctx->Multisample.Enabled;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
+            return;
+         }
+      case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLint) ctx->Multisample.SampleAlphaToCoverage;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
+            return;
+         }
+      case GL_SAMPLE_ALPHA_TO_ONE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLint) ctx->Multisample.SampleAlphaToOne;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLint) ctx->Multisample.SampleCoverage;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_VALUE_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLint) ctx->Multisample.SampleCoverageValue;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
+            return;
+         }
+      case GL_SAMPLE_COVERAGE_INVERT_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = (GLint) ctx->Multisample.SampleCoverageInvert;
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
+            return;
+         }
+      case GL_SAMPLE_BUFFERS_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = 0; /* XXX fix someday */
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
+            return;
+         }
+      case GL_SAMPLES_ARB:
+         if (ctx->Extensions.ARB_multisample) {
+            *params = 0; /* XXX fix someday */
+         }
+         else {
+            _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv");
+            return;
+         }
+
       /* GL_MESA_sprite_point */
       case GL_SPRITE_POINT_MESA:
          if (ctx->Extensions.MESA_sprite_point) {
index b8c2ec7af6e1f178321506ef706051c24e7f7ee3..d82d806cc8f290299a59e9eccf0e07288d680df8 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mtypes.h,v 1.42 2001/05/21 16:41:03 brianp Exp $ */
+/* $Id: mtypes.h,v 1.43 2001/05/29 15:23:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -375,6 +375,11 @@ struct gl_enable_attrib {
    GLboolean RescaleNormals;
    GLboolean Scissor;
    GLboolean Stencil;
+   GLboolean MultisampleEnabled;     /* GL_ARB_multisample */
+   GLboolean SampleAlphaToCoverage;  /* GL_ARB_multisample */
+   GLboolean SampleAlphaToOne;       /* GL_ARB_multisample */
+   GLboolean SampleCoverage;         /* GL_ARB_multisample */
+   GLboolean SampleCoverageInvert;   /* GL_ARB_multisample */
    GLuint Texture[MAX_TEXTURE_UNITS];
    GLuint TexGen[MAX_TEXTURE_UNITS];
 };
@@ -524,6 +529,17 @@ struct gl_list_extensions {
    GLuint nr_opcodes;
 };
 
+
+struct gl_multisample_attrib {
+   GLboolean Enabled;
+   GLboolean SampleAlphaToCoverage;
+   GLboolean SampleAlphaToOne;
+   GLboolean SampleCoverage;
+   GLfloat SampleCoverageValue;
+   GLboolean SampleCoverageInvert;
+};
+
+
 struct gl_pixel_attrib {
    GLenum ReadBuffer;          /* src buffer for glRead/CopyPixels */
    GLenum DriverReadBuffer;    /* Driver's current source buffer */
@@ -1175,6 +1191,7 @@ struct gl_extensions {
     * Not every extension needs to have such a flag, but it's encouraged.
     */
    GLboolean ARB_imaging;
+   GLboolean ARB_multisample;
    GLboolean ARB_multitexture;
    GLboolean ARB_texture_border_clamp;
    GLboolean ARB_texture_compression;
@@ -1273,21 +1290,21 @@ struct gl_extensions {
 #define _NEW_FOG               0x100      /* ctx->Fog */
 #define _NEW_HINT              0x200      /* ctx->Hint */
 #define _NEW_LIGHT             0x400      /* ctx->Light */
-#define _NEW_LINE              0x800     /* ctx->Line */
+#define _NEW_LINE              0x800      /* ctx->Line */
 #define _NEW_PIXEL             0x1000     /* ctx->Pixel */
-#define _NEW_POINT             0x2000    /* ctx->Point */
-#define _NEW_POLYGON           0x4000    /* ctx->Polygon */
-#define _NEW_POLYGONSTIPPLE    0x8000    /* ctx->PolygonStipple */
+#define _NEW_POINT             0x2000     /* ctx->Point */
+#define _NEW_POLYGON           0x4000     /* ctx->Polygon */
+#define _NEW_POLYGONSTIPPLE    0x8000     /* ctx->PolygonStipple */
 #define _NEW_SCISSOR           0x10000    /* ctx->Scissor */
-#define _NEW_STENCIL           0x20000   /* ctx->Stencil */
-#define _NEW_TEXTURE           0x40000   /* ctx->Texture */
-#define _NEW_TRANSFORM         0x80000   /* ctx->Transform */
+#define _NEW_STENCIL           0x20000    /* ctx->Stencil */
+#define _NEW_TEXTURE           0x40000    /* ctx->Texture */
+#define _NEW_TRANSFORM         0x80000    /* ctx->Transform */
 #define _NEW_VIEWPORT          0x100000   /* ctx->Viewport */
-#define _NEW_PACKUNPACK                0x200000  /* ctx->Pack, ctx->Unpack */
-#define _NEW_ARRAY             0x400000  /* ctx->Array */
-#define _NEW_RENDERMODE                0x800000  /* RenderMode, Feedback, Select */
-#define _NEW_BUFFERS            0x1000000 /* ctx->Visual, ctx->DrawBuffer, */
-
+#define _NEW_PACKUNPACK                0x200000   /* ctx->Pack, ctx->Unpack */
+#define _NEW_ARRAY             0x400000   /* ctx->Array */
+#define _NEW_RENDERMODE                0x800000   /* RenderMode, Feedback, Select */
+#define _NEW_BUFFERS            0x1000000  /* ctx->Visual, ctx->DrawBuffer, */
+#define _NEW_MULTISAMPLE        0x2000000  /* ctx->Multisample */
 #define _NEW_ALL ~0
 
 
@@ -1482,6 +1499,7 @@ struct __GLcontextRec {
    struct gl_light_attrib      Light;
    struct gl_line_attrib       Line;
    struct gl_list_attrib       List;
+   struct gl_multisample_attrib Multisample;
    struct gl_pixel_attrib      Pixel;
    struct gl_point_attrib      Point;
    struct gl_polygon_attrib    Polygon;
index e699ac075284cddfcc4be74702acd495f605dc71..6b7682144dd332bcd0a3f9bd2e2191938fc50941 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: state.c,v 1.65 2001/05/10 15:42:43 keithw Exp $ */
+/* $Id: state.c,v 1.66 2001/05/29 15:23:49 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -475,6 +475,9 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
    exec->MultTransposeMatrixdARB = _mesa_MultTransposeMatrixdARB;
    exec->MultTransposeMatrixfARB = _mesa_MultTransposeMatrixfARB;
 
+   /* ARB 5. GL_ARB_multisample */
+   exec->SampleCoverageARB = _mesa_SampleCoverageARB;
+
    /* ARB 12. GL_ARB_texture_compression */
    exec->CompressedTexImage3DARB = _mesa_CompressedTexImage3DARB;
    exec->CompressedTexImage2DARB = _mesa_CompressedTexImage2DARB;