support for N texture units
[mesa.git] / src / mesa / main / lines.c
index 5d33946ce3fdd12781c2f58f189c9b7bf7068161..7330ea573bde83932d1b995900bfd33512d1abc3 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: lines.c,v 1.8 2000/02/27 20:38:15 keithw Exp $ */
+/* $Id: lines.c,v 1.15 2000/09/30 18:42:29 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.3
+ * Version:  3.5
  * 
- * Copyright (C) 1999  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2000  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"),
@@ -58,6 +58,8 @@ _mesa_LineWidth( 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);
    }
 }
 
@@ -114,22 +116,13 @@ _mesa_LineStipple( GLint factor, GLushort pattern )
 static void flat_ci_line( GLcontext *ctx,
                           GLuint vert0, GLuint vert1, GLuint pvert )
 {
-   GLint count;
-   GLint *pbx = ctx->PB->x;
-   GLint *pby = ctx->PB->y;
-   PB_SET_INDEX( ctx, ctx->PB, ctx->VB->IndexPtr->data[pvert] );
-   count = ctx->PB->count;
+   PB_SET_INDEX( ctx->PB, ctx->VB->IndexPtr->data[pvert] );
 
 #define INTERP_XY 1
-
-#define PLOT(X,Y)              \
-       pbx[count] = X;         \
-       pby[count] = Y;         \
-       count++;
+#define PLOT(X,Y)  PB_WRITE_PIXEL(ctx->PB, X, Y, 0);
 
 #include "linetemp.h"
 
-   ctx->PB->count = count;
    gl_flush_pb(ctx);
 }
 
@@ -139,25 +132,14 @@ static void flat_ci_line( GLcontext *ctx,
 static void flat_ci_z_line( GLcontext *ctx,
                             GLuint vert0, GLuint vert1, GLuint pvert )
 {
-   GLint count;
-   GLint *pbx = ctx->PB->x;
-   GLint *pby = ctx->PB->y;
-   GLdepth *pbz = ctx->PB->z;
-   PB_SET_INDEX( ctx, ctx->PB, ctx->VB->IndexPtr->data[pvert] );
-   count = ctx->PB->count;
+   PB_SET_INDEX( ctx->PB, ctx->VB->IndexPtr->data[pvert] );
 
 #define INTERP_XY 1
 #define INTERP_Z 1
-
-#define PLOT(X,Y)              \
-       pbx[count] = X;         \
-       pby[count] = Y;         \
-       pbz[count] = Z;         \
-       count++;
+#define PLOT(X,Y)  PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
 
 #include "linetemp.h"
 
-   ctx->PB->count = count;
    gl_flush_pb(ctx);
 }
 
@@ -167,23 +149,14 @@ static void flat_ci_z_line( GLcontext *ctx,
 static void flat_rgba_line( GLcontext *ctx,
                             GLuint vert0, GLuint vert1, GLuint pvert )
 {
-   GLint count;
-   GLint *pbx = ctx->PB->x;
-   GLint *pby = ctx->PB->y;
-   GLubyte *color = ctx->VB->ColorPtr->data[pvert];
-   PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] );
-   count = ctx->PB->count;
+   const GLubyte *color = ctx->VB->ColorPtr->data[pvert];
+   PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] );
 
 #define INTERP_XY 1
-
-#define PLOT(X,Y)              \
-       pbx[count] = X;         \
-       pby[count] = Y;         \
-       count++;
+#define PLOT(X,Y)   PB_WRITE_PIXEL(ctx->PB, X, Y, 0);
 
 #include "linetemp.h"
 
-   ctx->PB->count = count;
    gl_flush_pb(ctx);
 }
 
@@ -193,26 +166,15 @@ static void flat_rgba_line( GLcontext *ctx,
 static void flat_rgba_z_line( GLcontext *ctx,
                               GLuint vert0, GLuint vert1, GLuint pvert )
 {
-   GLint count;
-   GLint *pbx = ctx->PB->x;
-   GLint *pby = ctx->PB->y;
-   GLdepth *pbz = ctx->PB->z;
-   GLubyte *color = ctx->VB->ColorPtr->data[pvert];
-   PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] );
-   count = ctx->PB->count;
+   const GLubyte *color = ctx->VB->ColorPtr->data[pvert];
+   PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] );
 
 #define INTERP_XY 1
 #define INTERP_Z 1
-
-#define PLOT(X,Y)      \
-       pbx[count] = X; \
-       pby[count] = Y; \
-       pbz[count] = Z; \
-       count++;
+#define PLOT(X,Y)   PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
 
 #include "linetemp.h"
 
-   ctx->PB->count = count;
    gl_flush_pb(ctx);
 }
 
@@ -225,9 +187,11 @@ static void smooth_ci_line( GLcontext *ctx,
    GLint count = ctx->PB->count;
    GLint *pbx = ctx->PB->x;
    GLint *pby = ctx->PB->y;
-   GLuint *pbi = ctx->PB->i;
+   GLuint *pbi = ctx->PB->index;
    (void) pvert;
 
+   ctx->PB->mono = GL_FALSE;
+
 #define INTERP_XY 1
 #define INTERP_INDEX 1
 
@@ -253,9 +217,11 @@ static void smooth_ci_z_line( GLcontext *ctx,
    GLint *pbx = ctx->PB->x;
    GLint *pby = ctx->PB->y;
    GLdepth *pbz = ctx->PB->z;
-   GLuint *pbi = ctx->PB->i;
+   GLuint *pbi = ctx->PB->index;
    (void) pvert;
 
+   ctx->PB->mono = GL_FALSE;
+
 #define INTERP_XY 1
 #define INTERP_Z 1
 #define INTERP_INDEX 1
@@ -285,6 +251,8 @@ static void smooth_rgba_line( GLcontext *ctx,
    GLubyte (*pbrgba)[4] = ctx->PB->rgba;
    (void) pvert;
 
+   ctx->PB->mono = GL_FALSE;
+
 #define INTERP_XY 1
 #define INTERP_RGB 1
 #define INTERP_ALPHA 1
@@ -317,6 +285,8 @@ static void smooth_rgba_z_line( GLcontext *ctx,
    GLubyte (*pbrgba)[4] = ctx->PB->rgba;
    (void) pvert;
 
+   ctx->PB->mono = GL_FALSE;
+
 #define INTERP_XY 1
 #define INTERP_Z 1
 #define INTERP_RGB 1
@@ -356,9 +326,11 @@ static void general_smooth_ci_line( GLcontext *ctx,
    GLint *pbx = ctx->PB->x;
    GLint *pby = ctx->PB->y;
    GLdepth *pbz = ctx->PB->z;
-   GLuint *pbi = ctx->PB->i;
+   GLuint *pbi = ctx->PB->index;
    (void) pvert;
 
+   ctx->PB->mono = GL_FALSE;
+
    if (ctx->Line.StippleFlag) {
       /* stippled */
 #define INTERP_XY 1
