head	3.23;
access;
symbols
	merge-1:3.19.2.2
	autoconf:3.19.0.4
	experimental-1:3.19.0.2
	mesa-3-1-with-kw3:3.18
	mesa-3-1-prior-to-kw3:3.17;
locks; strict;
comment	@ * @;


3.23
date	99.07.23.00.59.23;	author brianp;	state Exp;
branches;
next	3.22;

3.22
date	99.07.21.01.28.52;	author brianp;	state Exp;
branches;
next	3.21;

3.21
date	99.07.20.00.47.10;	author brianp;	state Exp;
branches;
next	3.20;

3.20
date	99.07.12.12.05.24;	author keithw;	state Exp;
branches;
next	3.19;

3.19
date	99.03.31.20.18.39;	author keithw;	state Exp;
branches
	3.19.2.1;
next	3.18;

3.18
date	99.02.25.14.12.31;	author keithw;	state Exp;
branches;
next	3.17;

3.17
date	99.02.24.22.48.06;	author jens;	state Exp;
branches;
next	3.16;

3.16
date	99.02.14.03.46.34;	author brianp;	state Exp;
branches;
next	3.15;

3.15
date	98.12.01.02.41.44;	author brianp;	state Exp;
branches;
next	3.14;

3.14
date	98.11.08.22.34.07;	author brianp;	state Exp;
branches;
next	3.13;

3.13
date	98.11.03.01.16.57;	author brianp;	state Exp;
branches;
next	3.12;

3.12
date	98.07.08.01.03.28;	author brianp;	state Exp;
branches;
next	3.11;

3.11
date	98.06.18.02.38.45;	author brianp;	state Exp;
branches;
next	3.10;

3.10
date	98.06.18.01.51.07;	author brianp;	state Exp;
branches;
next	3.9;

3.9
date	98.06.17.04.08.38;	author brianp;	state Exp;
branches;
next	3.8;

3.8
date	98.06.17.01.18.14;	author brianp;	state Exp;
branches;
next	3.7;

3.7
date	98.06.17.01.15.10;	author brianp;	state Exp;
branches;
next	3.6;

3.6
date	98.06.11.01.58.40;	author brianp;	state Exp;
branches;
next	3.5;

3.5
date	98.06.09.03.23.55;	author brianp;	state Exp;
branches;
next	3.4;

3.4
date	98.06.07.22.18.52;	author brianp;	state Exp;
branches;
next	3.3;

3.3
date	98.04.13.23.30.08;	author brianp;	state Exp;
branches;
next	3.2;

3.2
date	98.03.27.04.17.52;	author brianp;	state Exp;
branches;
next	3.1;

3.1
date	98.02.04.00.44.29;	author brianp;	state Exp;
branches;
next	3.0;

3.0
date	98.01.31.20.55.24;	author brianp;	state Exp;
branches;
next	;

3.19.2.1
date	99.05.21.21.29.26;	author keithw;	state Exp;
branches;
next	3.19.2.2;

3.19.2.2
date	99.06.19.15.04.14;	author keithw;	state Exp;
branches;
next	;


desc
@line drawing functions
@


3.23
log
@clean-up
@
text
@/* $Id: lines.c,v 3.22 1999/07/21 01:28:52 brianp Exp $ */

/*
 * Mesa 3-D graphics library
 * Version:  3.1
 * 
 * Copyright (C) 1999  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
 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 * 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.
 */





#ifdef PC_HEADER
#include "all.h"
#else
#include <assert.h>
#include "context.h"
#include "depth.h"
#include "feedback.h"
#include "lines.h"
#include "macros.h"
#include "mmath.h"
#include "pb.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 )
{
   if (width<=0.0) {
      gl_error( ctx, GL_INVALID_VALUE, "glLineWidth" );
      return;
   }
   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLineWidth");
   
   if (ctx->Line.Width != width) {
      ctx->Line.Width = width;
      ctx->TriangleCaps &= ~DD_LINE_WIDTH;
      if (width != 1.0) ctx->TriangleCaps |= DD_LINE_WIDTH;
      ctx->NewState |= NEW_RASTER_OPS;
   }
}



void gl_LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
{
   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glLineStipple");
   ctx->Line.StippleFactor = CLAMP( factor, 1, 256 );
   ctx->Line.StipplePattern = pattern;
   ctx->NewState |= NEW_RASTER_OPS;
}



/**********************************************************************/
/*****                    Rasterization                           *****/
/**********************************************************************/


/*
 * There are 4 pairs (RGBA, CI) of line drawing functions:
 *   1. simple:  width=1 and no special rasterization functions (fastest)
 *   2. flat:  width=1, non-stippled, flat-shaded, any raster operations
 *   3. smooth:  width=1, non-stippled, smooth-shaded, any raster operations
 *   4. general:  any other kind of line (slowest)
 */


/*
 * All line drawing functions have the same arguments:
 * v1, v2 - indexes of first and second endpoints into vertex buffer arrays
 * pv     - provoking vertex: which vertex color/index to use for flat shading.
 */



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 );
}



#if MAX_WIDTH > MAX_HEIGHT
#  define MAXPOINTS MAX_WIDTH
#else
#  define MAXPOINTS MAX_HEIGHT
#endif


/* Flat, color index line */
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;

#define INTERP_XY 1

#define PLOT(X,Y)		\
	pbx[count] = X;		\
	pby[count] = Y;		\
	count++;

#include "linetemp.h"

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}



/* Flat, color index line with Z interpolation/testing */
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;

#define INTERP_XY 1
#define INTERP_Z 1

#define PLOT(X,Y)		\
	pbx[count] = X;		\
	pby[count] = Y;		\
	pbz[count] = Z;		\
	count++;

#include "linetemp.h"

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}



/* Flat-shaded, RGBA line */
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;

#define INTERP_XY 1

#define PLOT(X,Y)		\
	pbx[count] = X;		\
	pby[count] = Y;		\
	count++;

#include "linetemp.h"

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}



/* Flat-shaded, RGBA line with Z interpolation/testing */
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;

#define INTERP_XY 1
#define INTERP_Z 1

#define PLOT(X,Y)	\
	pbx[count] = X;	\
	pby[count] = Y;	\
	pbz[count] = Z;	\
	count++;

#include "linetemp.h"

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}



/* Smooth shaded, color index line */
static void smooth_ci_line( GLcontext *ctx,
                            GLuint vert0, GLuint vert1, GLuint pvert )
{
   GLint count = ctx->PB->count;
   GLint *pbx = ctx->PB->x;
   GLint *pby = ctx->PB->y;
   GLuint *pbi = ctx->PB->i;
   (void) pvert;

#define INTERP_XY 1
#define INTERP_INDEX 1

#define PLOT(X,Y)		\
	pbx[count] = X;		\
	pby[count] = Y;		\
	pbi[count] = I;		\
	count++;

#include "linetemp.h"

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}



/* Smooth shaded, color index line with Z interpolation/testing */
static void smooth_ci_z_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;
   GLuint *pbi = ctx->PB->i;
   (void) pvert;

#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_INDEX 1

#define PLOT(X,Y)		\
	pbx[count] = X;		\
	pby[count] = Y;		\
	pbz[count] = Z;		\
	pbi[count] = I;		\
	count++;

#include "linetemp.h"

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}



/* Smooth-shaded, RGBA line */
static void smooth_rgba_line( GLcontext *ctx,
                       	      GLuint vert0, GLuint vert1, GLuint pvert )
{
   GLint count = ctx->PB->count;
   GLint *pbx = ctx->PB->x;
   GLint *pby = ctx->PB->y;
   GLubyte (*pbrgba)[4] = ctx->PB->rgba;
   (void) pvert;

#define INTERP_XY 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1

#define PLOT(X,Y)			\
	pbx[count] = X;			\
	pby[count] = Y;			\
	pbrgba[count][RCOMP] = FixedToInt(r0);	\
	pbrgba[count][GCOMP] = FixedToInt(g0);	\
	pbrgba[count][BCOMP] = FixedToInt(b0);	\
	pbrgba[count][ACOMP] = FixedToInt(a0);	\
	count++;

#include "linetemp.h"

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}



/* Smooth-shaded, RGBA line with Z interpolation/testing */
static void smooth_rgba_z_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;
   (void) pvert;

#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1

#define PLOT(X,Y)			\
	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);	\
	count++;

#include "linetemp.h"

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}


#define CHECK_FULL(count)			\
	if (count >= PB_SIZE-MAX_WIDTH) {	\
	   ctx->PB->count = count;		\
	   gl_flush_pb(ctx);			\
	   count = ctx->PB->count;		\
	}



