1 /* $Id: s_lines.c,v 1.20 2001/08/20 16:41:47 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 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)
55 /* Flat, color index line */
56 static void flat_ci_line( GLcontext
*ctx
,
57 const SWvertex
*vert0
,
58 const SWvertex
*vert1
)
60 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
62 PB_SET_INDEX( PB
, vert0
->index
);
65 #define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, 0, 0);
67 #include "s_linetemp.h"
74 /* Flat, color index line with Z interpolation/testing */
75 static void flat_ci_z_line( GLcontext
*ctx
,
76 const SWvertex
*vert0
,
77 const SWvertex
*vert1
)
79 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
80 PB_SET_INDEX( PB
, vert0
->index
);
85 #define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0);
87 #include "s_linetemp.h"
94 /* Flat-shaded, RGBA line */
95 static void flat_rgba_line( GLcontext
*ctx
,
96 const SWvertex
*vert0
,
97 const SWvertex
*vert1
)
99 const GLchan
*color
= vert1
->color
;
100 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
101 PB_SET_COLOR( PB
, color
[0], color
[1], color
[2], color
[3] );
104 #define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, 0, 0);
106 #include "s_linetemp.h"
113 /* Flat-shaded, RGBA line with Z interpolation/testing */
114 static void flat_rgba_z_line( GLcontext
*ctx
,
115 const SWvertex
*vert0
,
116 const SWvertex
*vert1
)
118 const GLchan
*color
= vert1
->color
;
119 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
120 PB_SET_COLOR( PB
, color
[0], color
[1], color
[2], color
[3] );
125 #define PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0);
127 #include "s_linetemp.h"
134 /* Smooth shaded, color index line */
135 static void smooth_ci_line( GLcontext
*ctx
,
136 const SWvertex
*vert0
,
137 const SWvertex
*vert1
)
139 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
140 GLint count
= PB
->count
;
143 GLuint
*pbi
= PB
->index
;
148 #define INTERP_INDEX 1
156 #include "s_linetemp.h"
164 /* Smooth shaded, color index line with Z interpolation/testing */
165 static void smooth_ci_z_line( GLcontext
*ctx
,
166 const SWvertex
*vert0
,
167 const SWvertex
*vert1
)
169 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
170 GLint count
= PB
->count
;
173 GLdepth
*pbz
= PB
->z
;
174 GLuint
*pbi
= PB
->index
;
181 #define INTERP_INDEX 1
190 #include "s_linetemp.h"
198 /* Smooth-shaded, RGBA line */
199 static void smooth_rgba_line( GLcontext
*ctx
,
200 const SWvertex
*vert0
,
201 const SWvertex
*vert1
)
203 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
204 GLint count
= PB
->count
;
207 GLchan (*pbrgba
)[4] = PB
->rgba
;
213 #define INTERP_ALPHA 1
218 pbrgba[count][RCOMP] = FixedToInt(r0); \
219 pbrgba[count][GCOMP] = FixedToInt(g0); \
220 pbrgba[count][BCOMP] = FixedToInt(b0); \
221 pbrgba[count][ACOMP] = FixedToInt(a0); \
224 #include "s_linetemp.h"
232 /* Smooth-shaded, RGBA line with Z interpolation/testing */
233 static void smooth_rgba_z_line( GLcontext
*ctx
,
234 const SWvertex
*vert0
,
235 const SWvertex
*vert1
)
237 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
238 GLint count
= PB
->count
;
241 GLdepth
*pbz
= PB
->z
;
242 GLfloat
*pbfog
= PB
->fog
;
243 GLchan (*pbrgba
)[4] = PB
->rgba
;
252 #define INTERP_ALPHA 1
258 pbfog[count] = fog0; \
259 pbrgba[count][RCOMP] = FixedToInt(r0); \
260 pbrgba[count][GCOMP] = FixedToInt(g0); \
261 pbrgba[count][BCOMP] = FixedToInt(b0); \
262 pbrgba[count][ACOMP] = FixedToInt(a0); \
265 #include "s_linetemp.h"
272 #define CHECK_FULL(count) \
273 if (count >= PB_SIZE-MAX_WIDTH) { \
275 _mesa_flush_pb(ctx); \
281 /* Smooth shaded, color index, any width, maybe stippled */
282 static void general_smooth_ci_line( GLcontext
*ctx
,
283 const SWvertex
*vert0
,
284 const SWvertex
*vert1
)
286 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
287 GLint count
= PB
->count
;
290 GLdepth
*pbz
= PB
->z
;
291 GLfloat
*pbfog
= PB
->fog
;
292 GLuint
*pbi
= PB
->index
;
296 if (ctx
->Line
.StippleFlag
) {
301 #define INTERP_INDEX 1
308 pbfog[count] = fog0; \
312 #include "s_linetemp.h"
316 if (ctx
->Line
.Width
==2.0F
) {
317 /* special case: unstippled and width=2 */
321 #define INTERP_INDEX 1
322 #define XMAJOR_PLOT(X,Y) \
323 pbx[count] = X; pbx[count+1] = X; \
324 pby[count] = Y; pby[count+1] = Y+1; \
325 pbz[count] = Z; pbz[count+1] = Z; \
326 pbfog[count] = fog0; pbfog[count+1] = fog0; \
327 pbi[count] = I; pbi[count+1] = I; \
330 #define YMAJOR_PLOT(X,Y) \
331 pbx[count] = X; pbx[count+1] = X+1; \
332 pby[count] = Y; pby[count+1] = Y; \
333 pbz[count] = Z; pbz[count+1] = Z; \
334 pbfog[count] = fog0; pbfog[count+1] = fog0; \
335 pbi[count] = I; pbi[count+1] = I; \
338 #include "s_linetemp.h"
341 /* unstippled, any width */
345 #define INTERP_INDEX 1
352 pbfog[count] = fog0; \
355 #include "s_linetemp.h"
364 /* Flat shaded, color index, any width, maybe stippled */
365 static void general_flat_ci_line( GLcontext
*ctx
,
366 const SWvertex
*vert0
,
367 const SWvertex
*vert1
)
369 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
373 GLdepth
*pbz
= PB
->z
;
374 GLfloat
*pbfog
= PB
->fog
;
375 PB_SET_INDEX( PB
, vert0
->index
);
378 if (ctx
->Line
.StippleFlag
) {
379 /* stippled, any width */
389 pbfog[count] = fog0; \
392 #include "s_linetemp.h"
396 if (ctx
->Line
.Width
==2.0F
) {
397 /* special case: unstippled and width=2 */
401 #define XMAJOR_PLOT(X,Y) \
402 pbx[count] = X; pbx[count+1] = X; \
403 pby[count] = Y; pby[count+1] = Y+1; \
404 pbz[count] = Z; pbz[count+1] = Z; \
405 pbfog[count] = fog0; pbfog[count+1] = fog0; \
408 #define YMAJOR_PLOT(X,Y) \
409 pbx[count] = X; pbx[count+1] = X+1; \
410 pby[count] = Y; pby[count+1] = Y; \
411 pbz[count] = Z; pbz[count+1] = Z; \
412 pbfog[count] = fog0; pbfog[count+1] = fog0; \
415 #include "s_linetemp.h"
418 /* unstippled, any width */
427 pbfog[count] = fog0; \
430 #include "s_linetemp.h"
440 static void general_smooth_rgba_line( GLcontext
*ctx
,
441 const SWvertex
*vert0
,
442 const SWvertex
*vert1
)
444 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
445 GLint count
= PB
->count
;
448 GLdepth
*pbz
= PB
->z
;
449 GLfloat
*pbfog
= PB
->fog
;
450 GLchan (*pbrgba
)[4] = PB
->rgba
;
454 if (ctx
->Line
.StippleFlag
) {
460 #define INTERP_ALPHA 1
467 pbfog[count] = fog0; \
468 pbrgba[count][RCOMP] = FixedToInt(r0); \
469 pbrgba[count][GCOMP] = FixedToInt(g0); \
470 pbrgba[count][BCOMP] = FixedToInt(b0); \
471 pbrgba[count][ACOMP] = FixedToInt(a0); \
474 #include "s_linetemp.h"
478 if (ctx
->Line
.Width
==2.0F
) {
479 /* special case: unstippled and width=2 */
484 #define INTERP_ALPHA 1
485 #define XMAJOR_PLOT(X,Y) \
486 pbx[count] = X; pbx[count+1] = X; \
487 pby[count] = Y; pby[count+1] = Y+1; \
488 pbz[count] = Z; pbz[count+1] = Z; \
489 pbfog[count] = fog0; pbfog[count+1] = fog0; \
490 pbrgba[count][RCOMP] = FixedToInt(r0); \
491 pbrgba[count][GCOMP] = FixedToInt(g0); \
492 pbrgba[count][BCOMP] = FixedToInt(b0); \
493 pbrgba[count][ACOMP] = FixedToInt(a0); \
494 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
495 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
496 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
497 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
500 #define YMAJOR_PLOT(X,Y) \
501 pbx[count] = X; pbx[count+1] = X+1; \
502 pby[count] = Y; pby[count+1] = Y; \
503 pbz[count] = Z; pbz[count+1] = Z; \
504 pbfog[count] = fog0; pbfog[count+1] = fog0; \
505 pbrgba[count][RCOMP] = FixedToInt(r0); \
506 pbrgba[count][GCOMP] = FixedToInt(g0); \
507 pbrgba[count][BCOMP] = FixedToInt(b0); \
508 pbrgba[count][ACOMP] = FixedToInt(a0); \
509 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
510 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
511 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
512 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
515 #include "s_linetemp.h"
518 /* unstippled, any width */
523 #define INTERP_ALPHA 1
529 pbfog[count] = fog0; \
530 pbrgba[count][RCOMP] = FixedToInt(r0); \
531 pbrgba[count][GCOMP] = FixedToInt(g0); \
532 pbrgba[count][BCOMP] = FixedToInt(b0); \
533 pbrgba[count][ACOMP] = FixedToInt(a0); \
536 #include "s_linetemp.h"
545 static void general_flat_rgba_line( GLcontext
*ctx
,
546 const SWvertex
*vert0
,
547 const SWvertex
*vert1
)
549 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
550 const GLchan
*color
= vert1
->color
;
552 PB_SET_COLOR( PB
, color
[0], color
[1], color
[2], color
[3] );
554 if (ctx
->Line
.StippleFlag
) {
562 PB_WRITE_PIXEL(PB, X, Y, Z, fog0); \
565 #include "s_linetemp.h"
569 if (ctx
->Line
.Width
==2.0F
) {
570 /* special case: unstippled and width=2 */
574 #define XMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0); \
575 PB_WRITE_PIXEL(PB, X, Y+1, Z, fog0);
576 #define YMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(PB, X, Y, Z, fog0); \
577 PB_WRITE_PIXEL(PB, X+1, Y, Z, fog0);
578 #include "s_linetemp.h"
581 /* unstippled, any width */
587 PB_WRITE_PIXEL(PB, X, Y, Z, fog0); \
590 #include "s_linetemp.h"
598 /* Flat-shaded, textured, any width, maybe stippled */
599 static void flat_textured_line( GLcontext
*ctx
,
600 const SWvertex
*vert0
,
601 const SWvertex
*vert1
)
603 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
607 GLdepth
*pbz
= PB
->z
;
608 GLfloat
*pbfog
= PB
->fog
;
609 GLfloat
*pbs
= PB
->s
[0];
610 GLfloat
*pbt
= PB
->t
[0];
611 GLfloat
*pbu
= PB
->u
[0];
612 GLchan
*color
= (GLchan
*) vert1
->color
;
613 PB_SET_COLOR( PB
, color
[0], color
[1], color
[2], color
[3] );
616 if (ctx
->Line
.StippleFlag
) {
629 pbfog[count] = fog0; \
630 pbs[count] = fragTexcoord[0];\
631 pbt[count] = fragTexcoord[1];\
632 pbu[count] = fragTexcoord[2];\
636 #include "s_linetemp.h"
650 pbfog[count] = fog0; \
651 pbs[count] = fragTexcoord[0];\
652 pbt[count] = fragTexcoord[1];\
653 pbu[count] = fragTexcoord[2];\
657 #include "s_linetemp.h"
666 /* Smooth-shaded, textured, any width, maybe stippled */
667 static void smooth_textured_line( GLcontext
*ctx
,
668 const SWvertex
*vert0
,
669 const SWvertex
*vert1
)
671 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
672 GLint count
= PB
->count
;
675 GLdepth
*pbz
= PB
->z
;
676 GLfloat
*pbfog
= PB
->fog
;
677 GLfloat
*pbs
= PB
->s
[0];
678 GLfloat
*pbt
= PB
->t
[0];
679 GLfloat
*pbu
= PB
->u
[0];
680 GLchan (*pbrgba
)[4] = PB
->rgba
;
684 if (ctx
->Line
.StippleFlag
) {
690 #define INTERP_ALPHA 1
699 pbfog[count] = fog0; \
700 pbs[count] = fragTexcoord[0]; \
701 pbt[count] = fragTexcoord[1]; \
702 pbu[count] = fragTexcoord[2]; \
703 pbrgba[count][RCOMP] = FixedToInt(r0); \
704 pbrgba[count][GCOMP] = FixedToInt(g0); \
705 pbrgba[count][BCOMP] = FixedToInt(b0); \
706 pbrgba[count][ACOMP] = FixedToInt(a0); \
710 #include "s_linetemp.h"
718 #define INTERP_ALPHA 1
726 pbfog[count] = fog0; \
727 pbs[count] = fragTexcoord[0]; \
728 pbt[count] = fragTexcoord[1]; \
729 pbu[count] = fragTexcoord[2]; \
730 pbrgba[count][RCOMP] = FixedToInt(r0); \
731 pbrgba[count][GCOMP] = FixedToInt(g0); \
732 pbrgba[count][BCOMP] = FixedToInt(b0); \
733 pbrgba[count][ACOMP] = FixedToInt(a0); \
737 #include "s_linetemp.h"
745 /* Smooth-shaded, multitextured, any width, maybe stippled, separate specular
746 * color interpolation.
748 static void smooth_multitextured_line( GLcontext
*ctx
,
749 const SWvertex
*vert0
,
750 const SWvertex
*vert1
)
752 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
753 GLint count
= PB
->count
;
756 GLdepth
*pbz
= PB
->z
;
757 GLfloat
*pbfog
= PB
->fog
;
758 GLchan (*pbrgba
)[4] = PB
->rgba
;
759 GLchan (*pbspec
)[3] = PB
->spec
;
763 if (ctx
->Line
.StippleFlag
) {
769 #define INTERP_SPEC 1
770 #define INTERP_ALPHA 1
771 #define INTERP_MULTITEX 1
780 pbfog[count] = fog0; \
781 pbrgba[count][RCOMP] = FixedToInt(r0); \
782 pbrgba[count][GCOMP] = FixedToInt(g0); \
783 pbrgba[count][BCOMP] = FixedToInt(b0); \
784 pbrgba[count][ACOMP] = FixedToInt(a0); \
785 pbspec[count][RCOMP] = FixedToInt(sr0); \
786 pbspec[count][GCOMP] = FixedToInt(sg0); \
787 pbspec[count][BCOMP] = FixedToInt(sb0); \
788 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
789 if (ctx->Texture.Unit[u]._ReallyEnabled) { \
790 PB->s[u][count] = fragTexcoord[u][0]; \
791 PB->t[u][count] = fragTexcoord[u][1]; \
792 PB->u[u][count] = fragTexcoord[u][2]; \
798 #include "s_linetemp.h"
806 #define INTERP_SPEC 1
807 #define INTERP_ALPHA 1
808 #define INTERP_MULTITEX 1
816 pbfog[count] = fog0; \
817 pbrgba[count][RCOMP] = FixedToInt(r0); \
818 pbrgba[count][GCOMP] = FixedToInt(g0); \
819 pbrgba[count][BCOMP] = FixedToInt(b0); \
820 pbrgba[count][ACOMP] = FixedToInt(a0); \
821 pbspec[count][RCOMP] = FixedToInt(sr0); \
822 pbspec[count][GCOMP] = FixedToInt(sg0); \
823 pbspec[count][BCOMP] = FixedToInt(sb0); \
824 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
825 if (ctx->Texture.Unit[u]._ReallyEnabled) { \
826 PB->s[u][count] = fragTexcoord[u][0]; \
827 PB->t[u][count] = fragTexcoord[u][1]; \
828 PB->u[u][count] = fragTexcoord[u][2]; \
834 #include "s_linetemp.h"
842 /* Flat-shaded, multitextured, any width, maybe stippled, separate specular
843 * color interpolation.
845 static void flat_multitextured_line( GLcontext
*ctx
,
846 const SWvertex
*vert0
,
847 const SWvertex
*vert1
)
849 struct pixel_buffer
*PB
= SWRAST_CONTEXT(ctx
)->PB
;
850 GLint count
= PB
->count
;
853 GLdepth
*pbz
= PB
->z
;
854 GLfloat
*pbfog
= PB
->fog
;
855 GLchan (*pbrgba
)[4] = PB
->rgba
;
856 GLchan (*pbspec
)[3] = PB
->spec
;
857 GLchan
*color
= (GLchan
*) vert1
->color
;
858 GLchan sRed
= vert1
->specular
[0];
859 GLchan sGreen
= vert1
->specular
[1];
860 GLchan sBlue
= vert1
->specular
[2];
864 if (ctx
->Line
.StippleFlag
) {
869 #define INTERP_ALPHA 1
870 #define INTERP_MULTITEX 1
879 pbfog[count] = fog0; \
880 pbrgba[count][RCOMP] = color[0]; \
881 pbrgba[count][GCOMP] = color[1]; \
882 pbrgba[count][BCOMP] = color[2]; \
883 pbrgba[count][ACOMP] = color[3]; \
884 pbspec[count][RCOMP] = sRed; \
885 pbspec[count][GCOMP] = sGreen; \
886 pbspec[count][BCOMP] = sBlue; \
887 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
888 if (ctx->Texture.Unit[u]._ReallyEnabled) { \
889 PB->s[u][count] = fragTexcoord[u][0]; \
890 PB->t[u][count] = fragTexcoord[u][1]; \
891 PB->u[u][count] = fragTexcoord[u][2]; \
897 #include "s_linetemp.h"
904 #define INTERP_ALPHA 1
905 #define INTERP_MULTITEX 1
913 pbfog[count] = fog0; \
914 pbrgba[count][RCOMP] = color[0]; \
915 pbrgba[count][GCOMP] = color[1]; \
916 pbrgba[count][BCOMP] = color[2]; \
917 pbrgba[count][ACOMP] = color[3]; \
918 pbspec[count][RCOMP] = sRed; \
919 pbspec[count][GCOMP] = sGreen; \
920 pbspec[count][BCOMP] = sBlue; \
921 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
922 if (ctx->Texture.Unit[u]._ReallyEnabled) { \
923 PB->s[u][count] = fragTexcoord[u][0]; \
924 PB->t[u][count] = fragTexcoord[u][1]; \
925 PB->u[u][count] = fragTexcoord[u][2]; \
931 #include "s_linetemp.h"
939 void _swrast_add_spec_terms_line( GLcontext
*ctx
,
943 SWvertex
*ncv0
= (SWvertex
*)v0
;
944 SWvertex
*ncv1
= (SWvertex
*)v1
;
946 COPY_CHAN4( c
[0], ncv0
->color
);
947 COPY_CHAN4( c
[1], ncv1
->color
);
948 ACC_3V( ncv0
->color
, ncv0
->specular
);
949 ACC_3V( ncv1
->color
, ncv1
->specular
);
950 SWRAST_CONTEXT(ctx
)->SpecLine( ctx
, ncv0
, ncv1
);
951 COPY_CHAN4( ncv0
->color
, c
[0] );
952 COPY_CHAN4( ncv1
->color
, c
[1] );
958 _mesa_print_line_function(GLcontext
*ctx
); /* silence compiler warning */
960 _mesa_print_line_function(GLcontext
*ctx
)
962 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
964 printf("Line Func == ");
965 if (swrast
->Line
== flat_ci_line
)
966 printf("flat_ci_line\n");
967 else if (swrast
->Line
== flat_ci_z_line
)
968 printf("flat_ci_z_line\n");
969 else if (swrast
->Line
== flat_rgba_line
)
970 printf("flat_rgba_line\n");
971 else if (swrast
->Line
== flat_rgba_z_line
)
972 printf("flat_rgba_z_line\n");
973 else if (swrast
->Line
== smooth_ci_line
)
974 printf("smooth_ci_line\n");
975 else if (swrast
->Line
== smooth_ci_z_line
)
976 printf("smooth_ci_z_line\n");
977 else if (swrast
->Line
== smooth_rgba_line
)
978 printf("smooth_rgba_line\n");
979 else if (swrast
->Line
== smooth_rgba_z_line
)
980 printf("smooth_rgba_z_line\n");
981 else if (swrast
->Line
== general_smooth_ci_line
)
982 printf("general_smooth_ci_line\n");
983 else if (swrast
->Line
== general_flat_ci_line
)
984 printf("general_flat_ci_line\n");
985 else if (swrast
->Line
== general_smooth_rgba_line
)
986 printf("general_smooth_rgba_line\n");
987 else if (swrast
->Line
== general_flat_rgba_line
)
988 printf("general_flat_rgba_line\n");
989 else if (swrast
->Line
== flat_textured_line
)
990 printf("flat_textured_line\n");
991 else if (swrast
->Line
== smooth_textured_line
)
992 printf("smooth_textured_line\n");
993 else if (swrast
->Line
== smooth_multitextured_line
)
994 printf("smooth_multitextured_line\n");
995 else if (swrast
->Line
== flat_multitextured_line
)
996 printf("flat_multitextured_line\n");
998 printf("Driver func %p\n", swrast
->Line
);
1006 /* record the current line function name */
1007 static const char *lineFuncName
= NULL
;
1009 #define USE(lineFunc) \
1011 lineFuncName = #lineFunc; \
1012 /*printf("%s\n", lineFuncName);*/ \
1013 swrast->Line = lineFunc; \
1018 #define USE(lineFunc) swrast->Line = lineFunc;
1025 * Determine which line drawing function to use given the current
1026 * rendering context.
1028 * Please update the summary flag _SWRAST_NEW_LINE if you add or remove
1029 * tests to this code.
1032 _swrast_choose_line( GLcontext
*ctx
)
1034 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
1035 const GLboolean rgbmode
= ctx
->Visual
.rgbMode
;
1037 if (ctx
->RenderMode
==GL_RENDER
) {
1038 if (ctx
->Line
.SmoothFlag
) {
1039 /* antialiased lines */
1040 _swrast_choose_aa_line_function(ctx
);
1041 ASSERT(swrast
->Triangle
);
1043 else if (ctx
->Texture
._ReallyEnabled
) {
1044 if (ctx
->Texture
._ReallyEnabled
> TEXTURE0_ANY
||
1045 (ctx
->_TriangleCaps
& DD_SEPARATE_SPECULAR
)) {
1046 /* multi-texture and/or separate specular color */
1047 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
)
1048 USE(smooth_multitextured_line
);
1050 USE(flat_multitextured_line
);
1053 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1054 USE(smooth_textured_line
);
1057 USE(flat_textured_line
);
1061 else if (ctx
->Line
.Width
!=1.0 || ctx
->Line
.StippleFlag
) {
1062 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1064 USE(general_smooth_rgba_line
);
1066 USE(general_smooth_ci_line
);
1070 USE(general_flat_rgba_line
);
1072 USE(general_flat_ci_line
);
1076 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1077 /* Width==1, non-stippled, smooth-shaded */
1078 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
1080 USE(smooth_rgba_z_line
);
1082 USE(smooth_ci_z_line
);
1086 USE(smooth_rgba_line
);
1088 USE(smooth_ci_line
);
1092 /* Width==1, non-stippled, flat-shaded */
1093 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
1095 USE(flat_rgba_z_line
);
1097 USE(flat_ci_z_line
);
1101 USE(flat_rgba_line
);
1108 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
1109 USE(_mesa_feedback_line
);
1112 /* GL_SELECT mode */
1113 USE(_mesa_select_line
);
1116 /*_mesa_print_line_function(ctx);*/