mesa: API and state for GL 3.1 primitive restart
authorBrian Paul <brianp@vmware.com>
Wed, 21 Apr 2010 03:02:09 +0000 (21:02 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 21 Apr 2010 03:02:09 +0000 (21:02 -0600)
src/mesa/main/enable.c
src/mesa/main/get.c
src/mesa/main/get_gen.py
src/mesa/main/mtypes.h
src/mesa/main/varray.c
src/mesa/main/varray.h

index d24564c353774326612bcc475e30a1d2e88a3b40..72787226dc4f5d9ebc3bed30cf9ba617e0ffe0eb 100644 (file)
@@ -990,6 +990,17 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
          break;
 #endif
 
+      /* GL 3.1 primitive restart */
+      case GL_PRIMITIVE_RESTART:
+        if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) {
+            goto invalid_enum_error;
+         }
+         if (ctx->Array.PrimitiveRestart != state) {
+            FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+            ctx->Array.PrimitiveRestart = state;
+         }
+         break;
+
       default:
          goto invalid_enum_error;
    }
@@ -1509,6 +1520,13 @@ _mesa_IsEnabled( GLenum cap )
          return ctx->TransformFeedback.RasterDiscard;
 #endif
 
+      /* GL 3.1 primitive restart */
+      case GL_PRIMITIVE_RESTART:
+        if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) {
+            goto invalid_enum_error;
+         }
+         return ctx->Array.PrimitiveRestart;
+
       default:
          goto invalid_enum_error;
    }
index cb12737bd7aae4a4055cf5d48e33f89cb821ca72..f89a798f1b6fe4eb886260f8de32b5ad04975ea1 100644 (file)
@@ -1954,6 +1954,12 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
       case GL_CONTEXT_FLAGS:
          params[0] = INT_TO_BOOLEAN(ctx->Const.ContextFlags);
          break;
+      case GL_PRIMITIVE_RESTART:
+         params[0] = ctx->Array.PrimitiveRestart;
+         break;
+      case GL_PRIMITIVE_RESTART_INDEX:
+         params[0] = INT_TO_BOOLEAN(ctx->Array.RestartIndex);
+         break;
       case GL_CONTEXT_PROFILE_MASK:
          params[0] = INT_TO_BOOLEAN(ctx->Const.ProfileMask);
          break;
@@ -3856,6 +3862,12 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
       case GL_CONTEXT_FLAGS:
          params[0] = (GLfloat)(ctx->Const.ContextFlags);
          break;
+      case GL_PRIMITIVE_RESTART:
+         params[0] = BOOLEAN_TO_FLOAT(ctx->Array.PrimitiveRestart);
+         break;
+      case GL_PRIMITIVE_RESTART_INDEX:
+         params[0] = (GLfloat)(ctx->Array.RestartIndex);
+         break;
       case GL_CONTEXT_PROFILE_MASK:
          params[0] = (GLfloat)(ctx->Const.ProfileMask);
          break;
@@ -5758,6 +5770,12 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
       case GL_CONTEXT_FLAGS:
          params[0] = ctx->Const.ContextFlags;
          break;
+      case GL_PRIMITIVE_RESTART:
+         params[0] = BOOLEAN_TO_INT(ctx->Array.PrimitiveRestart);
+         break;
+      case GL_PRIMITIVE_RESTART_INDEX:
+         params[0] = ctx->Array.RestartIndex;
+         break;
       case GL_CONTEXT_PROFILE_MASK:
          params[0] = ctx->Const.ProfileMask;
          break;
@@ -7661,6 +7679,12 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
       case GL_CONTEXT_FLAGS:
          params[0] = (GLint64)(ctx->Const.ContextFlags);
          break;
+      case GL_PRIMITIVE_RESTART:
+         params[0] = BOOLEAN_TO_INT64(ctx->Array.PrimitiveRestart);
+         break;
+      case GL_PRIMITIVE_RESTART_INDEX:
+         params[0] = (GLint64)(ctx->Array.RestartIndex);
+         break;
       case GL_CONTEXT_PROFILE_MASK:
          params[0] = (GLint64)(ctx->Const.ProfileMask);
          break;
index 63b64a97a935acbb10e9ca095bac8c21bb6d03f1..0279ec9d1d3748a702c5b35a3712d67b24f9895c 100644 (file)
@@ -1145,6 +1145,12 @@ StateVars = [
        ( "GL_MINOR_VERSION", GLint, ["ctx->VersionMinor"], "", NoState, NoExt ),
        ( "GL_CONTEXT_FLAGS", GLint, ["ctx->Const.ContextFlags"], "", NoState, NoExt ),
 
+    # GL 3.1
+    ( "GL_PRIMITIVE_RESTART", GLboolean,
+      ["ctx->Array.PrimitiveRestart"], "", NoState, NoExt ),
+    ( "GL_PRIMITIVE_RESTART_INDEX", GLint,
+      ["ctx->Array.RestartIndex"], "", NoState, NoExt ),
        # GL 3.2
        ( "GL_CONTEXT_PROFILE_MASK", GLint, ["ctx->Const.ProfileMask"], "",
          NoState, NoExt )
index a980405f0196f4e2a68de70b7cb4ea8555a8d7be..349d5f51e66170b60c8dcb0e8f54be5c771a1da3 100644 (file)
@@ -1547,6 +1547,10 @@ struct gl_array_attrib
    GLuint LockFirst;            /**< GL_EXT_compiled_vertex_array */
    GLuint LockCount;            /**< GL_EXT_compiled_vertex_array */
 
+   /** GL 3.1 (slightly different from GL_NV_primitive_restart) */
+   GLboolean PrimitiveRestart;
+   GLuint RestartIndex;
+
    GLbitfield NewState;                /**< mask of _NEW_ARRAY_* values */
 
 #if FEATURE_ARB_vertex_buffer_object
index b4128f84d81dd63ea99bfb00012099cef8cf6d55..5f255b39b79eba02c1c1b8b361643e231f559547 100644 (file)
@@ -1053,6 +1053,27 @@ _mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
 }
 
 
+/**
+ * GL 3.1 glPrimitiveRestartIndex().
+ */
+void GLAPIENTRY
+_mesa_PrimitiveRestartIndex(GLuint index)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   if (ctx->VersionMajor * 10 + ctx->VersionMinor < 31) {
+      _mesa_error(ctx, GL_INVALID_OPERATION, "glPrimitiveRestartIndex()");
+      return;
+   }
+
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+   FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+
+   ctx->Array.RestartIndex = index;
+}
+
+
 /**
  * Copy one client vertex array to another.
  */
index ef790c504ea5bd6d4a15e9033fb46c7831259dca..b7c3e11674e186989d322e0ee323d39dc4c803ae 100644 (file)
@@ -174,6 +174,9 @@ _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end,
                                  const GLvoid *indices,
                                  GLint basevertex);
 
+extern void GLAPIENTRY
+_mesa_PrimitiveRestartIndex(GLuint index);
+
 
 extern void
 _mesa_copy_client_array(GLcontext *ctx,