/* Smooth shaded, color index, any width, maybe stippled */
static void general_smooth_ci_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;
   GLuint *pbi = ctx->PB->i;
   (void) pvert;

   if (ctx->Line.StippleFlag) {
      /* stippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_INDEX 1
#define WIDE 1
#define STIPPLE 1
#define PLOT(X,Y)		\
	pbx[count] = X;		\
	pby[count] = Y;		\
	pbz[count] = Z;		\
	pbi[count] = I;		\
	count++;		\
	CHECK_FULL(count);
#include "linetemp.h"
   }
   else {
      /* unstippled */
      if (ctx->Line.Width==2.0F) {
         /* special case: unstippled and width=2 */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_INDEX 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;	\
	pbi[count] = I;  pbi[count+1] = I;	\
	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;	\
	pbi[count] = I;  pbi[count+1] = I;	\
	count += 2;				\
	CHECK_FULL(count);
#include "linetemp.h"
      }
      else {
         /* unstippled, any width */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_INDEX 1
#define WIDE 1
#define PLOT(X,Y)		\
	pbx[count] = X;		\
	pby[count] = Y;		\
	pbz[count] = Z;		\
	pbi[count] = I;		\
	count++;		\
	CHECK_FULL(count);
#include "linetemp.h"
      }
   }

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}


/* Flat shaded, color index, any width, maybe stippled */
static void general_flat_ci_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;

   if (ctx->Line.StippleFlag) {
      /* stippled, any width */
#define INTERP_XY 1
#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);
#include "linetemp.h"
   }
   else {
      /* unstippled */
      if (ctx->Line.Width==2.0F) {
         /* 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);
#include "linetemp.h"
      }
      else {
         /* unstippled, any width */
#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);
#include "linetemp.h"
      }
   }

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}



static void general_smooth_rgba_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;
   (void) pvert;

   if (ctx->Line.StippleFlag) {
      /* stippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define WIDE 1
#define STIPPLE 1
#define PLOT(X,Y)				\
	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);	\
	count++;				\
	CHECK_FULL(count);
#include "linetemp.h"
   }
   else {
      /* unstippled */
      if (ctx->Line.Width==2.0F) {
         /* special case: unstippled and width=2 */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_ALPHA 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;		\
	pbrgba[count][RCOMP] = FixedToInt(r0);		\
	pbrgba[count][GCOMP] = FixedToInt(g0);		\
	pbrgba[count][BCOMP] = FixedToInt(b0);		\
	pbrgba[count][ACOMP] = FixedToInt(a0);		\
	pbrgba[count+1][RCOMP] = FixedToInt(r0);	\
	pbrgba[count+1][GCOMP] = FixedToInt(g0);	\
	pbrgba[count+1][BCOMP] = FixedToInt(b0);	\
	pbrgba[count+1][ACOMP] = FixedToInt(a0);	\
	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;		\
	pbrgba[count][RCOMP] = FixedToInt(r0);		\
	pbrgba[count][GCOMP] = FixedToInt(g0);		\
	pbrgba[count][BCOMP] = FixedToInt(b0);		\
	pbrgba[count][ACOMP] = FixedToInt(a0);		\
	pbrgba[count+1][RCOMP] = FixedToInt(r0);	\
	pbrgba[count+1][GCOMP] = FixedToInt(g0);	\
	pbrgba[count+1][BCOMP] = FixedToInt(b0);	\
	pbrgba[count+1][ACOMP] = FixedToInt(a0);	\
	count += 2;					\
	CHECK_FULL(count);
#include "linetemp.h"
      }
      else {
         /* unstippled, any width */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define WIDE 1
#define PLOT(X,Y)				\
	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);	\
	count++;				\
	CHECK_FULL(count);
#include "linetemp.h"
      }
   }

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}


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;

   if (ctx->Line.StippleFlag) {
      /* stippled */
#define INTERP_XY 1
#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);
#include "linetemp.h"
   }
   else {
      /* unstippled */
      if (ctx->Line.Width==2.0F) {
         /* 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);
#include "linetemp.h"
      }
      else {
         /* unstippled, any width */
#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);
#include "linetemp.h"
      }
   }

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}


/* Flat-shaded, textured, any width, maybe stippled */
static void flat_textured_line( GLcontext *ctx,
                                GLuint vert0, GLuint vert1, GLuint pv )
{
   GLint count;
   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];
   GLubyte *color = ctx->VB->ColorPtr->data[pv];
   PB_SET_COLOR( ctx, 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 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;		\
	   count++;			\
	   CHECK_FULL(count);		\
	}
#include "linetemp.h"
   }
   else {
      /* unstippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_STUV0 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;		\
	   count++;			\
	   CHECK_FULL(count);		\
	}
#include "linetemp.h"
   }

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}



/* Smooth-shaded, textured, any width, maybe stippled */
static void smooth_textured_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;
   GLfloat *pbs = ctx->PB->s[0];
   GLfloat *pbt = ctx->PB->t[0];
   GLfloat *pbu = ctx->PB->u[0];
   GLubyte (*pbrgba)[4] = ctx->PB->rgba;
   (void) pvert;

   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 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;				\
	   pbrgba[count][RCOMP] = FixedToInt(r0);	\
	   pbrgba[count][GCOMP] = FixedToInt(g0);	\
	   pbrgba[count][BCOMP] = FixedToInt(b0);	\
	   pbrgba[count][ACOMP] = FixedToInt(a0);	\
	   count++;					\
	   CHECK_FULL(count);				\
	}
#include "linetemp.h"
   }
   else {
      /* unstippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define INTERP_STUV0 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;				\
	   pbrgba[count][RCOMP] = FixedToInt(r0);	\
	   pbrgba[count][GCOMP] = FixedToInt(g0);	\
	   pbrgba[count][BCOMP] = FixedToInt(b0);	\
	   pbrgba[count][ACOMP] = FixedToInt(a0);	\
	   count++;					\
	   CHECK_FULL(count);				\
	}
#include "linetemp.h"
   }

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}


/* Smooth-shaded, multitextured, any width, maybe stippled, separate specular
 * color interpolation.
 */
static void smooth_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;
   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;

   if (ctx->Line.StippleFlag) {
      /* stippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_SPEC 1
#define INTERP_ALPHA 1
#define INTERP_STUV0 1
#define INTERP_STUV1 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);				\
	}
#include "linetemp.h"
   }
   else {
      /* unstippled */
#define INTERP_XY 1
#define INTERP_Z 1
#define INTERP_RGB 1
#define INTERP_SPEC 1
#define INTERP_ALPHA 1
#define INTERP_STUV0 1
#define INTERP_STUV1 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);				\
	}
#include "linetemp.h"
   }

   ctx->PB->count = count;
   PB_CHECK_FLUSH( ctx, ctx->PB );
}


/*
 * Antialiased RGBA line
 *
 * This AA line function isn't terribly efficient but it's pretty
 * straight-forward to understand.  Also, it doesn't exactly conform
 * to the specification.
 */
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 ); }
#include "lnaatemp.h"
}

/*
 * Antialiased Textured RGBA line
 *
 * This AA line function isn't terribly efficient but it's pretty
 * straight-forward to understand.  Also, it doesn't exactly conform
 * to the specification.
 */
static void aa_tex_rgba_line( GLcontext *ctx,
                              GLuint vert0, GLuint vert1, GLuint pvert )
{
#define INTERP_RGBA 1
#define INTERP_STUV0 1
#define PLOT(x, y)							\
   {									\
      PB_WRITE_TEX_PIXEL( pb, (x), (y), z, red, green, blue, coverage,	\
                          s, t, u );					\
   }
#include "lnaatemp.h"
}


/*
 * Antialiased Multitextured RGBA line
 *
 * This AA line function isn't terribly efficient but it's pretty
 * straight-forward to understand.  Also, it doesn't exactly conform
 * to the specification.
 */
static void aa_multitex_rgba_line( GLcontext *ctx,
                                   GLuint vert0, GLuint vert1, GLuint pvert )
{
#define INTERP_RGBA 1
#define INTERP_SPEC 1
#define INTERP_STUV0 1
#define INTERP_STUV1 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 );					\
   }
#include "lnaatemp.h"
}


/*
 * Antialiased CI line.  Same comments for RGBA antialiased lines apply.
 */
static void aa_ci_line( GLcontext *ctx,
                        GLuint vert0, GLuint vert1, GLuint pvert )
{
#define INTERP_INDEX 1
#define PLOT(x, y)						\
   {								\
      PB_WRITE_CI_PIXEL( pb, (x), (y), z, index + coverage );	\
   }
#include "lnaatemp.h"
}


