New vbo_set_draw_func() to keep vbo context opaque to state tracker and tnl module.
[mesa.git] / src / mesa / tnl / t_vb_rendertmp.h
index b6c2933ae856164e3f623d1c8884da8e8bcae4a4..2b5f4e93b2202a6d058902ccef6233aea4ebecab 100644 (file)
@@ -1,21 +1,19 @@
-/* $Id: t_vb_rendertmp.h,v 1.7 2001/01/16 05:29:43 keithw Exp $ */
-
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
- * 
- * Copyright (C) 1999  Brian Paul   All Rights Reserved.
- * 
+ * Version:  6.5
+ *
+ * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * to deal in the Software without restriction, including without limitation
  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  * and/or sell copies of the Software, and to permit persons to whom the
  * Software is furnished to do so, subject to the following conditions:
- * 
+ *
  * The above copyright notice and this permission notice shall be included
  * in all copies or substantial portions of the Software.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
@@ -23,8 +21,8 @@
  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
- * Author:
- *    Keith Whitwell <keithw@valinux.com>
+ * Authors:
+ *    Keith Whitwell <keith@tungstengraphics.com>
  */
 
 
 #endif
 
 #ifndef INIT
-#define INIT(x)  
+#define INIT(x)
 #endif
 
 #ifndef NEED_EDGEFLAG_SETUP
 #define NEED_EDGEFLAG_SETUP 0
 #define EDGEFLAG_GET(a) 0
-#define EDGEFLAG_SET(a,b) (void)b 
+#define EDGEFLAG_SET(a,b) (void)b
 #endif
 
 #ifndef RESET_STIPPLE
 #define RESET_STIPPLE
 #endif
 
-#ifndef RESET_OCCLUSION
-#define RESET_OCCLUSION
-#endif
-
 #ifndef TEST_PRIM_END
-#define TEST_PRIM_END(flags) (flags & PRIM_END)
-#define TEST_PRIM_BEGIN(flags) (flags & PRIM_BEGIN)
-#define TEST_PRIM_PARITY(flags) (flags & PRIM_PARITY)
+#define TEST_PRIM_END(prim) (flags & PRIM_END)
+#define TEST_PRIM_BEGIN(prim) (flags & PRIM_BEGIN)
 #endif
 
 #ifndef ELT