@@ -428,7 +400,7 @@ static void general_flat_ci_line( GLcontext *ctx,
    GLint *pbx = ctx->PB->x;
    GLint *pby = ctx->PB->y;
    GLdepth *pbz = ctx->PB->z;
-   PB_SET_INDEX( ctx, ctx->PB, ctx->VB->IndexPtr->data[pvert] );
+   PB_SET_INDEX( ctx->PB, ctx->VB->IndexPtr->data[pvert] );
    count = ctx->PB->count;
 
    if (ctx->Line.StippleFlag) {
@@ -496,6 +468,8 @@ static void general_smooth_rgba_line( GLcontext *ctx,
    GLubyte (*pbrgba)[4] = ctx->PB->rgba;
    (void) pvert;
 
+   ctx->PB->mono = GL_FALSE;
+
    if (ctx->Line.StippleFlag) {
       /* stippled */
 #define INTERP_XY 1
@@ -583,13 +557,8 @@ static void general_smooth_rgba_line( GLcontext *ctx,
 static void general_flat_rgba_line( GLcontext *ctx,
                                     GLuint vert0, GLuint vert1, GLuint pvert )
 {
-   GLint count;
-   GLint *pbx = ctx->PB->x;
-   GLint *pby = ctx->PB->y;
-   GLdepth *pbz = ctx->PB->z;
-   GLubyte *color = ctx->VB->ColorPtr->data[pvert];
-   PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] );
-   count = ctx->PB->count;
+   const GLubyte *color = ctx->VB->ColorPtr->data[pvert];
+   PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] );
 
    if (ctx->Line.StippleFlag) {
       /* stippled */
@@ -597,12 +566,7 @@ static void general_flat_rgba_line( GLcontext *ctx,
 #define INTERP_Z 1
 #define WIDE 1
 #define STIPPLE 1
-#define PLOT(X,Y)                      \
-       pbx[count] = X;                 \
-       pby[count] = Y;                 \
-       pbz[count] = Z;                 \
-       count++;                        \
-       CHECK_FULL(count);
+#define PLOT(X,Y)  PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
 #include "linetemp.h"
    }
    else {
@@ -611,18 +575,10 @@ static void general_flat_rgba_line( GLcontext *ctx,
          /* special case: unstippled and width=2 */
 #define INTERP_XY 1
 #define INTERP_Z 1
-#define XMAJOR_PLOT(X,Y)                       \
-       pbx[count] = X;  pbx[count+1] = X;      \
-       pby[count] = Y;  pby[count+1] = Y+1;    \
-       pbz[count] = Z;  pbz[count+1] = Z;      \
-       count += 2;                             \
-       CHECK_FULL(count);
-#define YMAJOR_PLOT(X,Y)                       \
-       pbx[count] = X;  pbx[count+1] = X+1;    \
-       pby[count] = Y;  pby[count+1] = Y;      \
-       pbz[count] = Z;  pbz[count+1] = Z;      \
-       count += 2;                             \
-       CHECK_FULL(count);
+#define XMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z); \
+                         PB_WRITE_PIXEL(ctx->PB, X, Y+1, Z);
+#define YMAJOR_PLOT(X,Y)  PB_WRITE_PIXEL(ctx->PB, X, Y, Z); \
+                          PB_WRITE_PIXEL(ctx->PB, X+1, Y, Z);
 #include "linetemp.h"
       }
       else {
@@ -630,17 +586,11 @@ static void general_flat_rgba_line( GLcontext *ctx,
 #define INTERP_XY 1
 #define INTERP_Z 1
 #define WIDE 1
-#define PLOT(X,Y)                      \
-       pbx[count] = X;                 \
-       pby[count] = Y;                 \
-       pbz[count] = Z;                 \
-       count++;                        \
-       CHECK_FULL(count);
+#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
 #include "linetemp.h"
       }
    }
 
-   ctx->PB->count = count;
    gl_flush_pb(ctx);
 }
 
@@ -657,14 +607,14 @@ static void flat_textured_line( GLcontext *ctx,
    GLfloat *pbt = ctx->PB->t[0];
    GLfloat *pbu = ctx->PB->u[0];
    GLubyte *color = ctx->VB->ColorPtr->data[pv];
-   PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] );
+   PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] );
    count = ctx->PB->count;
 
    if (ctx->Line.StippleFlag) {
       /* stippled */
 #define INTERP_XY 1
 #define INTERP_Z 1
-#define INTERP_STUV0 1
+#define INTERP_TEX 1
 #define WIDE 1
 #define STIPPLE 1
 #define PLOT(X,Y)                      \
@@ -672,9 +622,9 @@ static void flat_textured_line( GLcontext *ctx,
           pbx[count] = X;              \
           pby[count] = Y;              \
           pbz[count] = Z;              \
-          pbs[count] = s;              \
-          pbt[count] = t;              \
-          pbu[count] = u;              \
+          pbs[count] = fragTexcoord[0];\
+          pbt[count] = fragTexcoord[1];\
+          pbu[count] = fragTexcoord[2];\
           count++;                     \
           CHECK_FULL(count);           \
        }
@@ -684,16 +634,16 @@ static void flat_textured_line( GLcontext *ctx,
       /* unstippled */
 #define INTERP_XY 1
 #define INTERP_Z 1
-#define INTERP_STUV0 1
+#define INTERP_TEX 1
 #define WIDE 1
 #define PLOT(X,Y)                      \
        {                               \
           pbx[count] = X;              \
           pby[count] = Y;              \
           pbz[count] = Z;              \
-          pbs[count] = s;              \
-          pbt[count] = t;              \
-          pbu[count] = u;              \
+          pbs[count] = fragTexcoord[0];\
+          pbt[count] = fragTexcoord[1];\
+          pbu[count] = fragTexcoord[2];\
           count++;                     \
           CHECK_FULL(count);           \
        }
@@ -720,13 +670,15 @@ static void smooth_textured_line( GLcontext *ctx,
    GLubyte (*pbrgba)[4] = ctx->PB->rgba;
    (void) pvert;
 
+   ctx->PB->mono = GL_FALSE;
+
    if (ctx->Line.StippleFlag) {
       /* stippled */
 #define INTERP_XY 1
 #define INTERP_Z 1
 #define INTERP_RGB 1
 #define INTERP_ALPHA 1
-#define INTERP_STUV0 1
+#define INTERP_TEX 1
 #define WIDE 1
 #define STIPPLE 1
 #define PLOT(X,Y)                                      \
@@ -734,9 +686,9 @@ static void smooth_textured_line( GLcontext *ctx,
           pbx[count] = X;                              \
           pby[count] = Y;                              \
           pbz[count] = Z;                              \
-          pbs[count] = s;                              \
-          pbt[count] = t;                              \
-          pbu[count] = u;                              \
+          pbs[count] = fragTexcoord[0];                \
+          pbt[count] = fragTexcoord[1];                \
+          pbu[count] = fragTexcoord[2];                \
           pbrgba[count][RCOMP] = FixedToInt(r0);       \
           pbrgba[count][GCOMP] = FixedToInt(g0);       \
           pbrgba[count][BCOMP] = FixedToInt(b0);       \
@@ -752,16 +704,16 @@ static void smooth_textured_line( GLcontext *ctx,
 #define INTERP_Z 1
 #define INTERP_RGB 1
 #define INTERP_ALPHA 1
-#define INTERP_STUV0 1
+#define INTERP_TEX 1
 #define WIDE 1
 #define PLOT(X,Y)                                      \
        {                                               \
           pbx[count] = X;                              \
           pby[count] = Y;                              \
           pbz[count] = Z;                              \
-          pbs[count] = s;                              \
-          pbt[count] = t;                              \
-          pbu[count] = u;                              \
+          pbs[count] = fragTexcoord[0];                \
+          pbt[count] = fragTexcoord[1];                \
+          pbu[count] = fragTexcoord[2];                \
           pbrgba[count][RCOMP] = FixedToInt(r0);       \
           pbrgba[count][GCOMP] = FixedToInt(g0);       \
           pbrgba[count][BCOMP] = FixedToInt(b0);       \
@@ -787,16 +739,12 @@ static void smooth_multitextured_line( GLcontext *ctx,
    GLint *pbx = ctx->PB->x;
    GLint *pby = ctx->PB->y;
    GLdepth *pbz = ctx->PB->z;
-   GLfloat *pbs = ctx->PB->s[0];
-   GLfloat *pbt = ctx->PB->t[0];
-   GLfloat *pbu = ctx->PB->u[0];
-   GLfloat *pbs1 = ctx->PB->s[1];
-   GLfloat *pbt1 = ctx->PB->t[1];
-   GLfloat *pbu1 = ctx->PB->u[1];
    GLubyte (*pbrgba)[4] = ctx->PB->rgba;
    GLubyte (*pbspec)[3] = ctx->PB->spec;
    (void) pvert;
 
+   ctx->PB->mono = GL_FALSE;
+
    if (ctx->Line.StippleFlag) {
       /* stippled */
 #define INTERP_XY 1
@@ -804,30 +752,32 @@ static void smooth_multitextured_line( GLcontext *ctx,
 #define INTERP_RGB 1
 #define INTERP_SPEC 1
 #define INTERP_ALPHA 1
-#define INTERP_STUV0 1
-#define INTERP_STUV1 1
+#define INTERP_MULTITEX 1
 #define WIDE 1
 #define STIPPLE 1
-#define PLOT(X,Y)                                      \
-       {                                               \
-          pbx[count] = X;                              \
-          pby[count] = Y;                              \
-          pbz[count] = Z;                              \
-          pbs[count] = s;                              \
-          pbt[count] = t;                              \
-          pbu[count] = u;                              \
-          pbs1[count] = s1;                            \
-          pbt1[count] = t1;                            \
-          pbu1[count] = u1;                            \
-          pbrgba[count][RCOMP] = FixedToInt(r0);       \
-          pbrgba[count][GCOMP] = FixedToInt(g0);       \
-          pbrgba[count][BCOMP] = FixedToInt(b0);       \
-          pbrgba[count][ACOMP] = FixedToInt(a0);       \
-          pbspec[count][RCOMP] = FixedToInt(sr0);      \
-          pbspec[count][GCOMP] = FixedToInt(sg0);      \
-          pbspec[count][BCOMP] = FixedToInt(sb0);      \
-          count++;                                     \
-          CHECK_FULL(count);                           \
+#define PLOT(X,Y)                                              \
+       {                                                       \
+          GLuint u;                                            \
+          pbx[count] = X;                                      \
+          pby[count] = Y;                                      \
+          pbz[count] = Z;                                      \
+          pbrgba[count][RCOMP] = FixedToInt(r0);               \
+          pbrgba[count][GCOMP] = FixedToInt(g0);               \
+          pbrgba[count][BCOMP] = FixedToInt(b0);               \
+          pbrgba[count][ACOMP] = FixedToInt(a0);               \
+          pbspec[count][RCOMP] = FixedToInt(sr0);              \
+          pbspec[count][GCOMP] = FixedToInt(sg0);              \
+          pbspec[count][BCOMP] = FixedToInt(sb0);              \
+          for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {   \
+             if (ctx->Texture.Unit[u].ReallyEnabled) {         \
+                ctx->PB->s[u][0] = fragTexcoord[u][0];         \
+                ctx->PB->s[u][1] = fragTexcoord[u][1];         \
+                ctx->PB->s[u][2] = fragTexcoord[u][2];         \
+                ctx->PB->s[u][3] = fragTexcoord[u][3];         \
+             }                                                 \
+          }                                                    \
+          count++;                                             \
+          CHECK_FULL(count);                                   \
        }
 #include "linetemp.h"
    }
@@ -838,29 +788,31 @@ static void smooth_multitextured_line( GLcontext *ctx,
 #define INTERP_RGB 1
 #define INTERP_SPEC 1
 #define INTERP_ALPHA 1
-#define INTERP_STUV0 1
-#define INTERP_STUV1 1
+#define INTERP_MULTITEX 1
 #define WIDE 1
-#define PLOT(X,Y)                                      \
-       {                                               \
-          pbx[count] = X;                              \
-          pby[count] = Y;                              \
-          pbz[count] = Z;                              \
-          pbs[count] = s;                              \
-          pbt[count] = t;                              \
-          pbu[count] = u;                              \
-          pbs1[count] = s1;                            \
-          pbt1[count] = t1;                            \
-          pbu1[count] = u1;                            \
-          pbrgba[count][RCOMP] = FixedToInt(r0);       \
-          pbrgba[count][GCOMP] = FixedToInt(g0);       \
-          pbrgba[count][BCOMP] = FixedToInt(b0);       \
-          pbrgba[count][ACOMP] = FixedToInt(a0);       \
-          pbspec[count][RCOMP] = FixedToInt(sr0);      \
-          pbspec[count][GCOMP] = FixedToInt(sg0);      \
-          pbspec[count][BCOMP] = FixedToInt(sb0);      \
-          count++;                                     \
-          CHECK_FULL(count);                           \
+#define PLOT(X,Y)                                              \
+       {                                                       \
+          GLuint u;                                            \
+          pbx[count] = X;                                      \
+          pby[count] = Y;                                      \
+          pbz[count] = Z;                                      \
+          pbrgba[count][RCOMP] = FixedToInt(r0);               \
+          pbrgba[count][GCOMP] = FixedToInt(g0);               \
+          pbrgba[count][BCOMP] = FixedToInt(b0);               \
+          pbrgba[count][ACOMP] = FixedToInt(a0);               \
+          pbspec[count][RCOMP] = FixedToInt(sr0);              \
+          pbspec[count][GCOMP] = FixedToInt(sg0);              \
+          pbspec[count][BCOMP] = FixedToInt(sb0);              \
+          for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {   \
+             if (ctx->Texture.Unit[u].ReallyEnabled) {         \
+                ctx->PB->s[u][0] = fragTexcoord[u][0];         \
+                ctx->PB->s[u][1] = fragTexcoord[u][1];         \
+                ctx->PB->s[u][2] = fragTexcoord[u][2];         \
+                ctx->PB->s[u][3] = fragTexcoord[u][3];         \
+             }                                                 \
+          }                                                    \
+          count++;                                             \
+          CHECK_FULL(count);                                   \
        }
 #include "linetemp.h"
    }
@@ -870,6 +822,102 @@ static void smooth_multitextured_line( GLcontext *ctx,
 }
 
 
+/* Flat-shaded, multitextured, any width, maybe stippled, separate specular
+ * color interpolation.
+ */
+static void flat_multitextured_line( GLcontext *ctx,
+                                     GLuint vert0, GLuint vert1, GLuint pvert )
+{
+   GLint count = ctx->PB->count;
+   GLint *pbx = ctx->PB->x;
+   GLint *pby = ctx->PB->y;
+   GLdepth *pbz = ctx->PB->z;
+   GLubyte (*pbrgba)[4] = ctx->PB->rgba;
+   GLubyte (*pbspec)[3] = ctx->PB->spec;
+   GLubyte *color = ctx->VB->ColorPtr->data[pvert];
+   GLubyte sRed   = ctx->VB->Specular ? ctx->VB->Specular[pvert][0] : 0;
+   GLubyte sGreen = ctx->VB->Specular ? ctx->VB->Specular[pvert][1] : 0;
+   GLubyte sBlue  = ctx->VB->Specular ? ctx->VB->Specular[pvert][2] : 0;
+
+   (void) pvert;
+
+   ctx->PB->mono = GL_FALSE;
+
+   if (ctx->Line.StippleFlag) {
+      /* stippled */
+#define INTERP_XY 1
+#define INTERP_Z 1
+#define INTERP_ALPHA 1
+#define INTERP_MULTITEX 1
+#define WIDE 1
+#define STIPPLE 1
+#define PLOT(X,Y)                                              \
+       {                                                       \
+          GLuint u;                                            \
+          pbx[count] = X;                                      \
+          pby[count] = Y;                                      \
+          pbz[count] = Z;                                      \
+          pbrgba[count][RCOMP] = color[0];                     \
+          pbrgba[count][GCOMP] = color[1];                     \
+          pbrgba[count][BCOMP] = color[2];                     \
+          pbrgba[count][ACOMP] = color[3];                     \
+          pbspec[count][RCOMP] = sRed;                         \
+          pbspec[count][GCOMP] = sGreen;                       \
+          pbspec[count][BCOMP] = sBlue;                        \
+          for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {   \
+             if (ctx->Texture.Unit[u].ReallyEnabled) {         \
+                ctx->PB->s[u][0] = fragTexcoord[u][0];         \
+                ctx->PB->s[u][1] = fragTexcoord[u][1];         \
+                ctx->PB->s[u][2] = fragTexcoord[u][2];         \
+                ctx->PB->s[u][3] = fragTexcoord[u][3];         \
+             }                                                 \
+          }                                                    \
+          count++;                                             \
+          CHECK_FULL(count);                                   \
+       }
+#include "linetemp.h"
+   }
+   else {
+      /* unstippled */
+#define INTERP_XY 1
+#define INTERP_Z 1
+#define INTERP_ALPHA 1
+#define INTERP_MULTITEX 1
+#define WIDE 1
+#define PLOT(X,Y)                                              \
+       {                                                       \
+          GLuint u;                                            \
+          pbx[count] = X;                                      \
+          pby[count] = Y;                                      \
+          pbz[count] = Z;                                      \
+          pbrgba[count][RCOMP] = color[0];                     \
+          pbrgba[count][GCOMP] = color[1];                     \
+          pbrgba[count][BCOMP] = color[2];                     \
+          pbrgba[count][ACOMP] = color[3];                     \
+          pbspec[count][RCOMP] = sRed;                         \
+          pbspec[count][GCOMP] = sGreen;                       \
+          pbspec[count][BCOMP] = sBlue;                        \
+          for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {   \
+             if (ctx->Texture.Unit[u].ReallyEnabled) {         \
+                ctx->PB->s[u][0] = fragTexcoord[u][0];         \
+                ctx->PB->s[u][1] = fragTexcoord[u][1];         \
+                ctx->PB->s[u][2] = fragTexcoord[u][2];         \
+                ctx->PB->s[u][3] = fragTexcoord[u][3];         \
+             }                                                 \
+          }                                                    \
+          count++;                                             \
+          CHECK_FULL(count);                                   \
+       }
+#include "linetemp.h"
+   }
+
+   ctx->PB->count = count;
+   gl_flush_pb(ctx);
+}
+
+
+
+
 /*
  * Antialiased RGBA line
  *
@@ -881,7 +929,11 @@ static void aa_rgba_line( GLcontext *ctx,
                           GLuint vert0, GLuint vert1, GLuint pvert )
 {
 #define INTERP_RGBA 1
-#define PLOT(x, y)  { PB_WRITE_RGBA_PIXEL( pb, (x), (y), z, red, green, blue, coverage ); }
+#define PLOT(x, y)                                             \
+   {                                                           \
+      PB_WRITE_RGBA_PIXEL( pb, (x), (y), z,                    \
+                          red, green, blue, coverage );        \
+   }
 #include "lnaatemp.h"
 }
 
@@ -896,11 +948,11 @@ static void aa_tex_rgba_line( GLcontext *ctx,
                               GLuint vert0, GLuint vert1, GLuint pvert )
 {
 #define INTERP_RGBA 1
-#define INTERP_STUV0 1
+#define INTERP_TEX 1
 #define PLOT(x, y)                                                     \
    {                                                                   \
       PB_WRITE_TEX_PIXEL( pb, (x), (y), z, red, green, blue, coverage, \
-                          s, t, u );                                   \
+                 fragTexcoord[0], fragTexcoord[1], fragTexcoord[2] );  \
    }
 #include "lnaatemp.h"
 }
@@ -918,13 +970,12 @@ static void aa_multitex_rgba_line( GLcontext *ctx,
 {
 #define INTERP_RGBA 1
 #define INTERP_SPEC 1
-#define INTERP_STUV0 1
-#define INTERP_STUV1 1
+#define INTERP_MULTITEX 1
 #define PLOT(x, y)                                                     \
    {                                                                   \
       PB_WRITE_MULTITEX_SPEC_PIXEL( pb, (x), (y), z,                   \
             red, green, blue, coverage, specRed, specGreen, specBlue,  \
-            s, t, u, s1, t1, u1 );                                     \
+            fragTexcoord );                                            \
    }
 #include "lnaatemp.h"
 }
@@ -957,13 +1008,68 @@ static void null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv )
 }
 
 
+
+#ifdef DEBUG
+void
+_mesa_print_line_function(GLcontext *ctx)
+{
+   printf("Line Func == ");
+   if (ctx->Driver.LineFunc == flat_ci_line)
+      printf("flat_ci_line\n");
+   else if (ctx->Driver.LineFunc == flat_ci_z_line)
+      printf("flat_ci_z_line\n");
+   else if (ctx->Driver.LineFunc == flat_rgba_line)
+      printf("flat_rgba_line\n");
+   else if (ctx->Driver.LineFunc == flat_rgba_z_line)
+      printf("flat_rgba_z_line\n");
+   else if (ctx->Driver.LineFunc == smooth_ci_line)
+      printf("smooth_ci_line\n");
+   else if (ctx->Driver.LineFunc == smooth_ci_z_line)
+      printf("smooth_ci_z_line\n");
+   else if (ctx->Driver.LineFunc == smooth_rgba_line)
+      printf("smooth_rgba_line\n");
+   else if (ctx->Driver.LineFunc == smooth_rgba_z_line)
+      printf("smooth_rgba_z_line\n");
+   else if (ctx->Driver.LineFunc == general_smooth_ci_line)
+      printf("general_smooth_ci_line\n");
+   else if (ctx->Driver.LineFunc == general_flat_ci_line)
+      printf("general_flat_ci_line\n");
+   else if (ctx->Driver.LineFunc == general_smooth_rgba_line)
+      printf("general_smooth_rgba_line\n");
+   else if (ctx->Driver.LineFunc == general_flat_rgba_line)
+      printf("general_flat_rgba_line\n");
+   else if (ctx->Driver.LineFunc == flat_textured_line)
+      printf("flat_textured_line\n");
+   else if (ctx->Driver.LineFunc == smooth_textured_line)
+      printf("smooth_textured_line\n");
+   else if (ctx->Driver.LineFunc == smooth_multitextured_line)
+      printf("smooth_multitextured_line\n");
+   else if (ctx->Driver.LineFunc == flat_multitextured_line)
+      printf("flat_multitextured_line\n");
+   else if (ctx->Driver.LineFunc == aa_rgba_line)
+      printf("aa_rgba_line\n");
+   else if (ctx->Driver.LineFunc == aa_tex_rgba_line)
+      printf("aa_tex_rgba_line\n");
+   else if (ctx->Driver.LineFunc == aa_multitex_rgba_line)
+      printf("aa_multitex_rgba_line\n");
+   else if (ctx->Driver.LineFunc == aa_ci_line)
+      printf("aa_ci_line\n");
+   else if (ctx->Driver.LineFunc == null_line)
+      printf("null_line\n");
+   else
+      printf("Driver func %p\n", ctx->Driver.PointsFunc);
+}
+#endif
+
+
+
 /*
  * Determine which line drawing function to use given the current
  * rendering context.
  */
 void gl_set_line_function( GLcontext *ctx )
 {
-   GLboolean rgbmode = ctx->Visual->RGBAflag;
+   GLboolean rgbmode = ctx->Visual.RGBAflag;
    /* TODO: antialiased lines */
 
    if (ctx->RenderMode==GL_RENDER) {
@@ -998,7 +1104,10 @@ void gl_set_line_function( GLcontext *ctx )
          if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D
              || ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) {
             /* multi-texture and/or separate specular color */
-            ctx->Driver.LineFunc = smooth_multitextured_line;
+            if (ctx->Light.ShadeModel==GL_SMOOTH)
+               ctx->Driver.LineFunc = smooth_multitextured_line;
+            else
+               ctx->Driver.LineFunc = flat_multitextured_line;
          }
          else {
             if (ctx->Light.ShadeModel==GL_SMOOTH) {
@@ -1064,5 +1173,6 @@ void gl_set_line_function( GLcontext *ctx )
       /* GL_SELECT mode */
       ctx->Driver.LineFunc = gl_select_line;
    }
-}
 
+   /*_mesa_print_line_function(ctx);*/
+}