/*
 * Null rasterizer for measuring transformation speed.
 */
static void null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv )
{
   (void) ctx;
   (void) v1;
   (void) v2;
   (void) pv;
}


/*
 * Determine which line drawing function to use given the current
 * rendering context.
 */
void gl_set_line_function( GLcontext *ctx )
{
   GLboolean rgbmode = ctx->Visual->RGBAflag;
   /* TODO: antialiased lines */

   if (ctx->RenderMode==GL_RENDER) {
      if (ctx->NoRaster) {
         ctx->Driver.LineFunc = null_line;
         return;
      }
      if (ctx->Driver.LineFunc) {
         /* Device driver will draw lines. */
	 return;
      }

      if (ctx->Line.SmoothFlag) {
         /* antialiased lines */
         if (rgbmode) {
            if (ctx->Texture.ReallyEnabled) {
               if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D
                  || ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
                  /* Multitextured! */
                  ctx->Driver.LineFunc = aa_multitex_rgba_line;
               else
                  ctx->Driver.LineFunc = aa_tex_rgba_line;
            } else {
               ctx->Driver.LineFunc = aa_rgba_line;
            }
         }
         else {
            ctx->Driver.LineFunc = aa_ci_line;
         }
      }
      else if (ctx->Texture.ReallyEnabled) {
         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;
         }
         else {
            if (ctx->Light.ShadeModel==GL_SMOOTH) {
                ctx->Driver.LineFunc = smooth_textured_line;
            }
            else {
                ctx->Driver.LineFunc = flat_textured_line;
            }
         }
      }
      else if (ctx->Line.Width!=1.0 || ctx->Line.StippleFlag
               || ctx->Line.SmoothFlag) {
         if (ctx->Light.ShadeModel==GL_SMOOTH) {
            if (rgbmode)
               ctx->Driver.LineFunc = general_smooth_rgba_line;
            else
               ctx->Driver.LineFunc = general_smooth_ci_line;
         }
         else {
            if (rgbmode)
               ctx->Driver.LineFunc = general_flat_rgba_line;
            else
               ctx->Driver.LineFunc = general_flat_ci_line;
         }
      }
      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 (rgbmode)
                  ctx->Driver.LineFunc = smooth_rgba_z_line;
               else
                  ctx->Driver.LineFunc = smooth_ci_z_line;
            }
            else {
               if (rgbmode)
                  ctx->Driver.LineFunc = smooth_rgba_line;
               else
                  ctx->Driver.LineFunc = smooth_ci_line;
            }
	 }
         else {
	    /* Width==1, non-stippled, flat-shaded */
            if (ctx->Depth.Test
                || (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) {
               if (rgbmode)
                  ctx->Driver.LineFunc = flat_rgba_z_line;
               else
                  ctx->Driver.LineFunc = flat_ci_z_line;
            }
            else {
               if (rgbmode)
                  ctx->Driver.LineFunc = flat_rgba_line;
               else
                  ctx->Driver.LineFunc = flat_ci_line;
            }
         }
      }
   }
   else if (ctx->RenderMode==GL_FEEDBACK) {
      ctx->Driver.LineFunc = feedback_line;
   }
   else {
      /* GL_SELECT mode */
      ctx->Driver.LineFunc = select_line;
   }
}

@


3.22
log
@added separate specular antialiased line support
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.21 1999/07/20 00:47:10 brianp Exp $ */
d743 1
a743 1
#define INTERP_STUV 1
a747 1
	   GLfloat invQ = 1.0F / hv0;	\
d751 3
a753 3
	   pbs[count] = hs0 * invQ;	\
	   pbt[count] = ht0 * invQ;	\
	   pbu[count] = hu0 * invQ;	\
d763 1
a763 1
#define INTERP_STUV 1
a766 1
	   GLfloat invQ = 1.0F / hv0;	\
d770 3
a772 3
	   pbs[count] = hs0 * invQ;	\
	   pbt[count] = ht0 * invQ;	\
	   pbu[count] = hu0 * invQ;	\
d805 1
a805 1
#define INTERP_STUV 1
a809 1
	   GLfloat invQ = 1.0F / hv0;			\
d813 3
a815 3
	   pbs[count] = hs0 * invQ;			\
	   pbt[count] = ht0 * invQ;			\
	   pbu[count] = hu0 * invQ;			\
d831 1
a831 1
#define INTERP_STUV 1
a834 1
	   GLfloat invQ = 1.0F / hv0;			\
d838 3
a840 3
	   pbs[count] = hs0 * invQ;			\
	   pbt[count] = ht0 * invQ;			\
	   pbu[count] = hu0 * invQ;			\
d883 1
a883 1
#define INTERP_STUV 1
a888 2
	   GLfloat invQ = 1.0F / hv0;			\
	   GLfloat invQ1 = 1.0F / hv01;			\
d892 6
a897 6
	   pbs[count] = hs0 * invQ;			\
	   pbt[count] = ht0 * invQ;			\
	   pbu[count] = hu0 * invQ;			\
	   pbs1[count] = hs01 * invQ1;			\
	   pbt1[count] = ht01 * invQ1;			\
	   pbu1[count] = hu01 * invQ1;			\
d917 1
a917 1
#define INTERP_STUV 1
a921 2
	   GLfloat invQ = 1.0F / hv0;			\
	   GLfloat invQ1 = 1.0F / hv01;			\
d925 6
a930 6
	   pbs[count] = hs0 * invQ;			\
	   pbt[count] = ht0 * invQ;			\
	   pbu[count] = hu0 * invQ;			\
	   pbs1[count] = hs01 * invQ1;			\
	   pbt1[count] = ht01 * invQ1;			\
	   pbu1[count] = hu01 * invQ1;			\
d976 5
a980 1
#define PLOT(x, y)  { PB_WRITE_TEX_PIXEL( pb, (x), (y), z, red, green, blue, coverage, s, t, u ); }
d999 6
a1004 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 ); }
d1016 4
a1019 1
#define PLOT(x, y)  { PB_WRITE_CI_PIXEL( pb, (x), (y), z, index + coverage ); }
@


3.21
log
@added separate specular color support
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.20 1999/07/12 12:05:24 keithw Exp $ */
d983 1
a983 1
#define INTERP_STUV 1
d1000 2
a1001 1
#define INTERP_STUV 1
d1003 1
a1003 1
#define PLOT(x, y)  { PB_WRITE_MULTITEX_PIXEL( pb, (x), (y), z, red, green, blue, coverage, s, t, u, s1, t1, u1 ); }
d1055 2
a1056 1
               if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D)
@


3.20
log
@merge from experimental branch upto merge-1 tag
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.19.2.2 1999/06/19 15:04:14 keithw Exp $ */
d860 3
a862 1
/* Smooth-shaded, multitextured, any width, maybe stippled */
d864 1
a864 1
                                       GLuint vert0, GLuint vert1, GLuint pvert )
d877 1
d885 1
d908 3
d921 1
d943 3
d1068 3
a1070 1
         if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
