more work on GL_ARB_texture_compression
[mesa.git] / src / mesa / main / lines.c
index 199686f60f33183f712e50a8b56b6f8eba4da1aa..28f9e38fbf530e2aff1b00c12754ad8f58b23fb7 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: lines.c,v 1.6 1999/11/11 01:22:27 brianp Exp $ */
+/* $Id: lines.c,v 1.10 2000/05/10 22:36:05 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -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);
    }
 }
 
@@ -71,6 +73,9 @@ _mesa_LineStipple( GLint factor, GLushort pattern )
    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 );
 }
 
 
@@ -111,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);
 }
 
@@ -136,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);
 }
 
@@ -164,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);
 }
 
@@ -190,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);
 }
 
@@ -222,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
 
@@ -250,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
@@ -282,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
@@ -314,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
@@ -353,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
@@ -425,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) {
@@ -493,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
@@ -585,7 +562,7 @@ static void general_flat_rgba_line( GLcontext *ctx,
    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] );
+   PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] );
    count = ctx->PB->count;
 
    if (ctx->Line.StippleFlag) {
@@ -654,7 +631,7 @@ 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) {
@@ -717,6 +694,8 @@ 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
@@ -794,6 +773,8 @@ static void smooth_multitextured_line( GLcontext *ctx,
    GLubyte (*pbspec)[3] = ctx->PB->spec;
    (void) pvert;
 
+   ctx->PB->mono = GL_FALSE;
+
    if (ctx->Line.StippleFlag) {
       /* stippled */
 #define INTERP_XY 1
@@ -1024,8 +1005,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
@@ -1040,8 +1020,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