use BCOPY macro on FreeBSD
[mesa.git] / src / mesa / main / lines.c
index ed671d7a8296b44a8e361f9d9097a47d0dda733f..ba877a85e1911c65b7ef26fe4e56b1740ba65259 100644 (file)
@@ -1,8 +1,8 @@
-/* $Id: lines.c,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
+/* $Id: lines.c,v 1.9 2000/03/03 18:55:45 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.1
+ * Version:  3.3
  * 
  * Copyright (C) 1999  Brian Paul   All Rights Reserved.
  * 
  */
 
 
-
-
-
 #ifdef PC_HEADER
 #include "all.h"
 #else
-#include <assert.h>
+#include "glheader.h"
 #include "context.h"
 #include "depth.h"
 #include "feedback.h"
 #include "texstate.h"
 #include "types.h"
 #include "vb.h"
-#ifdef XFree86Server
-#include "GL/xf86glx.h"
-#endif
 #endif
 
 
 
-void gl_LineWidth( GLcontext *ctx, GLfloat width )
+void
+_mesa_LineWidth( GLfloat width )
 {
+   GET_CURRENT_CONTEXT(ctx);
    if (width<=0.0) {
       gl_error( ctx, GL_INVALID_VALUE, "glLineWidth" );
       return;
@@ -62,17 +58,24 @@ void gl_LineWidth( GLcontext *ctx, GLfloat width )
       ctx->TriangleCaps &= ~DD_LINE_WIDTH;
       if (width != 1.0) ctx->TriangleCaps |= DD_LINE_WIDTH;
       ctx->NewState |= NEW_RASTER_OPS;
+      if (ctx->Driver.LineWidth)
+         (*ctx->Driver.LineWidth)(ctx, width);
    }
 }
 
 
 
-void gl_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
+void
+_mesa_LineStipple( GLint factor, GLushort pattern )
 {
+   GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLineStipple");
    ctx->Line.StippleFactor = CLAMP( factor, 1, 256 );
    ctx->Line.StipplePattern = pattern;
    ctx->NewState |= NEW_RASTER_OPS;
+
+   if (ctx->Driver.LineStipple)
+      ctx->Driver.LineStipple( ctx, factor, pattern );
 }
 
 
@@ -99,83 +102,6 @@ void gl_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
 
 
 
-static void feedback_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv )
-{
-   struct vertex_buffer *VB = ctx->VB;
-   GLfloat x1, y1, z1, w1;
-   GLfloat x2, y2, z2, w2;
-   GLfloat tex1[4], tex2[4], invq;
-   GLuint texUnit = ctx->Texture.CurrentTransformUnit;
-
-   x1 = VB->Win.data[v1][0];
-   y1 = VB->Win.data[v1][1];
-   z1 = VB->Win.data[v1][2] / DEPTH_SCALE;
-   w1 = (VB->ClipPtr->size == 4 ? VEC_ELT(VB->ClipPtr, GLfloat, v1)[3] : 1.0);
-
-   x2 = VB->Win.data[v2][0];
-   y2 = VB->Win.data[v2][1];
-   z2 = VB->Win.data[v2][2] / DEPTH_SCALE;
-   w2 = (VB->ClipPtr->size == 4 ? VEC_ELT(VB->ClipPtr, GLfloat, v2)[3] : 1.0);
-
-
-   if (VB->TexCoordPtr[texUnit]->size == 4) {      
-      invq = (VB->TexCoordPtr[texUnit]->data[v1][3]==0.0
-             ? 1.0
-             : 1.0F / VB->TexCoordPtr[texUnit]->data[v1][3]);
-
-      tex1[0] = VB->TexCoordPtr[texUnit]->data[v1][0] * invq;
-      tex1[1] = VB->TexCoordPtr[texUnit]->data[v1][1] * invq;
-      tex1[2] = VB->TexCoordPtr[texUnit]->data[v1][2] * invq;
-      tex1[3] = VB->TexCoordPtr[texUnit]->data[v1][3];
-
-      invq = (VB->TexCoordPtr[texUnit]->data[v2][3]==0.0
-             ? 1.0
-             : 1.0F / VB->TexCoordPtr[texUnit]->data[v2][3]);
-
-      tex2[0] = VB->TexCoordPtr[texUnit]->data[v2][0] * invq;
-      tex2[1] = VB->TexCoordPtr[texUnit]->data[v2][1] * invq;
-      tex2[2] = VB->TexCoordPtr[texUnit]->data[v2][2] * invq;
-      tex2[3] = VB->TexCoordPtr[texUnit]->data[v2][3];
-   } else {
-      ASSIGN_4V(tex1, 0,0,0,1);
-      ASSIGN_4V(tex2, 0,0,0,1);
-      COPY_SZ_4V(tex1, 
-                VB->TexCoordPtr[texUnit]->size,
-                VB->TexCoordPtr[texUnit]->data[v1]);
-      COPY_SZ_4V(tex2, 
-                VB->TexCoordPtr[texUnit]->size,
-                VB->TexCoordPtr[texUnit]->data[v2]);
-   }
-
-
-   if (ctx->StippleCounter==0) {
-      FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_LINE_RESET_TOKEN );
-   }
-   else {
-      FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_LINE_TOKEN );
-   }
-
-   {
-      GLfloat color[4];
-      GLubyte *ubc = VB->ColorPtr->data[pv];
-      GLuint index = VB->IndexPtr->data[pv];
-
-      UBYTE_RGBA_TO_FLOAT_RGBA( color, ubc );
-      gl_feedback_vertex( ctx, x1,y1,z1,w1, color, (GLfloat) index, tex1 );
-      gl_feedback_vertex( ctx, x2,y2,z2,w2, color, (GLfloat) index, tex2 );
-   }
-
-   ctx->StippleCounter++;
-}
-
-
-
-static void select_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv )
-{
-   (void) pv;
-   gl_update_hitflag( ctx, ctx->VB->Win.data[v1][2] / DEPTH_SCALE );
-   gl_update_hitflag( ctx, ctx->VB->Win.data[v2][2] / DEPTH_SCALE );
-}
 
 
 