d1083 1
a1083 1
               || ctx->Line.SmoothFlag || ctx->Texture.ReallyEnabled) {
@


3.19
log
@Compiled vertex arrays
@
text
@d1 1
a1 1
/* $Id: lines.c,v 1.3 1999/02/25 23:50:21 keithw Exp $ */
d59 7
a65 3

   ctx->Line.Width = width;
   ctx->NewState |= NEW_RASTER_OPS;
@


3.19.2.1
log
@Quake3 inspired optimizations
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.19 1999/03/31 20:18:39 keithw Exp $ */
a1031 1
	 ctx->IndirectTriangles &= ~DD_LINE_SW_RASTERIZE;
@


3.19.2.2
log
@Removed SGIS multitexture, added FX/X86 assm directory
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.19.2.1 1999/05/21 21:29:26 keithw Exp $ */
d59 3
a61 7
   
   if (ctx->Line.Width != width) {
      ctx->Line.Width = width;
      ctx->TriangleCaps &= ~DD_LINE_WIDTH;
      if (width != 1.0) ctx->TriangleCaps |= DD_LINE_WIDTH;
      ctx->NewState |= NEW_RASTER_OPS;
   }
d1032 1
@


3.18
log
@Merged in kw3 patch
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.17 1999/02/24 22:48:06 jens Exp $ */
@


3.17
log
@Added header file to get XMesa to compile standalone and inside XFree86
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.16 1999/02/14 03:46:34 brianp Exp $ */
d28 1
a28 54
/*
 * $Log: lines.c,v $
 * Revision 3.16  1999/02/14 03:46:34  brianp
 * new copyright
 *
 * Revision 3.15  1998/12/01 02:41:44  brianp
 * patched per MJK for multi-textured, antialiased lines
 *
 * Revision 3.14  1998/11/08 22:34:07  brianp
 * renamed texture sets to texture units
 *
 * Revision 3.13  1998/11/03 01:16:57  brianp
 * added Texture.ReallyEnabled to simply testing for enabled textures
 *
 * Revision 3.12  1998/07/08 01:03:28  brianp
 * removed some unused variables
 *
 * Revision 3.11  1998/06/18 02:38:45  brianp
 * re-implemented INTERP_STUV code for textured lines
 *
 * Revision 3.10  1998/06/18 01:51:07  brianp
 * more work on AA texture coordinate interpolation
 *
 * Revision 3.9  1998/06/17 04:08:38  brianp
 * textured, AA lines didn't interpolate texture coords correctly
 *
 * Revision 3.8  1998/06/17 01:18:14  brianp
 * textured, AA lines test was backward (Marten Stromberg)
 *
 * Revision 3.7  1998/06/17 01:15:10  brianp
 * include assert.h
 *
 * Revision 3.6  1998/06/11 01:58:40  brianp
 * separate textured and non-textured AA line functions
 *
 * Revision 3.5  1998/06/09 03:23:55  brianp
 * implemented antialiased lines
 *
 * Revision 3.4  1998/06/07 22:18:52  brianp
 * implemented GL_EXT_multitexture extension
 *
 * Revision 3.3  1998/04/13 23:30:08  brianp
 * fixed PB overflow bug (Randy Frank)
 *
 * Revision 3.2  1998/03/27 04:17:52  brianp
 * fixed G++ warnings
 *
 * Revision 3.1  1998/02/04 00:44:29  brianp
 * fixed casts and conditional expression problems for Amiga StormC compiler
 *
 * Revision 3.0  1998/01/31 20:55:24  brianp
 * initial rev
 *
 */
d40 1
d58 2
a59 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glLineWidth" );
      return;
   }
d68 1
a68 4
   if (INSIDE_BEGIN_END(ctx)) {
      gl_error( ctx, GL_INVALID_OPERATION, "glLineStipple" );
      return;
   }
d106 40
a145 20
   x1 = VB->Win[v1][0];
   y1 = VB->Win[v1][1];
   z1 = VB->Win[v1][2] / DEPTH_SCALE;
   w1 = VB->Clip[v1][3];

   x2 = VB->Win[v2][0];
   y2 = VB->Win[v2][1];
   z2 = VB->Win[v2][2] / DEPTH_SCALE;
   w2 = VB->Clip[v2][3];

   invq = (VB->MultiTexCoord[texUnit][v1][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v1][3]);
   tex1[0] = VB->MultiTexCoord[texUnit][v1][0] * invq;
   tex1[1] = VB->MultiTexCoord[texUnit][v1][1] * invq;
   tex1[2] = VB->MultiTexCoord[texUnit][v1][2] * invq;
   tex1[3] = VB->MultiTexCoord[texUnit][v1][3];
   invq = (VB->MultiTexCoord[texUnit][v2][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v2][3]);
   tex2[0] = VB->MultiTexCoord[texUnit][v2][0] * invq;
   tex2[1] = VB->MultiTexCoord[texUnit][v2][1] * invq;
   tex2[2] = VB->MultiTexCoord[texUnit][v2][2] * invq;
   tex2[3] = VB->MultiTexCoord[texUnit][v2][3];
d156 6
a161 9
      /* convert color from integer to a float in [0,1] */
      color[0] = (GLfloat) VB->Color[pv][0] * (1.0F / 255.0F);
      color[1] = (GLfloat) VB->Color[pv][1] * (1.0F / 255.0F);
      color[2] = (GLfloat) VB->Color[pv][2] * (1.0F / 255.0F);
      color[3] = (GLfloat) VB->Color[pv][3] * (1.0F / 255.0F);
      gl_feedback_vertex( ctx, x1,y1,z1,w1, color,
                          (GLfloat) VB->Index[pv], tex1 );
      gl_feedback_vertex( ctx, x2,y2,z2,w2, color,
                          (GLfloat) VB->Index[pv], tex2 );
d172 2
a173 2
   gl_update_hitflag( ctx, ctx->VB->Win[v1][2] / DEPTH_SCALE );
   gl_update_hitflag( ctx, ctx->VB->Win[v2][2] / DEPTH_SCALE );
d192 1
a192 1
   PB_SET_INDEX( ctx, ctx->PB, ctx->VB->Index[pvert] );
d218 1
a218 1
   PB_SET_INDEX( ctx, ctx->PB, ctx->VB->Index[pvert] );
d245 1
a245 1
   GLubyte *color = ctx->VB->Color[pvert];
d272 1
a272 1
   GLubyte *color = ctx->VB->Color[pvert];
d503 1
a503 1
   PB_SET_INDEX( ctx, ctx->PB, ctx->VB->Index[pvert] );
d662 1
a662 1
   GLubyte *color = ctx->VB->Color[pvert];
d731 1
a731 1
   GLubyte *color = ctx->VB->Color[pv];
d973 1
d991 1
d1032 1
a1032 1
         ctx->Driver.LineFunc = ctx->Driver.LineFunc;
