1 /* $Id: s_lines.c,v 1.2 2000/11/05 18:24:40 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 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.
34 #include "s_context.h"
37 #include "s_feedback.h"
41 /**********************************************************************/
42 /***** Rasterization *****/
43 /**********************************************************************/
47 * There are 4 pairs (RGBA, CI) of line drawing functions:
48 * 1. simple: width=1 and no special rasterization functions (fastest)
49 * 2. flat: width=1, non-stippled, flat-shaded, any raster operations
50 * 3. smooth: width=1, non-stippled, smooth-shaded, any raster operations
51 * 4. general: any other kind of line (slowest)
56 * All line drawing functions have the same arguments:
57 * v1, v2 - indexes of first and second endpoints into vertex buffer arrays
65 #if MAX_WIDTH > MAX_HEIGHT
66 # define MAXPOINTS MAX_WIDTH
68 # define MAXPOINTS MAX_HEIGHT
72 /* Flat, color index line */
73 static void flat_ci_line( GLcontext
*ctx
,
77 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
79 PB_SET_INDEX( PB
, vert0
->index
);
82 #define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, 0, 0);
84 #include "s_linetemp.h"
91 /* Flat, color index line with Z interpolation/testing */
92 static void flat_ci_z_line( GLcontext
*ctx
,
96 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
97 PB_SET_INDEX( PB
, vert0
->index
);
101 #define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0);
103 #include "s_linetemp.h"
110 /* Flat-shaded, RGBA line */
111 static void flat_rgba_line( GLcontext
*ctx
,
115 const GLchan
*color
= vert0
->color
;
116 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
117 PB_SET_COLOR( PB
, color
[0], color
[1], color
[2], color
[3] );
120 #define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, 0, 0);
122 #include "s_linetemp.h"
129 /* Flat-shaded, RGBA line with Z interpolation/testing */
130 static void flat_rgba_z_line( GLcontext
*ctx
,
134 const GLchan
*color
= vert0
->color
;
135 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
136 PB_SET_COLOR( PB
, color
[0], color
[1], color
[2], color
[3] );
140 #define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0);
142 #include "s_linetemp.h"
149 /* Smooth shaded, color index line */
150 static void smooth_ci_line( GLcontext
*ctx
,
154 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
155 GLint count
= PB
->count
;
158 GLuint
*pbi
= PB
->index
;
163 #define INTERP_INDEX 1
171 #include "s_linetemp.h"
179 /* Smooth shaded, color index line with Z interpolation/testing */
180 static void smooth_ci_z_line( GLcontext
*ctx
,
184 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
185 GLint count
= PB
->count
;
188 GLdepth
*pbz
= PB
->z
;
189 GLuint
*pbi
= PB
->index
;
195 #define INTERP_INDEX 1
204 #include "s_linetemp.h"
212 /* Smooth-shaded, RGBA line */
213 static void smooth_rgba_line( GLcontext
*ctx
,
217 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
218 GLint count
= PB
->count
;
221 GLchan (*pbrgba
)[4] = PB
->rgba
;
227 #define INTERP_ALPHA 1
232 pbrgba[count][RCOMP] = FixedToInt(r0); \
233 pbrgba[count][GCOMP] = FixedToInt(g0); \
234 pbrgba[count][BCOMP] = FixedToInt(b0); \
235 pbrgba[count][ACOMP] = FixedToInt(a0); \
238 #include "s_linetemp.h"
246 /* Smooth-shaded, RGBA line with Z interpolation/testing */
247 static void smooth_rgba_z_line( GLcontext
*ctx
,
251 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
252 GLint count
= PB
->count
;
255 GLdepth
*pbz
= PB
->z
;
256 GLfixed
*pbfog
= PB
->fog
;
257 GLchan (*pbrgba
)[4] = PB
->rgba
;
265 #define INTERP_ALPHA 1
271 pbfog[count] = fog0; \
272 pbrgba[count][RCOMP] = FixedToInt(r0); \
273 pbrgba[count][GCOMP] = FixedToInt(g0); \
274 pbrgba[count][BCOMP] = FixedToInt(b0); \
275 pbrgba[count][ACOMP] = FixedToInt(a0); \
278 #include "s_linetemp.h"
285 #define CHECK_FULL(count) \
286 if (count >= PB_SIZE-MAX_WIDTH) { \
294 /* Smooth shaded, color index, any width, maybe stippled */
295 static void general_smooth_ci_line( GLcontext
*ctx
,
299 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
300 GLint count
= PB
->count
;
303 GLdepth
*pbz
= PB
->z
;
304 GLfixed
*pbfog
= PB
->fog
;
305 GLuint
*pbi
= PB
->index
;
309 if (ctx
->Line
.StippleFlag
) {
313 #define INTERP_INDEX 1
320 pbfog[count] = fog0; \
324 #include "s_linetemp.h"
328 if (ctx
->Line
.Width
==2.0F
) {
329 /* special case: unstippled and width=2 */
332 #define INTERP_INDEX 1
333 #define XMAJOR_PLOT(X,Y) \
334 pbx[count] = X; pbx[count+1] = X; \
335 pby[count] = Y; pby[count+1] = Y+1; \
336 pbz[count] = Z; pbz[count+1] = Z; \
337 pbfog[count] = fog0; pbfog[count+1] = fog0; \
338 pbi[count] = I; pbi[count+1] = I; \
341 #define YMAJOR_PLOT(X,Y) \
342 pbx[count] = X; pbx[count+1] = X+1; \
343 pby[count] = Y; pby[count+1] = Y; \
344 pbz[count] = Z; pbz[count+1] = Z; \
345 pbfog[count] = fog0; pbfog[count+1] = fog0; \
346 pbi[count] = I; pbi[count+1] = I; \
349 #include "s_linetemp.h"
352 /* unstippled, any width */
355 #define INTERP_INDEX 1
362 pbfog[count] = fog0; \
365 #include "s_linetemp.h"
374 /* Flat shaded, color index, any width, maybe stippled */
375 static void general_flat_ci_line( GLcontext
*ctx
,
379 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
383 GLdepth
*pbz
= PB
->z
;
384 GLfixed
*pbfog
= PB
->fog
;
385 PB_SET_INDEX( PB
, vert0
->index
);
388 if (ctx
->Line
.StippleFlag
) {
389 /* stippled, any width */
398 pbfog[count] = fog0; \
401 #include "s_linetemp.h"
405 if (ctx
->Line
.Width
==2.0F
) {
406 /* special case: unstippled and width=2 */
409 #define XMAJOR_PLOT(X,Y) \
410 pbx[count] = X; pbx[count+1] = X; \
411 pby[count] = Y; pby[count+1] = Y+1; \
412 pbz[count] = Z; pbz[count+1] = Z; \
413 pbfog[count] = fog0; pbfog[count+1] = fog0; \
416 #define YMAJOR_PLOT(X,Y) \
417 pbx[count] = X; pbx[count+1] = X+1; \
418 pby[count] = Y; pby[count+1] = Y; \
419 pbz[count] = Z; pbz[count+1] = Z; \
420 pbfog[count] = fog0; pbfog[count+1] = fog0; \
423 #include "s_linetemp.h"
426 /* unstippled, any width */
434 pbfog[count] = fog0; \
437 #include "s_linetemp.h"
447 static void general_smooth_rgba_line( GLcontext
*ctx
,
451 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
452 GLint count
= PB
->count
;
455 GLdepth
*pbz
= PB
->z
;
456 GLfixed
*pbfog
= PB
->fog
;
457 GLchan (*pbrgba
)[4] = PB
->rgba
;
461 if (ctx
->Line
.StippleFlag
) {
466 #define INTERP_ALPHA 1
473 pbfog[count] = fog0; \
474 pbrgba[count][RCOMP] = FixedToInt(r0); \
475 pbrgba[count][GCOMP] = FixedToInt(g0); \
476 pbrgba[count][BCOMP] = FixedToInt(b0); \
477 pbrgba[count][ACOMP] = FixedToInt(a0); \
480 #include "s_linetemp.h"
484 if (ctx
->Line
.Width
==2.0F
) {
485 /* special case: unstippled and width=2 */
489 #define INTERP_ALPHA 1
490 #define XMAJOR_PLOT(X,Y) \
491 pbx[count] = X; pbx[count+1] = X; \
492 pby[count] = Y; pby[count+1] = Y+1; \
493 pbz[count] = Z; pbz[count+1] = Z; \
494 pbfog[count] = fog0; pbfog[count+1] = fog0; \
495 pbrgba[count][RCOMP] = FixedToInt(r0); \
496 pbrgba[count][GCOMP] = FixedToInt(g0); \
497 pbrgba[count][BCOMP] = FixedToInt(b0); \
498 pbrgba[count][ACOMP] = FixedToInt(a0); \
499 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
500 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
501 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
502 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
505 #define YMAJOR_PLOT(X,Y) \
506 pbx[count] = X; pbx[count+1] = X+1; \
507 pby[count] = Y; pby[count+1] = Y; \
508 pbz[count] = Z; pbz[count+1] = Z; \
509 pbfog[count] = fog0; pbfog[count+1] = fog0; \
510 pbrgba[count][RCOMP] = FixedToInt(r0); \
511 pbrgba[count][GCOMP] = FixedToInt(g0); \
512 pbrgba[count][BCOMP] = FixedToInt(b0); \
513 pbrgba[count][ACOMP] = FixedToInt(a0); \
514 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
515 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
516 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
517 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
520 #include "s_linetemp.h"
523 /* unstippled, any width */
527 #define INTERP_ALPHA 1
533 pbfog[count] = fog0; \
534 pbrgba[count][RCOMP] = FixedToInt(r0); \
535 pbrgba[count][GCOMP] = FixedToInt(g0); \
536 pbrgba[count][BCOMP] = FixedToInt(b0); \
537 pbrgba[count][ACOMP] = FixedToInt(a0); \
540 #include "s_linetemp.h"
549 static void general_flat_rgba_line( GLcontext
*ctx
,
553 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
554 const GLchan
*color
= vert0
->color
;
555 PB_SET_COLOR( PB
, color
[0], color
[1], color
[2], color
[3] );
557 if (ctx
->Line
.StippleFlag
) {
563 #define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0);
564 #include "s_linetemp.h"
568 if (ctx
->Line
.Width
==2.0F
) {
569 /* special case: unstippled and width=2 */
572 #define XMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0); \
573 PB_WRITE_PIXEL(PB, X, Y+1, Z, fog0);
574 #define YMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0); \
575 PB_WRITE_PIXEL(PB, X+1, Y, Z, fog0);
576 #include "s_linetemp.h"
579 /* unstippled, any width */
583 #define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0);
584 #include "s_linetemp.h"
592 /* Flat-shaded, textured, any width, maybe stippled */
593 static void flat_textured_line( GLcontext
*ctx
,
597 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
601 GLdepth
*pbz
= PB
->z
;
602 GLfixed
*pbfog
= PB
->fog
;
603 GLfloat
*pbs
= PB
->s
[0];
604 GLfloat
*pbt
= PB
->t
[0];
605 GLfloat
*pbu
= PB
->u
[0];
606 GLchan
*color
= vert0
->color
;
607 PB_SET_COLOR( PB
, color
[0], color
[1], color
[2], color
[3] );
610 if (ctx
->Line
.StippleFlag
) {
622 pbfog[count] = fog0; \
623 pbs[count] = fragTexcoord[0];\
624 pbt[count] = fragTexcoord[1];\
625 pbu[count] = fragTexcoord[2];\
629 #include "s_linetemp.h"
642 pbfog[count] = fog0; \
643 pbs[count] = fragTexcoord[0];\
644 pbt[count] = fragTexcoord[1];\
645 pbu[count] = fragTexcoord[2];\
649 #include "s_linetemp.h"
658 /* Smooth-shaded, textured, any width, maybe stippled */
659 static void smooth_textured_line( GLcontext
*ctx
,
663 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
664 GLint count
= PB
->count
;
667 GLdepth
*pbz
= PB
->z
;
668 GLfixed
*pbfog
= PB
->fog
;
669 GLfloat
*pbs
= PB
->s
[0];
670 GLfloat
*pbt
= PB
->t
[0];
671 GLfloat
*pbu
= PB
->u
[0];
672 GLchan (*pbrgba
)[4] = PB
->rgba
;
676 if (ctx
->Line
.StippleFlag
) {
681 #define INTERP_ALPHA 1
690 pbfog[count] = fog0; \
691 pbs[count] = fragTexcoord[0]; \
692 pbt[count] = fragTexcoord[1]; \
693 pbu[count] = fragTexcoord[2]; \
694 pbrgba[count][RCOMP] = FixedToInt(r0); \
695 pbrgba[count][GCOMP] = FixedToInt(g0); \
696 pbrgba[count][BCOMP] = FixedToInt(b0); \
697 pbrgba[count][ACOMP] = FixedToInt(a0); \
701 #include "s_linetemp.h"
708 #define INTERP_ALPHA 1
716 pbfog[count] = fog0; \
717 pbs[count] = fragTexcoord[0]; \
718 pbt[count] = fragTexcoord[1]; \
719 pbu[count] = fragTexcoord[2]; \
720 pbrgba[count][RCOMP] = FixedToInt(r0); \
721 pbrgba[count][GCOMP] = FixedToInt(g0); \
722 pbrgba[count][BCOMP] = FixedToInt(b0); \
723 pbrgba[count][ACOMP] = FixedToInt(a0); \
727 #include "s_linetemp.h"
735 /* Smooth-shaded, multitextured, any width, maybe stippled, separate specular
736 * color interpolation.
738 static void smooth_multitextured_line( GLcontext
*ctx
,
742 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
743 GLint count
= PB
->count
;
746 GLdepth
*pbz
= PB
->z
;
747 GLfixed
*pbfog
= PB
->fog
;
748 GLchan (*pbrgba
)[4] = PB
->rgba
;
749 GLchan (*pbspec
)[3] = PB
->spec
;
753 if (ctx
->Line
.StippleFlag
) {
758 #define INTERP_SPEC 1
759 #define INTERP_ALPHA 1
760 #define INTERP_MULTITEX 1
769 pbfog[count] = fog0; \
770 pbrgba[count][RCOMP] = FixedToInt(r0); \
771 pbrgba[count][GCOMP] = FixedToInt(g0); \
772 pbrgba[count][BCOMP] = FixedToInt(b0); \
773 pbrgba[count][ACOMP] = FixedToInt(a0); \
774 pbspec[count][RCOMP] = FixedToInt(sr0); \
775 pbspec[count][GCOMP] = FixedToInt(sg0); \
776 pbspec[count][BCOMP] = FixedToInt(sb0); \
777 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
778 if (ctx->Texture.Unit[u]._ReallyEnabled) { \
779 PB->s[u][0] = fragTexcoord[u][0]; \
780 PB->s[u][1] = fragTexcoord[u][1]; \
781 PB->s[u][2] = fragTexcoord[u][2]; \
782 PB->s[u][3] = fragTexcoord[u][3]; \
788 #include "s_linetemp.h"
795 #define INTERP_SPEC 1
796 #define INTERP_ALPHA 1
797 #define INTERP_MULTITEX 1
805 pbfog[count] = fog0; \
806 pbrgba[count][RCOMP] = FixedToInt(r0); \
807 pbrgba[count][GCOMP] = FixedToInt(g0); \
808 pbrgba[count][BCOMP] = FixedToInt(b0); \
809 pbrgba[count][ACOMP] = FixedToInt(a0); \
810 pbspec[count][RCOMP] = FixedToInt(sr0); \
811 pbspec[count][GCOMP] = FixedToInt(sg0); \
812 pbspec[count][BCOMP] = FixedToInt(sb0); \
813 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
814 if (ctx->Texture.Unit[u]._ReallyEnabled) { \
815 PB->s[u][0] = fragTexcoord[u][0]; \
816 PB->s[u][1] = fragTexcoord[u][1]; \
817 PB->s[u][2] = fragTexcoord[u][2]; \
818 PB->s[u][3] = fragTexcoord[u][3]; \
824 #include "s_linetemp.h"
832 /* Flat-shaded, multitextured, any width, maybe stippled, separate specular
833 * color interpolation.
835 static void flat_multitextured_line( GLcontext
*ctx
,
839 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
840 GLint count
= PB
->count
;
843 GLdepth
*pbz
= PB
->z
;
844 GLfixed
*pbfog
= PB
->fog
;
845 GLchan (*pbrgba
)[4] = PB
->rgba
;
846 GLchan (*pbspec
)[3] = PB
->spec
;
847 GLchan
*color
= vert0
->color
;
848 GLchan sRed
= vert0
->specular
[0];
849 GLchan sGreen
= vert0
->specular
[1];
850 GLchan sBlue
= vert0
->specular
[2];
854 if (ctx
->Line
.StippleFlag
) {
858 #define INTERP_ALPHA 1
859 #define INTERP_MULTITEX 1
868 pbfog[count] = fog0; \
869 pbrgba[count][RCOMP] = color[0]; \
870 pbrgba[count][GCOMP] = color[1]; \
871 pbrgba[count][BCOMP] = color[2]; \
872 pbrgba[count][ACOMP] = color[3]; \
873 pbspec[count][RCOMP] = sRed; \
874 pbspec[count][GCOMP] = sGreen; \
875 pbspec[count][BCOMP] = sBlue; \
876 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
877 if (ctx->Texture.Unit[u]._ReallyEnabled) { \
878 PB->s[u][0] = fragTexcoord[u][0]; \
879 PB->s[u][1] = fragTexcoord[u][1]; \
880 PB->s[u][2] = fragTexcoord[u][2]; \
881 PB->s[u][3] = fragTexcoord[u][3]; \
887 #include "s_linetemp.h"
893 #define INTERP_ALPHA 1
894 #define INTERP_MULTITEX 1
902 pbfog[count] = fog0; \
903 pbrgba[count][RCOMP] = color[0]; \
904 pbrgba[count][GCOMP] = color[1]; \
905 pbrgba[count][BCOMP] = color[2]; \
906 pbrgba[count][ACOMP] = color[3]; \
907 pbspec[count][RCOMP] = sRed; \
908 pbspec[count][GCOMP] = sGreen; \
909 pbspec[count][BCOMP] = sBlue; \
910 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
911 if (ctx->Texture.Unit[u]._ReallyEnabled) { \
912 PB->s[u][0] = fragTexcoord[u][0]; \
913 PB->s[u][1] = fragTexcoord[u][1]; \
914 PB->s[u][2] = fragTexcoord[u][2]; \
915 PB->s[u][3] = fragTexcoord[u][3]; \
921 #include "s_linetemp.h"
932 * Antialiased RGBA line
934 * This AA line function isn't terribly efficient but it's pretty
935 * straight-forward to understand. Also, it doesn't exactly conform
936 * to the specification.
938 static void aa_rgba_line( GLcontext
*ctx
,
942 #define INTERP_RGBA 1
945 PB_WRITE_RGBA_PIXEL( pb, (x), (y), z, fog0, \
946 red, green, blue, coverage ); \
948 #include "s_lnaatemp.h"
952 * Antialiased Textured RGBA line
954 * This AA line function isn't terribly efficient but it's pretty
955 * straight-forward to understand. Also, it doesn't exactly conform
956 * to the specification.
958 static void aa_tex_rgba_line( GLcontext
*ctx
,
962 #define INTERP_RGBA 1
966 PB_WRITE_TEX_PIXEL( pb, (x), (y), z, fog0, \
967 red, green, blue, coverage, \
968 fragTexcoord[0], fragTexcoord[1], fragTexcoord[2] ); \
970 #include "s_lnaatemp.h"
975 * Antialiased Multitextured RGBA line
977 * This AA line function isn't terribly efficient but it's pretty
978 * straight-forward to understand. Also, it doesn't exactly conform
979 * to the specification.
981 static void aa_multitex_rgba_line( GLcontext
*ctx
,
985 #define INTERP_RGBA 1
986 #define INTERP_SPEC 1
987 #define INTERP_MULTITEX 1
990 PB_WRITE_MULTITEX_SPEC_PIXEL( pb, (x), (y), z, fog0, \
991 red, green, blue, coverage, specRed, specGreen, specBlue, \
994 #include "s_lnaatemp.h"
999 * Antialiased CI line. Same comments for RGBA antialiased lines apply.
1001 static void aa_ci_line( GLcontext
*ctx
,
1005 #define INTERP_INDEX 1
1006 #define PLOT(x, y) \
1008 PB_WRITE_CI_PIXEL( pb, (x), (y), z, fog0, index + coverage ); \
1010 #include "s_lnaatemp.h"
1017 _mesa_print_line_function(GLcontext
*ctx
)
1019 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1021 printf("Line Func == ");
1022 if (swrast
->Line
== flat_ci_line
)
1023 printf("flat_ci_line\n");
1024 else if (swrast
->Line
== flat_ci_z_line
)
1025 printf("flat_ci_z_line\n");
1026 else if (swrast
->Line
== flat_rgba_line
)
1027 printf("flat_rgba_line\n");
1028 else if (swrast
->Line
== flat_rgba_z_line
)
1029 printf("flat_rgba_z_line\n");
1030 else if (swrast
->Line
== smooth_ci_line
)
1031 printf("smooth_ci_line\n");
1032 else if (swrast
->Line
== smooth_ci_z_line
)
1033 printf("smooth_ci_z_line\n");
1034 else if (swrast
->Line
== smooth_rgba_line
)
1035 printf("smooth_rgba_line\n");
1036 else if (swrast
->Line
== smooth_rgba_z_line
)
1037 printf("smooth_rgba_z_line\n");
1038 else if (swrast
->Line
== general_smooth_ci_line
)
1039 printf("general_smooth_ci_line\n");
1040 else if (swrast
->Line
== general_flat_ci_line
)
1041 printf("general_flat_ci_line\n");
1042 else if (swrast
->Line
== general_smooth_rgba_line
)
1043 printf("general_smooth_rgba_line\n");
1044 else if (swrast
->Line
== general_flat_rgba_line
)
1045 printf("general_flat_rgba_line\n");
1046 else if (swrast
->Line
== flat_textured_line
)
1047 printf("flat_textured_line\n");
1048 else if (swrast
->Line
== smooth_textured_line
)
1049 printf("smooth_textured_line\n");
1050 else if (swrast
->Line
== smooth_multitextured_line
)
1051 printf("smooth_multitextured_line\n");
1052 else if (swrast
->Line
== flat_multitextured_line
)
1053 printf("flat_multitextured_line\n");
1054 else if (swrast
->Line
== aa_rgba_line
)
1055 printf("aa_rgba_line\n");
1056 else if (swrast
->Line
== aa_tex_rgba_line
)
1057 printf("aa_tex_rgba_line\n");
1058 else if (swrast
->Line
== aa_multitex_rgba_line
)
1059 printf("aa_multitex_rgba_line\n");
1060 else if (swrast
->Line
== aa_ci_line
)
1061 printf("aa_ci_line\n");
1063 printf("Driver func %p\n", swrast
->Line
);
1070 * Determine which line drawing function to use given the current
1071 * rendering context.
1073 * Please update the summary flag _SWRAST_NEW_LINE if you add or remove
1074 * tests to this code.
1077 _swrast_choose_line( GLcontext
*ctx
)
1079 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1081 GLboolean rgbmode
= ctx
->Visual
.RGBAflag
;
1082 /* TODO: antialiased lines */
1084 if (ctx
->RenderMode
==GL_RENDER
) {
1085 if (ctx
->Line
.SmoothFlag
) {
1086 /* antialiased lines */
1088 if (ctx
->Texture
._ReallyEnabled
) {
1089 if (ctx
->Texture
._MultiTextureEnabled
1090 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
1091 || ctx
->Fog
.ColorSumEnabled
)
1092 /* Multitextured! */
1093 swrast
->Line
= aa_multitex_rgba_line
;
1095 swrast
->Line
= aa_tex_rgba_line
;
1097 swrast
->Line
= aa_rgba_line
;
1101 swrast
->Line
= aa_ci_line
;
1104 else if (ctx
->Texture
._ReallyEnabled
) {
1105 if (ctx
->Texture
._MultiTextureEnabled
1106 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
1107 || ctx
->Fog
.ColorSumEnabled
) {
1108 /* multi-texture and/or separate specular color */
1109 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
)
1110 swrast
->Line
= smooth_multitextured_line
;
1112 swrast
->Line
= flat_multitextured_line
;
1115 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1116 swrast
->Line
= smooth_textured_line
;
1119 swrast
->Line
= flat_textured_line
;
1123 else if (ctx
->Line
.Width
!=1.0 || ctx
->Line
.StippleFlag
1124 || ctx
->Line
.SmoothFlag
) {
1125 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1127 swrast
->Line
= general_smooth_rgba_line
;
1129 swrast
->Line
= general_smooth_ci_line
;
1133 swrast
->Line
= general_flat_rgba_line
;
1135 swrast
->Line
= general_flat_ci_line
;
1139 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1140 /* Width==1, non-stippled, smooth-shaded */
1141 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
1143 swrast
->Line
= smooth_rgba_z_line
;
1145 swrast
->Line
= smooth_ci_z_line
;
1149 swrast
->Line
= smooth_rgba_line
;
1151 swrast
->Line
= smooth_ci_line
;
1155 /* Width==1, non-stippled, flat-shaded */
1156 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
1158 swrast
->Line
= flat_rgba_z_line
;
1160 swrast
->Line
= flat_ci_z_line
;
1164 swrast
->Line
= flat_rgba_line
;
1166 swrast
->Line
= flat_ci_line
;
1171 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
1172 swrast
->Line
= gl_feedback_line
;
1175 /* GL_SELECT mode */
1176 swrast
->Line
= gl_select_line
;
1179 /*_mesa_print_line_function(ctx);*/