@@ -206,7 +132,7 @@ static void flat_ci_line( GLcontext *ctx,
 #include "linetemp.h"
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -234,7 +160,7 @@ static void flat_ci_z_line( GLcontext *ctx,
 #include "linetemp.h"
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -260,7 +186,7 @@ static void flat_rgba_line( GLcontext *ctx,
 #include "linetemp.h"
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -289,7 +215,7 @@ static void flat_rgba_z_line( GLcontext *ctx,
 #include "linetemp.h"
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -316,7 +242,7 @@ static void smooth_ci_line( GLcontext *ctx,
 #include "linetemp.h"
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -346,7 +272,7 @@ static void smooth_ci_z_line( GLcontext *ctx,
 #include "linetemp.h"
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -377,7 +303,7 @@ static void smooth_rgba_line( GLcontext *ctx,
 #include "linetemp.h"
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -411,7 +337,7 @@ static void smooth_rgba_z_line( GLcontext *ctx,
 #include "linetemp.h"
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -492,7 +418,7 @@ static void general_smooth_ci_line( GLcontext *ctx,
    }
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -557,7 +483,7 @@ static void general_flat_ci_line( GLcontext *ctx,
    }
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -652,7 +578,7 @@ static void general_smooth_rgba_line( GLcontext *ctx,
    }
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -717,7 +643,7 @@ static void general_flat_rgba_line( GLcontext *ctx,
    }
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -777,7 +703,7 @@ static void flat_textured_line( GLcontext *ctx,
    }
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -849,7 +775,7 @@ static void smooth_textured_line( GLcontext *ctx,
    }
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -942,7 +868,7 @@ static void smooth_multitextured_line( GLcontext *ctx,
    }
 
    ctx->PB->count = count;
-   PB_CHECK_FLUSH( ctx, ctx->PB );
+   gl_flush_pb(ctx);
 }
 
 
@@ -1103,8 +1029,7 @@ void gl_set_line_function( GLcontext *ctx )
       else {
         if (ctx->Light.ShadeModel==GL_SMOOTH) {
            /* Width==1, non-stippled, smooth-shaded */
-            if (ctx->Depth.Test
-               || (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) {
+            if (ctx->Depth.Test || ctx->FogMode == FOG_FRAGMENT) {
                if (rgbmode)
                   ctx->Driver.LineFunc = smooth_rgba_z_line;
                else
@@ -1119,8 +1044,7 @@ void gl_set_line_function( GLcontext *ctx )
         }
          else {
            /* Width==1, non-stippled, flat-shaded */
-            if (ctx->Depth.Test
-                || (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) {
+            if (ctx->Depth.Test || ctx->FogMode == FOG_FRAGMENT) {
                if (rgbmode)
                   ctx->Driver.LineFunc = flat_rgba_z_line;
                else
@@ -1136,11 +1060,11 @@ void gl_set_line_function( GLcontext *ctx )
       }
    }
    else if (ctx->RenderMode==GL_FEEDBACK) {
-      ctx->Driver.LineFunc = feedback_line;
+      ctx->Driver.LineFunc = gl_feedback_line;
    }
    else {
       /* GL_SELECT mode */
-      ctx->Driver.LineFunc = select_line;
+      ctx->Driver.LineFunc = gl_select_line;
    }
 }