d1034 2
a1035 1
      else if (ctx->Line.SmoothFlag) {
@


3.16
log
@new copyright
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.15 1998/12/01 02:41:44 brianp Exp brianp $ */
d30 3
d97 3
@


3.15
log
@patched per MJK for multi-textured, antialiased lines
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.14 1998/11/08 22:34:07 brianp Exp $ */
d6 19
a24 15
 * Copyright (C) 1995-1998  Brian Paul
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
d30 3
@


3.14
log
@renamed texture sets to texture units
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.13 1998/11/03 01:16:57 brianp Exp brianp $ */
d5 1
a5 1
 * Version:  3.0
d26 3
a746 1

d755 3
a757 3
   GLfloat *pbs = ctx->PB->s;
   GLfloat *pbt = ctx->PB->t;
   GLfloat *pbu = ctx->PB->u;
d818 3
a820 3
   GLfloat *pbs = ctx->PB->s;
   GLfloat *pbt = ctx->PB->t;
   GLfloat *pbu = ctx->PB->u;
d883 85
d979 3
a981 183
   struct vertex_buffer *VB = ctx->VB;
   struct pixel_buffer *pb = ctx->PB;
   GLfloat halfWidth = 0.5F * ctx->Line.Width;  /* 0.5 is a bit of a hack */
   GLboolean solid = !ctx->Line.StippleFlag;
   GLint x0 = (GLint) VB->Win[vert0][0], x1 = (GLint) VB->Win[vert1][0];
   GLint y0 = (GLint) VB->Win[vert0][1], y1 = (GLint) VB->Win[vert1][1];
   GLint dx = x1 - x0;
   GLint dy = y1 - y0;
   GLint xStep, yStep;
   GLint z0, z1;
   GLfixed fr, fg, fb, fa;      /* fixed-pt RGBA */
   GLfixed dfr, dfg, dfb, dfa;  /* fixed-pt RGBA deltas */

   if (dx == 0 && dy == 0)
      return;

#if DEPTH_BITS==16
   z0 = FloatToFixed(VB->Win[vert0][2]);
   z1 = FloatToFixed(VB->Win[vert1][2]);
#else
   z0 = (int) VB->Win[vert0][2];
   z1 = (int) VB->Win[vert1][2];
#endif

   if (ctx->Light.ShadeModel == GL_SMOOTH) {
      fr = IntToFixed(VB->Color[vert0][0]);
      fg = IntToFixed(VB->Color[vert0][1]);
      fb = IntToFixed(VB->Color[vert0][2]);
      fa = IntToFixed(VB->Color[vert0][3]);
   }
   else {
      fr = IntToFixed(VB->Color[pvert][0]);
      fg = IntToFixed(VB->Color[pvert][1]);
      fb = IntToFixed(VB->Color[pvert][2]);
      fa = IntToFixed(VB->Color[pvert][3]);
      dfr = dfg = dfb = dfa = 0;
   }

   if (dx < 0) {
      xStep = -1;
      dx = -dx;
   }
   else {
      xStep = 1;
   }

   if (dy < 0) {
      yStep = -1;
      dy = -dy;
   }
   else {
      yStep = 1;
   }

   if (dx > dy) {
      /* X-major line */
      GLint i;
      GLint x = x0;
      GLfloat y = VB->Win[vert0][1];
      GLfloat yStep = (VB->Win[vert1][1] - y) / (GLfloat) dx;
      GLint dz = (z1 - z0) / dx;
      if (ctx->Light.ShadeModel == GL_SMOOTH) {
         dfr = (IntToFixed(VB->Color[vert1][0]) - fr) / dx;
         dfg = (IntToFixed(VB->Color[vert1][1]) - fg) / dx;
         dfb = (IntToFixed(VB->Color[vert1][2]) - fb) / dx;
         dfa = (IntToFixed(VB->Color[vert1][3]) - fa) / dx;
      }
      for (i = 0; i < dx; i++) {
         if (solid || (ctx->Line.StipplePattern & (1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf)))) {

            GLfloat yTop = y + halfWidth;
            GLfloat yBot = y - halfWidth;
            GLint yTopi = (GLint) yTop;
            GLint yBoti = (GLint) yBot;
            GLint iy;
            GLint coverage;
            GLubyte red   = FixedToInt(fr);
            GLubyte green = FixedToInt(fg);
            GLubyte blue  = FixedToInt(fb);
            GLubyte alpha = FixedToInt(fa);
#if DEPTH_BITS==16
            GLdepth z = FixedToInt(z0);
#else
            GLdepth z = z0;
#endif
            ASSERT(yBoti < yTopi);

            {
               /* bottom pixel of swipe */
               coverage = (GLint) (alpha * (1.0F - (yBot - yBoti)));
               PB_WRITE_RGBA_PIXEL( pb, x, yBoti, z, red, green, blue, coverage );
               yBoti++;

               /* top pixel of swipe */
               coverage = (GLint) (alpha * (yTop - yTopi));
               PB_WRITE_RGBA_PIXEL( pb, x, yTopi, z, red, green, blue, coverage );
               yTopi--;

               /* pixels between top and bottom with 100% coverage */
               for (iy = yBoti; iy <= yTopi; iy++) {
                  PB_WRITE_RGBA_PIXEL( pb, x, iy, z, red, green, blue, alpha );
               }
            }

            PB_CHECK_FLUSH( ctx, pb );

         } /* if stippling */

         x += xStep;
         y += yStep;
         z0 += dz;
         fr += dfr;
         fg += dfg;
         fb += dfb;
         fa += dfa;
         if (!solid)
            ctx->StippleCounter++;
      }
   }
   else {
      /* Y-major line */
      GLint i;
      GLint y = y0;
      GLfloat x = VB->Win[vert0][0];
      GLfloat xStep = (VB->Win[vert1][0] - x) / (GLfloat) dy;
      GLint dz = (z1 - z0) / dy;
      if (ctx->Light.ShadeModel == GL_SMOOTH) {
         dfr = (IntToFixed(VB->Color[vert1][0]) - fr) / dy;
         dfg = (IntToFixed(VB->Color[vert1][1]) - fg) / dy;
         dfb = (IntToFixed(VB->Color[vert1][2]) - fb) / dy;
         dfa = (IntToFixed(VB->Color[vert1][3]) - fa) / dy;
      }
      for (i = 0; i < dy; i++) {
         if (solid || (ctx->Line.StipplePattern & (1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf)))) {
            GLfloat xRight = x + halfWidth;
            GLfloat xLeft = x - halfWidth;
            GLint xRighti = (GLint) xRight;
            GLint xLefti = (GLint) xLeft;
            GLint ix;
            GLint coverage;
            GLubyte red   = FixedToInt(fr);
            GLubyte green = FixedToInt(fg);
            GLubyte blue  = FixedToInt(fb);
            GLubyte alpha = FixedToInt(fa);
#if DEPTH_BITS==16
            GLdepth z = FixedToInt(z0);
#else
            GLdepth z = z0;
#endif

            ASSERT(xLefti < xRight);

            {
               /* left pixel of swipe */
               coverage = (GLint) (alpha * (1.0F - (xLeft - xLefti)));
               PB_WRITE_RGBA_PIXEL( pb, xLefti, y, z, red, green, blue, coverage );
               xLefti++;

               /* right pixel of swipe */
               coverage = (GLint) (alpha * (xRight - xRighti));
               PB_WRITE_RGBA_PIXEL( pb, xRighti, y, z, red, green, blue, coverage );
               xRighti--;

               /* pixels between top and bottom with 100% coverage */
               for (ix = xLefti; ix <= xRighti; ix++) {
                  PB_WRITE_RGBA_PIXEL( pb, ix, y, z, red, green, blue, alpha );
               }
            }

            PB_CHECK_FLUSH( ctx, pb );
         }

         x += xStep;
         y += yStep;
         z0 += dz;
         fr += dfr;
         fg += dfg;
         fb += dfb;
         fa += dfa;
         if (!solid)
            ctx->StippleCounter++;
      }
   }
a983 1

d994 5
a998 18
   struct vertex_buffer *VB = ctx->VB;
   struct pixel_buffer *pb = ctx->PB;
   GLfloat halfWidth = 0.5F * ctx->Line.Width;  /* 0.5 is a bit of a hack */
   GLboolean solid = !ctx->Line.StippleFlag;
   GLint x0 = (GLint) VB->Win[vert0][0], x1 = (GLint) VB->Win[vert1][0];
   GLint y0 = (GLint) VB->Win[vert0][1], y1 = (GLint) VB->Win[vert1][1];
   GLint dx = x1 - x0;
   GLint dy = y1 - y0;
   GLint xStep, yStep;
   GLint z0, z1;
   GLfixed fr, dfr;
   GLfixed fg, dfg;
   GLfixed fb, dfb;
   GLfixed fa, dfa;
   GLfloat hs0, dhs;     /* h denotes hyperbolic */
   GLfloat ht0, dht;
   GLfloat hu0, dhu;
   GLfloat hv0, dhv;
d1000 15
a1014 215
   if (dx == 0 && dy == 0)
      return;

#if DEPTH_BITS==16
   z0 = FloatToFixed(VB->Win[vert0][2]);
   z1 = FloatToFixed(VB->Win[vert1][2]);
#else
   z0 = (int) VB->Win[vert0][2];
   z1 = (int) VB->Win[vert1][2];