@@ -72,7 +65,6 @@ static void TAG(render_points)( GLcontext *ctx,
    LOCAL_VARS;
    (void) flags;
 
-   RESET_OCCLUSION;
    INIT(GL_POINTS);
    RENDER_POINTS( start, count );
    POSTFIX;
@@ -87,11 +79,10 @@ static void TAG(render_lines)( GLcontext *ctx,
    LOCAL_VARS;
    (void) flags;
 
-   RESET_OCCLUSION;
    INIT(GL_LINES);
    for (j=start+1; j<count; j+=2 ) {
-      RENDER_LINE( ELT(j-1), ELT(j) );
       RESET_STIPPLE;
+      RENDER_LINE( ELT(j-1), ELT(j) );
    }
    POSTFIX;
 }
@@ -106,14 +97,14 @@ static void TAG(render_line_strip)( GLcontext *ctx,
    LOCAL_VARS;
    (void) flags;
 
-   RESET_OCCLUSION;
    INIT(GL_LINE_STRIP);
 
-   for (j=start+1; j<count; j++ ) 
-      RENDER_LINE( ELT(j-1), ELT(j) );
-
-   if (TEST_PRIM_END(flags))
+   if (TEST_PRIM_BEGIN(flags)) {
       RESET_STIPPLE;
+   }
+
+   for (j=start+1; j<count; j++ )
+      RENDER_LINE( ELT(j-1), ELT(j) );
 
    POSTFIX;
 }
@@ -124,16 +115,16 @@ static void TAG(render_line_loop)( GLcontext *ctx,
                                   GLuint count,
                                   GLuint flags )
 {
-   GLuint i;    
+   GLuint i;
    LOCAL_VARS;
 
    (void) flags;
 
-   RESET_OCCLUSION;
    INIT(GL_LINE_LOOP);
 
    if (start+1 < count) {
       if (TEST_PRIM_BEGIN(flags)) {
+        RESET_STIPPLE;
         RENDER_LINE( ELT(start), ELT(start+1) );
       }
 
@@ -143,7 +134,6 @@ static void TAG(render_line_loop)( GLcontext *ctx,
 
       if ( TEST_PRIM_END(flags)) {
         RENDER_LINE( ELT(count-1), ELT(start) );
-        RESET_STIPPLE;
       }
    }
 
@@ -165,8 +155,8 @@ static void TAG(render_triangles)( GLcontext *ctx,
       for (j=start+2; j<count; j+=3) {
         /* Leave the edgeflags as supplied by the user.
          */
-        RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
         RESET_STIPPLE;
+        RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
       }
    } else {
       for (j=start+2; j<count; j+=3) {
@@ -186,10 +176,7 @@ static void TAG(render_tri_strip)( GLcontext *ctx,
    GLuint j;
    GLuint parity = 0;
    LOCAL_VARS;
-   
-   if (TEST_PRIM_PARITY(flags))
-      parity = 1;
-   
+
    INIT(GL_TRIANGLE_STRIP);
    if (NEED_EDGEFLAG_SETUP) {
       for (j=start+2;j<count;j++,parity^=1) {
@@ -199,6 +186,9 @@ static void TAG(render_tri_strip)( GLcontext *ctx,
         GLboolean ef2 = EDGEFLAG_GET( ej2 );
         GLboolean ef1 = EDGEFLAG_GET( ej1 );
         GLboolean ef = EDGEFLAG_GET( ej );
+        if (TEST_PRIM_BEGIN(flags)) {
+           RESET_STIPPLE;
+        }
         EDGEFLAG_SET( ej2, GL_TRUE );
         EDGEFLAG_SET( ej1, GL_TRUE );
         EDGEFLAG_SET( ej, GL_TRUE );
@@ -206,7 +196,6 @@ static void TAG(render_tri_strip)( GLcontext *ctx,
         EDGEFLAG_SET( ej2, ef2 );
         EDGEFLAG_SET( ej1, ef1 );
         EDGEFLAG_SET( ej, ef );
-        RESET_STIPPLE;
       }
    } else {
       for (j=start+2; j<count ; j++, parity^=1) {
@@ -237,6 +226,9 @@ static void TAG(render_tri_fan)( GLcontext *ctx,
         GLboolean efs = EDGEFLAG_GET( ejs );
         GLboolean ef1 = EDGEFLAG_GET( ej1 );
         GLboolean ef = EDGEFLAG_GET( ej );
+        if (TEST_PRIM_BEGIN(flags)) {
+           RESET_STIPPLE;
+        }
         EDGEFLAG_SET( ejs, GL_TRUE );
         EDGEFLAG_SET( ej1, GL_TRUE );
         EDGEFLAG_SET( ej, GL_TRUE );
@@ -244,7 +236,6 @@ static void TAG(render_tri_fan)( GLcontext *ctx,
         EDGEFLAG_SET( ejs, efs );
         EDGEFLAG_SET( ej1, ef1 );
         EDGEFLAG_SET( ej, ef );
-        RESET_STIPPLE;
       }
    } else {
       for (j=start+2;j<count;j++) {
@@ -273,29 +264,32 @@ static void TAG(render_poly)( GLcontext *ctx,
       /* If the primitive does not begin here, the first edge
        * is non-boundary.
        */
-      if (!TEST_PRIM_BEGIN(flags)) 
+      if (!TEST_PRIM_BEGIN(flags))
         EDGEFLAG_SET( ELT(start), GL_FALSE );
+      else {
+        RESET_STIPPLE;
+      }
 
       /* If the primitive does not end here, the final edge is
        * non-boundary.
        */
-      if (!TEST_PRIM_END(flags)) 
+      if (!TEST_PRIM_END(flags))
         EDGEFLAG_SET( ELT(count-1), GL_FALSE );
 
       /* Draw the first triangles (possibly zero)
        */
-      if (j<count-1) {
+      if (j+1<count) {
         GLboolean ef = EDGEFLAG_GET( ELT(j) );
         EDGEFLAG_SET( ELT(j), GL_FALSE );
         RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
         EDGEFLAG_SET( ELT(j), ef );
         j++;
-           
+
         /* Don't render the first edge again:
          */
         EDGEFLAG_SET( ELT(start), GL_FALSE );
 
-        for (;j<count-1;j++) {
+        for (;j+1<count;j++) {
            GLboolean efj = EDGEFLAG_GET( ELT(j) );
            EDGEFLAG_SET( ELT(j), GL_FALSE );
            RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
@@ -312,10 +306,7 @@ static void TAG(render_poly)( GLcontext *ctx,
        */
       EDGEFLAG_SET( ELT(count-1), efcount );
       EDGEFLAG_SET( ELT(start), efstart );
-        
-      if (TEST_PRIM_END(flags)) {
-        RESET_STIPPLE;
-      }
+
    }
    else {
       for (j=start+2;j<count;j++) {
@@ -339,8 +330,8 @@ static void TAG(render_quads)( GLcontext *ctx,
       for (j=start+3; j<count; j+=4) {
         /* Use user-specified edgeflags for quads.
          */
-        RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
         RESET_STIPPLE;
+        RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
       }
    } else {
       for (j=start+3; j<count; j+=4) {
@@ -348,7 +339,7 @@ static void TAG(render_quads)( GLcontext *ctx,
       }
    }
    POSTFIX;
-} 
+}
 
 static void TAG(render_quad_strip)( GLcontext *ctx,
                                    GLuint start,
@@ -369,6 +360,9 @@ static void TAG(render_quad_strip)( GLcontext *ctx,
         GLboolean ef2 = EDGEFLAG_GET( ELT(j-2) );
         GLboolean ef1 = EDGEFLAG_GET( ELT(j-1) );
         GLboolean ef = EDGEFLAG_GET( ELT(j) );
+        if (TEST_PRIM_BEGIN(flags)) {
+           RESET_STIPPLE;
+        }
         EDGEFLAG_SET( ELT(j-3), GL_TRUE );
         EDGEFLAG_SET( ELT(j-2), GL_TRUE );
         EDGEFLAG_SET( ELT(j-1), GL_TRUE );
@@ -378,7 +372,6 @@ static void TAG(render_quad_strip)( GLcontext *ctx,
         EDGEFLAG_SET( ELT(j-2), ef2 );
         EDGEFLAG_SET( ELT(j-1), ef1 );
         EDGEFLAG_SET( ELT(j), ef );
-        RESET_STIPPLE;
       }
    } else {
       for (j=start+3;j<count;j+=2) {
@@ -399,7 +392,7 @@ static void TAG(render_noop)( GLcontext *ctx,
 RENDER_TAB_QUALIFIER void (*TAG(render_tab)[GL_POLYGON+2])(GLcontext *,
                                                           GLuint,
                                                           GLuint,
-                                                          GLuint) = 
+                                                          GLuint) =
 {
    TAG(render_points),
    TAG(render_lines),
@@ -436,4 +429,3 @@ RENDER_TAB_QUALIFIER void (*TAG(render_tab)[GL_POLYGON+2])(GLcontext *,
 
 #undef PRESERVE_VB_DEFS
 #undef PRESERVE_TAG
-