1 /* $Id: lines.c,v 1.2 1999/09/18 20:41:23 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46 #include "GL/xf86glx.h"
52 void gl_LineWidth( GLcontext
*ctx
, GLfloat width
)
55 gl_error( ctx
, GL_INVALID_VALUE
, "glLineWidth" );
58 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glLineWidth");
60 if (ctx
->Line
.Width
!= width
) {
61 ctx
->Line
.Width
= width
;
62 ctx
->TriangleCaps
&= ~DD_LINE_WIDTH
;
63 if (width
!= 1.0) ctx
->TriangleCaps
|= DD_LINE_WIDTH
;
64 ctx
->NewState
|= NEW_RASTER_OPS
;
70 void gl_LineStipple( GLcontext
*ctx
, GLint factor
, GLushort pattern
)
72 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glLineStipple");
73 ctx
->Line
.StippleFactor
= CLAMP( factor
, 1, 256 );
74 ctx
->Line
.StipplePattern
= pattern
;
75 ctx
->NewState
|= NEW_RASTER_OPS
;
80 /**********************************************************************/
81 /***** Rasterization *****/
82 /**********************************************************************/
86 * There are 4 pairs (RGBA, CI) of line drawing functions:
87 * 1. simple: width=1 and no special rasterization functions (fastest)
88 * 2. flat: width=1, non-stippled, flat-shaded, any raster operations
89 * 3. smooth: width=1, non-stippled, smooth-shaded, any raster operations
90 * 4. general: any other kind of line (slowest)
95 * All line drawing functions have the same arguments:
96 * v1, v2 - indexes of first and second endpoints into vertex buffer arrays
97 * pv - provoking vertex: which vertex color/index to use for flat shading.
105 #if MAX_WIDTH > MAX_HEIGHT
106 # define MAXPOINTS MAX_WIDTH
108 # define MAXPOINTS MAX_HEIGHT
112 /* Flat, color index line */
113 static void flat_ci_line( GLcontext
*ctx
,
114 GLuint vert0
, GLuint vert1
, GLuint pvert
)
117 GLint
*pbx
= ctx
->PB
->x
;
118 GLint
*pby
= ctx
->PB
->y
;
119 PB_SET_INDEX( ctx
, ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
120 count
= ctx
->PB
->count
;
129 #include "linetemp.h"
131 ctx
->PB
->count
= count
;
132 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
137 /* Flat, color index line with Z interpolation/testing */
138 static void flat_ci_z_line( GLcontext
*ctx
,
139 GLuint vert0
, GLuint vert1
, GLuint pvert
)
142 GLint
*pbx
= ctx
->PB
->x
;
143 GLint
*pby
= ctx
->PB
->y
;
144 GLdepth
*pbz
= ctx
->PB
->z
;
145 PB_SET_INDEX( ctx
, ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
146 count
= ctx
->PB
->count
;
157 #include "linetemp.h"
159 ctx
->PB
->count
= count
;
160 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
165 /* Flat-shaded, RGBA line */
166 static void flat_rgba_line( GLcontext
*ctx
,
167 GLuint vert0
, GLuint vert1
, GLuint pvert
)
170 GLint
*pbx
= ctx
->PB
->x
;
171 GLint
*pby
= ctx
->PB
->y
;
172 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
173 PB_SET_COLOR( ctx
, ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
174 count
= ctx
->PB
->count
;
183 #include "linetemp.h"
185 ctx
->PB
->count
= count
;
186 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
191 /* Flat-shaded, RGBA line with Z interpolation/testing */
192 static void flat_rgba_z_line( GLcontext
*ctx
,
193 GLuint vert0
, GLuint vert1
, GLuint pvert
)
196 GLint
*pbx
= ctx
->PB
->x
;
197 GLint
*pby
= ctx
->PB
->y
;
198 GLdepth
*pbz
= ctx
->PB
->z
;
199 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
200 PB_SET_COLOR( ctx
, ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
201 count
= ctx
->PB
->count
;
212 #include "linetemp.h"
214 ctx
->PB
->count
= count
;
215 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
220 /* Smooth shaded, color index line */
221 static void smooth_ci_line( GLcontext
*ctx
,
222 GLuint vert0
, GLuint vert1
, GLuint pvert
)
224 GLint count
= ctx
->PB
->count
;
225 GLint
*pbx
= ctx
->PB
->x
;
226 GLint
*pby
= ctx
->PB
->y
;
227 GLuint
*pbi
= ctx
->PB
->i
;
231 #define INTERP_INDEX 1
239 #include "linetemp.h"
241 ctx
->PB
->count
= count
;
242 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
247 /* Smooth shaded, color index line with Z interpolation/testing */
248 static void smooth_ci_z_line( GLcontext
*ctx
,
249 GLuint vert0
, GLuint vert1
, GLuint pvert
)
251 GLint count
= ctx
->PB
->count
;
252 GLint
*pbx
= ctx
->PB
->x
;
253 GLint
*pby
= ctx
->PB
->y
;
254 GLdepth
*pbz
= ctx
->PB
->z
;
255 GLuint
*pbi
= ctx
->PB
->i
;
260 #define INTERP_INDEX 1
269 #include "linetemp.h"
271 ctx
->PB
->count
= count
;
272 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
277 /* Smooth-shaded, RGBA line */
278 static void smooth_rgba_line( GLcontext
*ctx
,
279 GLuint vert0
, GLuint vert1
, GLuint pvert
)
281 GLint count
= ctx
->PB
->count
;
282 GLint
*pbx
= ctx
->PB
->x
;
283 GLint
*pby
= ctx
->PB
->y
;
284 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
289 #define INTERP_ALPHA 1
294 pbrgba[count][RCOMP] = FixedToInt(r0); \
295 pbrgba[count][GCOMP] = FixedToInt(g0); \
296 pbrgba[count][BCOMP] = FixedToInt(b0); \
297 pbrgba[count][ACOMP] = FixedToInt(a0); \
300 #include "linetemp.h"
302 ctx
->PB
->count
= count
;
303 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
308 /* Smooth-shaded, RGBA line with Z interpolation/testing */
309 static void smooth_rgba_z_line( GLcontext
*ctx
,
310 GLuint vert0
, GLuint vert1
, GLuint pvert
)
312 GLint count
= ctx
->PB
->count
;
313 GLint
*pbx
= ctx
->PB
->x
;
314 GLint
*pby
= ctx
->PB
->y
;
315 GLdepth
*pbz
= ctx
->PB
->z
;
316 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
322 #define INTERP_ALPHA 1
328 pbrgba[count][RCOMP] = FixedToInt(r0); \
329 pbrgba[count][GCOMP] = FixedToInt(g0); \
330 pbrgba[count][BCOMP] = FixedToInt(b0); \
331 pbrgba[count][ACOMP] = FixedToInt(a0); \
334 #include "linetemp.h"
336 ctx
->PB
->count
= count
;
337 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
341 #define CHECK_FULL(count) \
342 if (count >= PB_SIZE-MAX_WIDTH) { \
343 ctx->PB->count = count; \
345 count = ctx->PB->count; \
350 /* Smooth shaded, color index, any width, maybe stippled */
351 static void general_smooth_ci_line( GLcontext
*ctx
,
352 GLuint vert0
, GLuint vert1
, GLuint pvert
)
354 GLint count
= ctx
->PB
->count
;
355 GLint
*pbx
= ctx
->PB
->x
;
356 GLint
*pby
= ctx
->PB
->y
;
357 GLdepth
*pbz
= ctx
->PB
->z
;
358 GLuint
*pbi
= ctx
->PB
->i
;
361 if (ctx
->Line
.StippleFlag
) {
365 #define INTERP_INDEX 1
375 #include "linetemp.h"
379 if (ctx
->Line
.Width
==2.0F
) {
380 /* special case: unstippled and width=2 */
383 #define INTERP_INDEX 1
384 #define XMAJOR_PLOT(X,Y) \
385 pbx[count] = X; pbx[count+1] = X; \
386 pby[count] = Y; pby[count+1] = Y+1; \
387 pbz[count] = Z; pbz[count+1] = Z; \
388 pbi[count] = I; pbi[count+1] = I; \
391 #define YMAJOR_PLOT(X,Y) \
392 pbx[count] = X; pbx[count+1] = X+1; \
393 pby[count] = Y; pby[count+1] = Y; \
394 pbz[count] = Z; pbz[count+1] = Z; \
395 pbi[count] = I; pbi[count+1] = I; \
398 #include "linetemp.h"
401 /* unstippled, any width */
404 #define INTERP_INDEX 1
413 #include "linetemp.h"
417 ctx
->PB
->count
= count
;
418 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
422 /* Flat shaded, color index, any width, maybe stippled */
423 static void general_flat_ci_line( GLcontext
*ctx
,
424 GLuint vert0
, GLuint vert1
, GLuint pvert
)
427 GLint
*pbx
= ctx
->PB
->x
;
428 GLint
*pby
= ctx
->PB
->y
;
429 GLdepth
*pbz
= ctx
->PB
->z
;
430 PB_SET_INDEX( ctx
, ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
431 count
= ctx
->PB
->count
;
433 if (ctx
->Line
.StippleFlag
) {
434 /* stippled, any width */
445 #include "linetemp.h"
449 if (ctx
->Line
.Width
==2.0F
) {
450 /* special case: unstippled and width=2 */
453 #define XMAJOR_PLOT(X,Y) \
454 pbx[count] = X; pbx[count+1] = X; \
455 pby[count] = Y; pby[count+1] = Y+1; \
456 pbz[count] = Z; pbz[count+1] = Z; \
459 #define YMAJOR_PLOT(X,Y) \
460 pbx[count] = X; pbx[count+1] = X+1; \
461 pby[count] = Y; pby[count+1] = Y; \
462 pbz[count] = Z; pbz[count+1] = Z; \
465 #include "linetemp.h"
468 /* unstippled, any width */
478 #include "linetemp.h"
482 ctx
->PB
->count
= count
;
483 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
488 static void general_smooth_rgba_line( GLcontext
*ctx
,
489 GLuint vert0
, GLuint vert1
, GLuint pvert
)
491 GLint count
= ctx
->PB
->count
;
492 GLint
*pbx
= ctx
->PB
->x
;
493 GLint
*pby
= ctx
->PB
->y
;
494 GLdepth
*pbz
= ctx
->PB
->z
;
495 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
498 if (ctx
->Line
.StippleFlag
) {
503 #define INTERP_ALPHA 1
510 pbrgba[count][RCOMP] = FixedToInt(r0); \
511 pbrgba[count][GCOMP] = FixedToInt(g0); \
512 pbrgba[count][BCOMP] = FixedToInt(b0); \
513 pbrgba[count][ACOMP] = FixedToInt(a0); \
516 #include "linetemp.h"
520 if (ctx
->Line
.Width
==2.0F
) {
521 /* special case: unstippled and width=2 */
525 #define INTERP_ALPHA 1
526 #define XMAJOR_PLOT(X,Y) \
527 pbx[count] = X; pbx[count+1] = X; \
528 pby[count] = Y; pby[count+1] = Y+1; \
529 pbz[count] = Z; pbz[count+1] = Z; \
530 pbrgba[count][RCOMP] = FixedToInt(r0); \
531 pbrgba[count][GCOMP] = FixedToInt(g0); \
532 pbrgba[count][BCOMP] = FixedToInt(b0); \
533 pbrgba[count][ACOMP] = FixedToInt(a0); \
534 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
535 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
536 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
537 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
540 #define YMAJOR_PLOT(X,Y) \
541 pbx[count] = X; pbx[count+1] = X+1; \
542 pby[count] = Y; pby[count+1] = Y; \
543 pbz[count] = Z; pbz[count+1] = Z; \
544 pbrgba[count][RCOMP] = FixedToInt(r0); \
545 pbrgba[count][GCOMP] = FixedToInt(g0); \
546 pbrgba[count][BCOMP] = FixedToInt(b0); \
547 pbrgba[count][ACOMP] = FixedToInt(a0); \
548 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
549 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
550 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
551 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
554 #include "linetemp.h"
557 /* unstippled, any width */
561 #define INTERP_ALPHA 1
567 pbrgba[count][RCOMP] = FixedToInt(r0); \
568 pbrgba[count][GCOMP] = FixedToInt(g0); \
569 pbrgba[count][BCOMP] = FixedToInt(b0); \
570 pbrgba[count][ACOMP] = FixedToInt(a0); \
573 #include "linetemp.h"
577 ctx
->PB
->count
= count
;
578 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
582 static void general_flat_rgba_line( GLcontext
*ctx
,
583 GLuint vert0
, GLuint vert1
, GLuint pvert
)
586 GLint
*pbx
= ctx
->PB
->x
;
587 GLint
*pby
= ctx
->PB
->y
;
588 GLdepth
*pbz
= ctx
->PB
->z
;
589 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
590 PB_SET_COLOR( ctx
, ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
591 count
= ctx
->PB
->count
;
593 if (ctx
->Line
.StippleFlag
) {
605 #include "linetemp.h"
609 if (ctx
->Line
.Width
==2.0F
) {
610 /* special case: unstippled and width=2 */
613 #define XMAJOR_PLOT(X,Y) \
614 pbx[count] = X; pbx[count+1] = X; \
615 pby[count] = Y; pby[count+1] = Y+1; \
616 pbz[count] = Z; pbz[count+1] = Z; \
619 #define YMAJOR_PLOT(X,Y) \
620 pbx[count] = X; pbx[count+1] = X+1; \
621 pby[count] = Y; pby[count+1] = Y; \
622 pbz[count] = Z; pbz[count+1] = Z; \
625 #include "linetemp.h"
628 /* unstippled, any width */
638 #include "linetemp.h"
642 ctx
->PB
->count
= count
;
643 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
647 /* Flat-shaded, textured, any width, maybe stippled */
648 static void flat_textured_line( GLcontext
*ctx
,
649 GLuint vert0
, GLuint vert1
, GLuint pv
)
652 GLint
*pbx
= ctx
->PB
->x
;
653 GLint
*pby
= ctx
->PB
->y
;
654 GLdepth
*pbz
= ctx
->PB
->z
;
655 GLfloat
*pbs
= ctx
->PB
->s
[0];
656 GLfloat
*pbt
= ctx
->PB
->t
[0];
657 GLfloat
*pbu
= ctx
->PB
->u
[0];
658 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
659 PB_SET_COLOR( ctx
, ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
660 count
= ctx
->PB
->count
;
662 if (ctx
->Line
.StippleFlag
) {
666 #define INTERP_STUV0 1
680 #include "linetemp.h"
686 #define INTERP_STUV0 1
699 #include "linetemp.h"
702 ctx
->PB
->count
= count
;
703 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
708 /* Smooth-shaded, textured, any width, maybe stippled */
709 static void smooth_textured_line( GLcontext
*ctx
,
710 GLuint vert0
, GLuint vert1
, GLuint pvert
)
712 GLint count
= ctx
->PB
->count
;
713 GLint
*pbx
= ctx
->PB
->x
;
714 GLint
*pby
= ctx
->PB
->y
;
715 GLdepth
*pbz
= ctx
->PB
->z
;
716 GLfloat
*pbs
= ctx
->PB
->s
[0];
717 GLfloat
*pbt
= ctx
->PB
->t
[0];
718 GLfloat
*pbu
= ctx
->PB
->u
[0];
719 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
722 if (ctx
->Line
.StippleFlag
) {
727 #define INTERP_ALPHA 1
728 #define INTERP_STUV0 1
739 pbrgba[count][RCOMP] = FixedToInt(r0); \
740 pbrgba[count][GCOMP] = FixedToInt(g0); \
741 pbrgba[count][BCOMP] = FixedToInt(b0); \
742 pbrgba[count][ACOMP] = FixedToInt(a0); \
746 #include "linetemp.h"
753 #define INTERP_ALPHA 1
754 #define INTERP_STUV0 1
764 pbrgba[count][RCOMP] = FixedToInt(r0); \
765 pbrgba[count][GCOMP] = FixedToInt(g0); \
766 pbrgba[count][BCOMP] = FixedToInt(b0); \
767 pbrgba[count][ACOMP] = FixedToInt(a0); \
771 #include "linetemp.h"
774 ctx
->PB
->count
= count
;
775 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
779 /* Smooth-shaded, multitextured, any width, maybe stippled, separate specular
780 * color interpolation.
782 static void smooth_multitextured_line( GLcontext
*ctx
,
783 GLuint vert0
, GLuint vert1
, GLuint pvert
)
785 GLint count
= ctx
->PB
->count
;
786 GLint
*pbx
= ctx
->PB
->x
;
787 GLint
*pby
= ctx
->PB
->y
;
788 GLdepth
*pbz
= ctx
->PB
->z
;
789 GLfloat
*pbs
= ctx
->PB
->s
[0];
790 GLfloat
*pbt
= ctx
->PB
->t
[0];
791 GLfloat
*pbu
= ctx
->PB
->u
[0];
792 GLfloat
*pbs1
= ctx
->PB
->s
[1];
793 GLfloat
*pbt1
= ctx
->PB
->t
[1];
794 GLfloat
*pbu1
= ctx
->PB
->u
[1];
795 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
796 GLubyte (*pbspec
)[3] = ctx
->PB
->spec
;
799 if (ctx
->Line
.StippleFlag
) {
804 #define INTERP_SPEC 1
805 #define INTERP_ALPHA 1
806 #define INTERP_STUV0 1
807 #define INTERP_STUV1 1
821 pbrgba[count][RCOMP] = FixedToInt(r0); \
822 pbrgba[count][GCOMP] = FixedToInt(g0); \
823 pbrgba[count][BCOMP] = FixedToInt(b0); \
824 pbrgba[count][ACOMP] = FixedToInt(a0); \
825 pbspec[count][RCOMP] = FixedToInt(sr0); \
826 pbspec[count][GCOMP] = FixedToInt(sg0); \
827 pbspec[count][BCOMP] = FixedToInt(sb0); \
831 #include "linetemp.h"
838 #define INTERP_SPEC 1
839 #define INTERP_ALPHA 1
840 #define INTERP_STUV0 1
841 #define INTERP_STUV1 1
854 pbrgba[count][RCOMP] = FixedToInt(r0); \
855 pbrgba[count][GCOMP] = FixedToInt(g0); \
856 pbrgba[count][BCOMP] = FixedToInt(b0); \
857 pbrgba[count][ACOMP] = FixedToInt(a0); \
858 pbspec[count][RCOMP] = FixedToInt(sr0); \
859 pbspec[count][GCOMP] = FixedToInt(sg0); \
860 pbspec[count][BCOMP] = FixedToInt(sb0); \
864 #include "linetemp.h"
867 ctx
->PB
->count
= count
;
868 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
873 * Antialiased RGBA line
875 * This AA line function isn't terribly efficient but it's pretty
876 * straight-forward to understand. Also, it doesn't exactly conform
877 * to the specification.
879 static void aa_rgba_line( GLcontext
*ctx
,
880 GLuint vert0
, GLuint vert1
, GLuint pvert
)
882 #define INTERP_RGBA 1
883 #define PLOT(x, y) { PB_WRITE_RGBA_PIXEL( pb, (x), (y), z, red, green, blue, coverage ); }
884 #include "lnaatemp.h"
888 * Antialiased Textured RGBA line
890 * This AA line function isn't terribly efficient but it's pretty
891 * straight-forward to understand. Also, it doesn't exactly conform
892 * to the specification.
894 static void aa_tex_rgba_line( GLcontext
*ctx
,
895 GLuint vert0
, GLuint vert1
, GLuint pvert
)
897 #define INTERP_RGBA 1
898 #define INTERP_STUV0 1
901 PB_WRITE_TEX_PIXEL( pb, (x), (y), z, red, green, blue, coverage, \
904 #include "lnaatemp.h"
909 * Antialiased Multitextured RGBA line
911 * This AA line function isn't terribly efficient but it's pretty
912 * straight-forward to understand. Also, it doesn't exactly conform
913 * to the specification.
915 static void aa_multitex_rgba_line( GLcontext
*ctx
,
916 GLuint vert0
, GLuint vert1
, GLuint pvert
)
918 #define INTERP_RGBA 1
919 #define INTERP_SPEC 1
920 #define INTERP_STUV0 1
921 #define INTERP_STUV1 1
924 PB_WRITE_MULTITEX_SPEC_PIXEL( pb, (x), (y), z, \
925 red, green, blue, coverage, specRed, specGreen, specBlue, \
926 s, t, u, s1, t1, u1 ); \
928 #include "lnaatemp.h"
933 * Antialiased CI line. Same comments for RGBA antialiased lines apply.
935 static void aa_ci_line( GLcontext
*ctx
,
936 GLuint vert0
, GLuint vert1
, GLuint pvert
)
938 #define INTERP_INDEX 1
941 PB_WRITE_CI_PIXEL( pb, (x), (y), z, index + coverage ); \
943 #include "lnaatemp.h"
948 * Null rasterizer for measuring transformation speed.
950 static void null_line( GLcontext
*ctx
, GLuint v1
, GLuint v2
, GLuint pv
)
960 * Determine which line drawing function to use given the current
963 void gl_set_line_function( GLcontext
*ctx
)
965 GLboolean rgbmode
= ctx
->Visual
->RGBAflag
;
966 /* TODO: antialiased lines */
968 if (ctx
->RenderMode
==GL_RENDER
) {
970 ctx
->Driver
.LineFunc
= null_line
;
973 if (ctx
->Driver
.LineFunc
) {
974 /* Device driver will draw lines. */
978 if (ctx
->Line
.SmoothFlag
) {
979 /* antialiased lines */
981 if (ctx
->Texture
.ReallyEnabled
) {
982 if (ctx
->Texture
.ReallyEnabled
>= TEXTURE1_1D
983 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
)
985 ctx
->Driver
.LineFunc
= aa_multitex_rgba_line
;
987 ctx
->Driver
.LineFunc
= aa_tex_rgba_line
;
989 ctx
->Driver
.LineFunc
= aa_rgba_line
;
993 ctx
->Driver
.LineFunc
= aa_ci_line
;
996 else if (ctx
->Texture
.ReallyEnabled
) {
997 if (ctx
->Texture
.ReallyEnabled
>= TEXTURE1_1D
998 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
) {
999 /* multi-texture and/or separate specular color */
1000 ctx
->Driver
.LineFunc
= smooth_multitextured_line
;
1003 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1004 ctx
->Driver
.LineFunc
= smooth_textured_line
;
1007 ctx
->Driver
.LineFunc
= flat_textured_line
;
1011 else if (ctx
->Line
.Width
!=1.0 || ctx
->Line
.StippleFlag
1012 || ctx
->Line
.SmoothFlag
) {
1013 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1015 ctx
->Driver
.LineFunc
= general_smooth_rgba_line
;
1017 ctx
->Driver
.LineFunc
= general_smooth_ci_line
;
1021 ctx
->Driver
.LineFunc
= general_flat_rgba_line
;
1023 ctx
->Driver
.LineFunc
= general_flat_ci_line
;
1027 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1028 /* Width==1, non-stippled, smooth-shaded */
1030 || (ctx
->Fog
.Enabled
&& ctx
->Hint
.Fog
==GL_NICEST
)) {
1032 ctx
->Driver
.LineFunc
= smooth_rgba_z_line
;
1034 ctx
->Driver
.LineFunc
= smooth_ci_z_line
;
1038 ctx
->Driver
.LineFunc
= smooth_rgba_line
;
1040 ctx
->Driver
.LineFunc
= smooth_ci_line
;
1044 /* Width==1, non-stippled, flat-shaded */
1046 || (ctx
->Fog
.Enabled
&& ctx
->Hint
.Fog
==GL_NICEST
)) {
1048 ctx
->Driver
.LineFunc
= flat_rgba_z_line
;
1050 ctx
->Driver
.LineFunc
= flat_ci_z_line
;
1054 ctx
->Driver
.LineFunc
= flat_rgba_line
;
1056 ctx
->Driver
.LineFunc
= flat_ci_line
;
1061 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
1062 ctx
->Driver
.LineFunc
= gl_feedback_line
;
1065 /* GL_SELECT mode */
1066 ctx
->Driver
.LineFunc
= gl_select_line
;