#endif
   {
      GLfloat invw0 = 1.0F / VB->Clip[vert0][3];
      GLfloat invw1 = 1.0F / VB->Clip[vert1][3];
      hs0 = VB->TexCoord[vert0][0] * invw0;
      dhs = VB->TexCoord[vert1][0] * invw1 - hs0;
      ht0 = VB->TexCoord[vert0][1] * invw0;
      dht = VB->TexCoord[vert1][1] * invw1 - ht0;
      hu0 = VB->TexCoord[vert0][2] * invw0;
      dhu = VB->TexCoord[vert1][2] * invw1 - hu0;
      hv0 = VB->TexCoord[vert0][3] * invw0;
      dhv = VB->TexCoord[vert1][3] * invw1 - hv0;
   }

   if (ctx->Light.ShadeModel == GL_SMOOTH) {
      fr = IntToFixed(VB->Color[vert0][0]);
      fg = IntToFixed(VB->Color[vert0][1]);
      fb = IntToFixed(VB->Color[vert0][2]);
      fa = IntToFixed(VB->Color[vert0][3]);
   }
   else {
      fr = IntToFixed(VB->Color[pvert][0]);
      fg = IntToFixed(VB->Color[pvert][1]);
      fb = IntToFixed(VB->Color[pvert][2]);
      fa = IntToFixed(VB->Color[pvert][3]);
      dfr = dfg = dfb = dfa = 0;
   }

   if (dx < 0) {
      xStep = -1;
      dx = -dx;
   }
   else {
      xStep = 1;
   }

   if (dy < 0) {
      yStep = -1;
      dy = -dy;
   }
   else {
      yStep = 1;
   }

   if (dx > dy) {
      /* X-major line */
      GLint i;
      GLint x = x0;
      GLfloat y = VB->Win[vert0][1];
      GLfloat yStep = (VB->Win[vert1][1] - y) / (GLfloat) dx;
      GLint dz = (z1 - z0) / dx;
      GLfloat invDx = 1.0F / dx;
      if (ctx->Light.ShadeModel == GL_SMOOTH) {
         dfr = (IntToFixed(VB->Color[vert1][0]) - fr) / dx;
         dfg = (IntToFixed(VB->Color[vert1][1]) - fg) / dx;
         dfb = (IntToFixed(VB->Color[vert1][2]) - fb) / dx;
         dfa = (IntToFixed(VB->Color[vert1][3]) - fa) / dx;
      }
      dhs *= invDx;
      dht *= invDx;
      dhu *= invDx;
      dhv *= invDx;
      for (i = 0; i < dx; i++) {
         if (solid || (ctx->Line.StipplePattern & (1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf)))) {

            GLfloat yTop = y + halfWidth;
            GLfloat yBot = y - halfWidth;
            GLint yTopi = (GLint) yTop;
            GLint yBoti = (GLint) yBot;
            GLint iy;
            GLint coverage;
            GLubyte red   = FixedToInt(fr);
            GLubyte green = FixedToInt(fg);
            GLubyte blue  = FixedToInt(fb);
            GLubyte alpha = FixedToInt(fa);
#if DEPTH_BITS==16
            GLdepth z = FixedToInt(z0);
#else
            GLdepth z = z0;
#endif
            ASSERT(yBoti <= yTopi);

            {
               GLfloat invQ = 1.0F / hv0;
               GLfloat s = hs0 * invQ;
               GLfloat t = ht0 * invQ;
               GLfloat u = hu0 * invQ;

               /* bottom pixel of swipe */
               coverage = (GLint) (alpha * (1.0F - (yBot - yBoti)));
               PB_WRITE_TEX_PIXEL( pb, x, yBoti, z, red, green, blue, coverage,
                                   s, t, u );
               yBoti++;

               /* top pixel of swipe */
               coverage = (GLint) (alpha * (yTop - yTopi));
               PB_WRITE_TEX_PIXEL( pb, x, yTopi, z, red, green, blue, coverage,
                                   s, t, u );
               yTopi--;

               /* pixels between top and bottom with 100% coverage */
               for (iy = yBoti; iy <= yTopi; iy++) {
                  PB_WRITE_TEX_PIXEL( pb, x, iy, z, red, green, blue, alpha,
                                      s, t, u );
               }
            }
            PB_CHECK_FLUSH( ctx, pb );

         } /* if stippling */

         x += xStep;
         y += yStep;
         z0 += dz;
         fr += dfr;
         fg += dfg;
         fb += dfb;
         fa += dfa;
         hs0 += dhs;
         ht0 += dht;
         hu0 += dhu;
         hv0 += dhv;

         if (!solid)
            ctx->StippleCounter++;
      }
   }
   else {
      /* Y-major line */
      GLint i;
      GLint y = y0;
      GLfloat x = VB->Win[vert0][0];
      GLfloat xStep = (VB->Win[vert1][0] - x) / (GLfloat) dy;
      GLint dz = (z1 - z0) / dy;
      GLfloat invDy = 1.0F / dy;
      if (ctx->Light.ShadeModel == GL_SMOOTH) {
         dfr = (IntToFixed(VB->Color[vert1][0]) - fr) / dy;
         dfg = (IntToFixed(VB->Color[vert1][1]) - fg) / dy;
         dfb = (IntToFixed(VB->Color[vert1][2]) - fb) / dy;
         dfa = (IntToFixed(VB->Color[vert1][3]) - fa) / dy;
      }
      dhs *= invDy;
      dht *= invDy;
      dhu *= invDy;
      dhv *= invDy;
      for (i = 0; i < dy; i++) {
         if (solid || (ctx->Line.StipplePattern & (1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf)))) {
            GLfloat xRight = x + halfWidth;
            GLfloat xLeft = x - halfWidth;
            GLint xRighti = (GLint) xRight;
            GLint xLefti = (GLint) xLeft;
            GLint ix;
            GLint coverage;
            GLubyte red   = FixedToInt(fr);
            GLubyte green = FixedToInt(fg);
            GLubyte blue  = FixedToInt(fb);
            GLubyte alpha = FixedToInt(fa);
#if DEPTH_BITS==16
            GLdepth z = FixedToInt(z0);
#else
            GLdepth z = z0;
#endif

            ASSERT(xLefti < xRight);

            {
               GLfloat invQ = 1.0F / hv0;
               GLfloat s = hs0 * invQ;
               GLfloat t = ht0 * invQ;
               GLfloat u = hu0 * invQ;

               /* left pixel of swipe */
               coverage = (GLint) (alpha * (1.0F - (xLeft - xLefti)));
               PB_WRITE_TEX_PIXEL( pb, xLefti, y, z, red, green, blue, coverage,
                                   s, t, u );
               xLefti++;

               /* right pixel of swipe */
               coverage = (GLint) (alpha * (xRight - xRighti));
               PB_WRITE_TEX_PIXEL( pb, xRighti, y, z, red, green, blue, coverage,
                                   s, t, u );
               xRighti--;

               /* pixels between top and bottom with 100% coverage */
               for (ix = xLefti; ix <= xRighti; ix++) {
                  PB_WRITE_TEX_PIXEL( pb, ix, y, z, red, green, blue, alpha,
                                      s, t, u );
               }
            }
            PB_CHECK_FLUSH( ctx, pb );
         }

         x += xStep;
         y += yStep;
         z0 += dz;
         fr += dfr;
         fg += dfg;
         fb += dfb;
         fa += dfa;
         hs0 += dhs;
         ht0 += dht;
         hu0 += dhu;
         hv0 += dhv;
         if (!solid)
            ctx->StippleCounter++;
      }
   }
a1016 3



d1023 3
a1025 155
   struct vertex_buffer *VB = ctx->VB;
   struct pixel_buffer *pb = ctx->PB;
   GLfloat halfWidth = 0.5F * ctx->Line.Width;  /* 0.5 is a bit of a hack */
   GLboolean solid = !ctx->Line.StippleFlag;
   GLint x0 = (GLint) VB->Win[vert0][0], x1 = (GLint) VB->Win[vert1][0];
   GLint y0 = (GLint) VB->Win[vert0][1], y1 = (GLint) VB->Win[vert1][1];
   GLint dx = x1 - x0;
   GLint dy = y1 - y0;
   GLint xStep, yStep;
   GLint z0, z1;
   GLfixed fi, dfi;

   if (dx == 0 && dy == 0)
      return;

#if DEPTH_BITS==16
   z0 = FloatToFixed(VB->Win[vert0][2]);
   z1 = FloatToFixed(VB->Win[vert1][2]);
#else
   z0 = (int) VB->Win[vert0][2];
   z1 = (int) VB->Win[vert1][2];
#endif

   if (ctx->Light.ShadeModel == GL_SMOOTH) {
      fi = IntToFixed(VB->Index[vert0]);
   }
   else {
      fi = IntToFixed(VB->Index[pvert]);
      dfi = 0;
   }

   if (dx < 0) {
      xStep = -1;
      dx = -dx;
   }
   else {
      xStep = 1;
   }

   if (dy < 0) {
      yStep = -1;
      dy = -dy;
   }
   else {
      yStep = 1;
   }

   if (dx > dy) {
      /* X-major line */
      GLint i;
      GLint x = x0;
      GLfloat y = VB->Win[vert0][1];
      GLfloat yStep = (VB->Win[vert1][1] - y) / (GLfloat) dx;
      GLint dz = (z1 - z0) / dx;
      if (ctx->Light.ShadeModel == GL_SMOOTH) {
         dfi = (IntToFixed(VB->Index[vert1]) - fi) / dx;
      }
      for (i = 0; i < dx; i++) {
         if (solid || (ctx->Line.StipplePattern & (1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf)))) {

            GLfloat yTop = y + halfWidth;
            GLfloat yBot = y - halfWidth;
            GLint yTopi = (GLint) yTop;
            GLint yBoti = (GLint) yBot;
            GLint iy;
            GLuint coverage;
            GLuint index = FixedToInt(fi) & 0xfffffff0;
#if DEPTH_BITS==16
            GLdepth z = FixedToInt(z0);
#else
            GLdepth z = z0;
#endif

            ASSERT(yBoti <= yTopi);

            /* bottom pixel of swipe */
            coverage = (GLuint) (15.0F * (1.0F - (yBot - yBoti)));
            PB_WRITE_CI_PIXEL( pb, x, yBoti, z, index + coverage );
            yBoti++;

            /* top pixel of swipe */
            coverage = (GLuint) (15.0F * (yTop - yTopi));
            PB_WRITE_CI_PIXEL( pb, x, yTopi, z, index + coverage );
            yTopi--;

            /* pixels between top and bottom with 100% coverage */
            for (iy = yBoti; iy <= yTopi; iy++) {
               PB_WRITE_CI_PIXEL( pb, x, iy, z, index + 15 );
            }
         }

         PB_CHECK_FLUSH( ctx, pb );

         x += xStep;
         y += yStep;
         z0 += dz;
         fi += dfi;
         if (!solid)
            ctx->StippleCounter++;
      }
   }
   else {
      /* Y-major line */
      GLint i;
      GLint y = y0;
      GLfloat x = VB->Win[vert0][0];
      GLfloat xStep = (VB->Win[vert1][0] - x) / (GLfloat) dy;
      GLint dz = (z1 - z0) / dy;
      if (ctx->Light.ShadeModel == GL_SMOOTH) {
         dfi = (IntToFixed(VB->Index[vert1]) - fi) / dy;
      }
      for (i = 0; i < dy; i++) {
         if (solid || (ctx->Line.StipplePattern & (1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf)))) {
            GLfloat xRight = x + halfWidth;
            GLfloat xLeft = x - halfWidth;
            GLint xRighti = (GLint) xRight;
            GLint xLefti = (GLint) xLeft;
            GLint ix;
            GLuint coverage;
            GLuint index = FixedToInt(fi) & 0xfffffff0;
#if DEPTH_BITS==16
            GLdepth z = FixedToInt(z0);
#else
            GLdepth z = z0;
#endif

            ASSERT(xLefti < xRight);

            /* left pixel of swipe */
            coverage = (GLuint) (15.0F * (1.0F - (xLeft - xLefti)));
            PB_WRITE_CI_PIXEL( pb, xLefti, y, z, index + coverage );
            xLefti++;

            /* right pixel of swipe */
            coverage = (GLuint) (15.0F * (xRight - xRighti));
            PB_WRITE_CI_PIXEL( pb, xRighti, y, z, index + coverage );
            xRighti--;

            /* pixels between top and bottom with 100% coverage */
            for (ix = xLefti; ix <= xRighti; ix++) {
               PB_WRITE_CI_PIXEL( pb, ix, y, z, index + 15 );
            }
         }

         PB_CHECK_FLUSH( ctx, pb );

         x += xStep;
         y += yStep;
         z0 += dz;
         fi += dfi;
         if (!solid)
            ctx->StippleCounter++;

      }
   }
a1028 2


a1040 1

d1062 7
a1068 3
            if (ctx->Texture.ReallyEnabled)
               ctx->Driver.LineFunc = aa_tex_rgba_line;
            else
d1070 1
d1077 2
a1078 2
         if (ctx->Light.ShadeModel==GL_SMOOTH) {
            ctx->Driver.LineFunc = smooth_textured_line;
d1081 6
a1086 1
            ctx->Driver.LineFunc = flat_textured_line;
@


3.13
log
@added Texture.ReallyEnabled to simply testing for enabled textures
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.12 1998/07/08 01:03:28 brianp Exp brianp $ */
d26 3
d145 1
a145 1
   GLuint texSet = ctx->Texture.CurrentTransformSet;
d157 10
a166 10
   invq = (VB->MultiTexCoord[texSet][v1][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v1][3]);
   tex1[0] = VB->MultiTexCoord[texSet][v1][0] * invq;
   tex1[1] = VB->MultiTexCoord[texSet][v1][1] * invq;
   tex1[2] = VB->MultiTexCoord[texSet][v1][2] * invq;
   tex1[3] = VB->MultiTexCoord[texSet][v1][3];
   invq = (VB->MultiTexCoord[texSet][v2][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v2][3]);
   tex2[0] = VB->MultiTexCoord[texSet][v2][0] * invq;
   tex2[1] = VB->MultiTexCoord[texSet][v2][1] * invq;
   tex2[2] = VB->MultiTexCoord[texSet][v2][2] * invq;
   tex2[3] = VB->MultiTexCoord[texSet][v2][3];
@


3.12
log
@removed some unused variables
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.11 1998/06/18 02:38:45 brianp Exp brianp $ */
d26 3
d1524 1
a1524 1
            if (ctx->Texture.Enabled)
d1533 1
a1533 1
      else if (ctx->Texture.Enabled) {
d1542 1
a1542 1
               || ctx->Line.SmoothFlag || ctx->Texture.Enabled) {
@


3.11
log
@re-implemented INTERP_STUV code for textured lines
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.10 1998/06/18 01:51:07 brianp Exp brianp $ */
d26 3
d1096 4
a1099 4
   GLfloat hs0, hs1, dhs;     /* h denotes hyperbolic */
   GLfloat ht0, ht1, dht;
   GLfloat hu0, hu1, dhu;
   GLfloat hv0, hv1, dhv;
@


3.10
log
@more work on AA texture coordinate interpolation
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.9 1998/06/17 04:08:38 brianp Exp brianp $ */
d26 3
d755 1
a755 2
#define INTERP_STW 1
#define INTERP_UV 1
d759 11
a769 8
	pbx[count] = X;			\
	pby[count] = Y;			\
	pbz[count] = Z;			\
	pbs[count] = s0 / w0;		\
	pbt[count] = t0 / w0;		\
	pbu[count] = u0 / w0;		\
	count++;			\
	CHECK_FULL(count);
d776 1
a776 2
#define INTERP_STW 1
#define INTERP_UV 1
d779 11
a789 8
	pbx[count] = X;			\
	pby[count] = Y;			\
	pbz[count] = Z;			\
	pbs[count] = s0 / w0;		\
	pbt[count] = t0 / w0;		\
	pbu[count] = u0 / w0;		\
	count++;			\
	CHECK_FULL(count);
d819 1
a819 2
#define INTERP_STW 1
#define INTERP_UV 1
d822 16
a837 13
#define PLOT(X,Y)				\
	pbx[count] = X;				\
	pby[count] = Y;				\
	pbz[count] = Z;				\
	pbs[count] = s0 / w0;			\
	pbt[count] = t0 / w0;			\
	pbu[count] = u0 / w0;			\
	pbrgba[count][RCOMP] = FixedToInt(r0);	\
	pbrgba[count][GCOMP] = FixedToInt(g0);	\
	pbrgba[count][BCOMP] = FixedToInt(b0);	\
	pbrgba[count][ACOMP] = FixedToInt(a0);	\
	count++;				\
	CHECK_FULL(count);
d846 1
a846 2
#define INTERP_STW 1
#define INTERP_UV 1
d848 16
a863 13
#define PLOT(X,Y)				\
	pbx[count] = X;				\
	pby[count] = Y;				\
	pbz[count] = Z;				\
	pbs[count] = s0 / w0;			\
	pbt[count] = t0 / w0;			\
	pbu[count] = u0 / w0;			\
	pbrgba[count][RCOMP] = FixedToInt(r0);	\
	pbrgba[count][GCOMP] = FixedToInt(g0);	\
	pbrgba[count][BCOMP] = FixedToInt(b0);	\
	pbrgba[count][ACOMP] = FixedToInt(a0);	\
	count++;				\
	CHECK_FULL(count);
d1093 1
a1093 1
   GLfloat hs0, hs1, dhs;     /* h = hyperbolic = 1 / s */
d1112 1
a1112 2
      hs1 = VB->TexCoord[vert1][0] * invw1;
      dhs = hs1 - hs0;
d1114 1
a1114 2
      ht1 = VB->TexCoord[vert1][1] * invw1;
      dht = ht1 - ht0;
d1116 1
a1116 2
      hu1 = VB->TexCoord[vert1][2] * invw1;
      dhu = hu1 - hu0;
d1118 1
a1118 2
      hv1 = VB->TexCoord[vert1][3] * invw1;
      dhv = hv1 - hv0;
d1187 1
a1187 1
            ASSERT(yBoti < yTopi);
d1190 4
a1193 4
               GLfloat invW = 1.0F / hv0;
               GLfloat s = hs0 * invW;
               GLfloat t = ht0 * invW;
               GLfloat u = hu0 * invW;
d1272 4
a1275 4
               GLfloat invW = 1.0F / hv0;
               GLfloat s = hs0 * invW;
               GLfloat t = ht0 * invW;
               GLfloat u = hu0 * invW;
d1397 1
a1397 1
            ASSERT(yBoti < yTopi);
@


3.9
log
@textured, AA lines didn't interpolate texture coords correctly
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.8 1998/06/17 01:18:14 brianp Exp brianp $ */
d26 3
d1085 1
a1085 1
   GLfloat hw0, hw1, dhw;     /* vertex W clip coordinate */
a1096 4
   hw0 = 1.0F / VB->Clip[vert0][3];
   hw1 = 1.0F / VB->Clip[vert1][3];
   dhw = hw1 - hw0;

d1098 4
a1101 4
      GLfloat invV0 = 1.0 / VB->TexCoord[vert0][3];
      GLfloat invV1 = 1.0 / VB->TexCoord[vert1][3];
      hs0 = hw0 * VB->TexCoord[vert0][0] * invV0;
      hs1 = hw1 * VB->TexCoord[vert1][0] * invV1;
d1103 2
a1104 2
      ht0 = hw0 * VB->TexCoord[vert0][1] * invV0;
      ht1 = hw1 * VB->TexCoord[vert1][1] * invV1;
d1106 2
a1107 2
      hu0 = hw0 * VB->TexCoord[vert0][2] * invV0;
      hu1 = hw1 * VB->TexCoord[vert1][2] * invV1;
d1109 3
d1161 1
a1161 1
      dhw *= invDx;
d1183 1
a1183 1
               GLfloat invW = 1.0F / hw0;
a1212 1
         hw0 += dhw;
d1220 1
d1243 1
a1243 1
      dhw *= invDy;
d1265 1
a1265 1
               GLfloat invW = 1.0F / hw0;
a1293 1
         hw0 += dhw;
d1301 1
@


3.8
log
@textured, AA lines test was backward (Marten Stromberg)
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.7 1998/06/17 01:15:10 brianp Exp brianp $ */
d26 3
d1075 8
a1082 4
   GLfixed fr, fg, fb, fa;      /* fixed-pt RGBA */
   GLfixed dfr, dfg, dfb, dfa;  /* fixed-pt RGBA deltas */
   GLfloat s0, t0, u0, v0;      /* S, T, R, Q texcoords */
   GLfloat ds, dt, du, dv;
d1094 17
a1110 4
   s0 = VB->TexCoord[vert0][0];
   t0 = VB->TexCoord[vert0][1];
   u0 = VB->TexCoord[vert0][2];
   v0 = VB->TexCoord[vert0][3];
d1149 1
d1156 4
a1159 4
      ds = (VB->TexCoord[vert1][0] - s0) / dx;
      dt = (VB->TexCoord[vert1][1] - t0) / dx;
      du = (VB->TexCoord[vert1][2] - u0) / dx;
      dv = (VB->TexCoord[vert1][3] - v0) / dx;
d1181 4
a1184 4
               GLfloat invV = 1.0F / v0;
               GLfloat s = s0 * invV;
               GLfloat t = t0 * invV;
               GLfloat u = u0 * invV;
a1202 4
               s0 += ds;
               t0 += dt;
               u0 += du;
               v0 += dv;
a1203 1

d1211 1
d1216 4
d1231 1
d1238 4
a1241 4
      ds = (VB->TexCoord[vert1][0] - s0) / dy;
      dt = (VB->TexCoord[vert1][1] - t0) / dy;
      du = (VB->TexCoord[vert1][2] - u0) / dy;
      dv = (VB->TexCoord[vert1][3] - v0) / dy;
d1263 4
a1266 4
               GLfloat invV = 1.0F / v0;
               GLfloat s = s0 * invV;
               GLfloat t = t0 * invV;
               GLfloat u = u0 * invV;
a1284 5

               s0 += ds;
               t0 += dt;
               u0 += du;
               v0 += dv;
a1285 1

d1292 1
d1297 3
@


3.7
log
@include assert.h
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.6 1998/06/11 01:58:40 brianp Exp brianp $ */
d26 3
d1490 2
a1492 2
            else
               ctx->Driver.LineFunc = aa_tex_rgba_line;
@


3.6
log
@separate textured and non-textured AA line functions
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.5 1998/06/09 03:23:55 brianp Exp brianp $ */
d26 3
d53 1
d948 1
a948 1
            assert(yBoti < yTopi);
d1013 1
a1013 1
            assert(xLefti < xRight);
d1154 1
a1154 1
            assert(yBoti < yTopi);
d1235 1
a1235 1
            assert(xLefti < xRight);
d1365 1
a1365 1
            assert(yBoti < yTopi);
d1418 1
a1418 1
            assert(xLefti < xRight);
@


3.5
log
@implemented antialiased lines
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.4 1998/06/07 22:18:52 brianp Exp brianp $ */
d26 3
d863 196
a1058 1
   GLboolean texture = (ctx->Texture.Enabled != 0);
d1152 1
a1152 1
            if (texture) {
a1179 16
            else {
               /* bottom pixel of swipe */
               coverage = (GLint) (alpha * (1.0F - (yBot - yBoti)));
               PB_WRITE_RGBA_PIXEL( pb, x, yBoti, z, red, green, blue, coverage );
               yBoti++;

               /* top pixel of swipe */
               coverage = (GLint) (alpha * (yTop - yTopi));
               PB_WRITE_RGBA_PIXEL( pb, x, yTopi, z, red, green, blue, coverage );
               yTopi--;

               /* pixels between top and bottom with 100% coverage */
               for (iy = yBoti; iy <= yTopi; iy++) {
                  PB_WRITE_RGBA_PIXEL( pb, x, iy, z, red, green, blue, alpha );
               }
            }
d1233 1
a1233 1
            if (texture) {
a1261 16
            else {
               /* left pixel of swipe */
               coverage = (GLint) (alpha * (1.0F - (xLeft - xLefti)));
               PB_WRITE_RGBA_PIXEL( pb, xLefti, y, z, red, green, blue, coverage );
               xLefti++;

               /* right pixel of swipe */
               coverage = (GLint) (alpha * (xRight - xRighti));
               PB_WRITE_RGBA_PIXEL( pb, xRighti, y, z, red, green, blue, coverage );
               xRighti--;

               /* pixels between top and bottom with 100% coverage */
               for (ix = xLefti; ix <= xRighti; ix++) {
                  PB_WRITE_RGBA_PIXEL( pb, ix, y, z, red, green, blue, alpha );
               }
            }
d1281 1
d1482 4
a1485 1
            ctx->Driver.LineFunc = aa_rgba_line;
@


3.4
log
@implemented GL_EXT_multitexture extension
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.3 1998/04/13 23:30:08 brianp Exp brianp $ */
d26 3
d847 435
d1311 9
@


3.3
log
@fixed PB overflow bug (Randy Frank)
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.2 1998/03/27 04:17:52 brianp Exp brianp $ */
d26 3
d114 1
d126 10
a135 10
   invq = (VB->TexCoord[v1][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v1][3]);
   tex1[0] = VB->TexCoord[v1][0] * invq;
   tex1[1] = VB->TexCoord[v1][1] * invq;
   tex1[2] = VB->TexCoord[v1][2] * invq;
   tex1[3] = VB->TexCoord[v1][3];
   invq = (VB->TexCoord[v2][3]==0.0) ? 1.0 : (1.0F / VB->TexCoord[v2][3]);
   tex2[0] = VB->TexCoord[v2][0] * invq;
   tex2[1] = VB->TexCoord[v2][1] * invq;
   tex2[2] = VB->TexCoord[v2][2] * invq;
   tex2[3] = VB->TexCoord[v2][3];
@


3.2
log
@fixed G++ warnings
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.1 1998/02/04 00:44:29 brianp Exp brianp $ */
d26 3
d451 2
a452 1
	count += 2;
d458 2
a459 1
	count += 2;
d519 2
a520 1
	count += 2;
d525 2
a526 1
	count += 2;
d600 2
a601 1
	count += 2;
d614 2
a615 1
	count += 2;
d679 2
a680 1
	count += 2;
d685 2
a686 1
	count += 2;
@


3.1
log
@fixed casts and conditional expression problems for Amiga StormC compiler
@
text
@d1 1
a1 1
/* $Id: lines.c,v 3.0 1998/01/31 20:55:24 brianp Exp brianp $ */
d26 3
d157 1
d287 1
d315 1
d344 1
d376 1
d418 1
d551 1
d760 1
a760 1
                                  GLuint vert0, GLuint vert1, GLuint pv )
d770 1
d833 4
@


3.0
log
@initial rev
@
text
@d1 1
a1 1
/* $Id$ */
d25 4
a28 1
 * $Log$
d128 1
a128 1
      FEEDBACK_TOKEN( ctx, (GLfloat) GL_LINE_RESET_TOKEN );
d131 1
a131 1
      FEEDBACK_TOKEN( ctx, (GLfloat) GL_LINE_TOKEN );
d855 4
a858 2
            ctx->Driver.LineFunc = rgbmode ? general_smooth_rgba_line
                                           : general_smooth_ci_line;
d861 4
a864 2
            ctx->Driver.LineFunc = rgbmode ? general_flat_rgba_line
                                           : general_flat_ci_line;
d872 4
a875 2
               ctx->Driver.LineFunc = rgbmode ? smooth_rgba_z_line
                                              : smooth_ci_z_line;
d878 4
a881 2
               ctx->Driver.LineFunc = rgbmode ? smooth_rgba_line
                                              : smooth_ci_line;
d888 4
a891 2
               ctx->Driver.LineFunc = rgbmode ? flat_rgba_z_line
                                              : flat_ci_z_line;
d894 4
a897 2
               ctx->Driver.LineFunc = rgbmode ? flat_rgba_line
                                              : flat_ci_line;
@
