1 /* $Id: s_lines.c,v 1.27 2002/04/12 15:39:59 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 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.
33 #include "s_context.h"
35 #include "s_feedback.h"
41 * Init the mask[] array to implement a line stipple.
44 compute_stipple_mask( GLcontext
*ctx
, GLuint len
, GLubyte mask
[] )
46 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
49 for (i
= 0; i
< len
; i
++) {
50 GLuint bit
= (swrast
->StippleCounter
/ ctx
->Line
.StippleFactor
) & 0xf;
51 if ((1 << bit
) & ctx
->Line
.StipplePattern
) {
57 swrast
->StippleCounter
++;
63 * To draw a wide line we can simply redraw the span N times, side by side.
66 draw_wide_line( GLcontext
*ctx
, struct sw_span
*span
, GLboolean xMajor
)
70 ASSERT(span
->end
< MAX_WIDTH
);
72 width
= (GLint
) CLAMP( ctx
->Line
.Width
, MIN_LINE_WIDTH
, MAX_LINE_WIDTH
);
77 start
= width
/ 2 - 1;
81 for (w
= 0; w
< width
; w
++) {
83 for (i
= 0; i
< span
->end
; i
++)
84 span
->yArray
[i
] -= start
;
87 for (i
= 0; i
< span
->end
; i
++)
90 if ((span
->interpMask
| span
->arrayMask
) & SPAN_TEXTURE
)
91 _mesa_write_texture_span(ctx
, span
);
92 else if ((span
->interpMask
| span
->arrayMask
) & SPAN_RGBA
)
93 _mesa_write_rgba_span(ctx
, span
);
95 _mesa_write_index_span(ctx
, span
);
100 for (w
= 0; w
< width
; w
++) {
102 for (i
= 0; i
< span
->end
; i
++)
103 span
->xArray
[i
] -= start
;
106 for (i
= 0; i
< span
->end
; i
++)
109 if ((span
->interpMask
| span
->arrayMask
) & SPAN_TEXTURE
)
110 _mesa_write_texture_span(ctx
, span
);
111 else if ((span
->interpMask
| span
->arrayMask
) & SPAN_RGBA
)
112 _mesa_write_rgba_span(ctx
, span
);
114 _mesa_write_index_span(ctx
, span
);
121 /**********************************************************************/
122 /***** Rasterization *****/
123 /**********************************************************************/
126 /* Flat, color index line */
127 static void flat_ci_line( GLcontext
*ctx
,
128 const SWvertex
*vert0
,
129 const SWvertex
*vert1
)
133 ASSERT(ctx
->Light
.ShadeModel
== GL_FLAT
);
134 ASSERT(!ctx
->Line
.StippleFlag
);
135 ASSERT(ctx
->Line
.Width
== 1.0F
);
137 INIT_SPAN(span
, GL_LINE
, 0, SPAN_INDEX
, SPAN_XY
);
138 /*span.arrayMask |= SPAN_XY;
139 span.interpMask |= SPAN_INDEX;*/
140 span
.index
= IntToFixed(vert1
->index
);
146 span.xArray[span.end] = X; \
147 span.yArray[span.end] = Y; \
151 #include "s_linetemp.h"
153 _mesa_write_index_span(ctx
, &span
);
157 /* Flat-shaded, RGBA line */
158 static void flat_rgba_line( GLcontext
*ctx
,
159 const SWvertex
*vert0
,
160 const SWvertex
*vert1
)
164 ASSERT(ctx
->Light
.ShadeModel
== GL_FLAT
);
165 ASSERT(!ctx
->Line
.StippleFlag
);
166 ASSERT(ctx
->Line
.Width
== 1.0F
);
168 INIT_SPAN(span
, GL_LINE
, 0, SPAN_RGBA
, SPAN_XY
);
169 /*span.arrayMask |= SPAN_XY;
170 span.interpMask |= SPAN_RGBA;*/
171 span
.red
= ChanToFixed(vert1
->color
[0]);
172 span
.green
= ChanToFixed(vert1
->color
[1]);
173 span
.blue
= ChanToFixed(vert1
->color
[2]);
174 span
.alpha
= ChanToFixed(vert1
->color
[3]);
183 span.xArray[span.end] = X; \
184 span.yArray[span.end] = Y; \
188 #include "s_linetemp.h"
190 _mesa_write_rgba_span(ctx
, &span
);
194 /* Smooth shaded, color index line */
195 static void smooth_ci_line( GLcontext
*ctx
,
196 const SWvertex
*vert0
,
197 const SWvertex
*vert1
)
201 ASSERT(ctx
->Light
.ShadeModel
== GL_SMOOTH
);
202 ASSERT(!ctx
->Line
.StippleFlag
);
203 ASSERT(ctx
->Line
.Width
== 1.0F
);
205 INIT_SPAN(span
, GL_LINE
, 0, 0, SPAN_XY
| SPAN_INDEX
);
206 /*span.arrayMask |= (SPAN_XY | SPAN_INDEX);*/
209 #define INTERP_INDEX 1
212 span.xArray[span.end] = X; \
213 span.yArray[span.end] = Y; \
214 span.color.index[span.end] = I; \
218 #include "s_linetemp.h"
220 _mesa_write_index_span(ctx
, &span
);
224 /* Smooth-shaded, RGBA line */
225 static void smooth_rgba_line( GLcontext
*ctx
,
226 const SWvertex
*vert0
,
227 const SWvertex
*vert1
)
231 ASSERT(ctx
->Light
.ShadeModel
== GL_SMOOTH
);
232 ASSERT(!ctx
->Line
.StippleFlag
);
233 ASSERT(ctx
->Line
.Width
== 1.0F
);
235 INIT_SPAN(span
, GL_LINE
, 0, 0, SPAN_XY
| SPAN_RGBA
);
236 /*span.arrayMask |= (SPAN_XY | SPAN_RGBA);*/
240 #define INTERP_ALPHA 1
243 span.xArray[span.end] = X; \
244 span.yArray[span.end] = Y; \
245 span.color.rgba[span.end][RCOMP] = FixedToInt(r0); \
246 span.color.rgba[span.end][GCOMP] = FixedToInt(g0); \
247 span.color.rgba[span.end][BCOMP] = FixedToInt(b0); \
248 span.color.rgba[span.end][ACOMP] = FixedToInt(a0); \
252 #include "s_linetemp.h"
254 _mesa_write_rgba_span(ctx
, &span
);
258 /* Smooth shaded, color index, any width, maybe stippled */
259 static void general_smooth_ci_line( GLcontext
*ctx
,
260 const SWvertex
*vert0
,
261 const SWvertex
*vert1
)
263 GLboolean xMajor
= GL_FALSE
;
266 ASSERT(ctx
->Light
.ShadeModel
== GL_SMOOTH
);
268 INIT_SPAN(span
, GL_LINE
, 0, 0,
269 SPAN_XY
| SPAN_Z
| SPAN_FOG
| SPAN_INDEX
);
270 /*span.arrayMask |= (SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_INDEX);*/
276 #define INTERP_INDEX 1
279 span.xArray[span.end] = X; \
280 span.yArray[span.end] = Y; \
281 span.zArray[span.end] = Z; \
282 span.fogArray[span.end] = fog0; \
283 span.color.index[span.end] = I; \
286 #include "s_linetemp.h"
288 if (ctx
->Line
.StippleFlag
) {
289 span
.arrayMask
|= SPAN_MASK
;
290 compute_stipple_mask(ctx
, span
.end
, span
.mask
);
293 if (ctx
->Line
.Width
> 1.0) {
294 draw_wide_line(ctx
, &span
, xMajor
);
297 _mesa_write_index_span(ctx
, &span
);
302 /* Flat shaded, color index, any width, maybe stippled */
303 static void general_flat_ci_line( GLcontext
*ctx
,
304 const SWvertex
*vert0
,
305 const SWvertex
*vert1
)
307 GLboolean xMajor
= GL_FALSE
;
310 ASSERT(ctx
->Light
.ShadeModel
== GL_FLAT
);
312 INIT_SPAN(span
, GL_LINE
, 0, SPAN_INDEX
,
313 SPAN_XY
| SPAN_Z
| SPAN_FOG
);
314 /*span.arrayMask |= (SPAN_XY | SPAN_Z | SPAN_FOG);
315 span.interpMask |= SPAN_INDEX;*/
316 span
.index
= IntToFixed(vert1
->index
);
325 span.xArray[span.end] = X; \
326 span.yArray[span.end] = Y; \
327 span.zArray[span.end] = Z; \
328 span.fogArray[span.end] = fog0; \
331 #include "s_linetemp.h"
333 if (ctx
->Line
.StippleFlag
) {
334 span
.arrayMask
|= SPAN_MASK
;
335 compute_stipple_mask(ctx
, span
.end
, span
.mask
);
338 if (ctx
->Line
.Width
> 1.0) {
339 draw_wide_line(ctx
, &span
, xMajor
);
342 _mesa_write_index_span(ctx
, &span
);
348 static void general_smooth_rgba_line( GLcontext
*ctx
,
349 const SWvertex
*vert0
,
350 const SWvertex
*vert1
)
352 GLboolean xMajor
= GL_FALSE
;
355 ASSERT(ctx
->Light
.ShadeModel
== GL_SMOOTH
);
357 INIT_SPAN(span
, GL_LINE
, 0, 0,
358 SPAN_XY
| SPAN_Z
| SPAN_FOG
| SPAN_RGBA
);
359 /*span.arrayMask |= (SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_RGBA);*/
366 #define INTERP_ALPHA 1
369 span.xArray[span.end] = X; \
370 span.yArray[span.end] = Y; \
371 span.zArray[span.end] = Z; \
372 span.color.rgba[span.end][RCOMP] = FixedToInt(r0); \
373 span.color.rgba[span.end][GCOMP] = FixedToInt(g0); \
374 span.color.rgba[span.end][BCOMP] = FixedToInt(b0); \
375 span.color.rgba[span.end][ACOMP] = FixedToInt(a0); \
376 span.fogArray[span.end] = fog0; \
379 #include "s_linetemp.h"
381 if (ctx
->Line
.StippleFlag
) {
382 span
.arrayMask
|= SPAN_MASK
;
383 compute_stipple_mask(ctx
, span
.end
, span
.mask
);
386 if (ctx
->Line
.Width
> 1.0) {
387 draw_wide_line(ctx
, &span
, xMajor
);
390 _mesa_write_rgba_span(ctx
, &span
);
395 static void general_flat_rgba_line( GLcontext
*ctx
,
396 const SWvertex
*vert0
,
397 const SWvertex
*vert1
)
399 GLboolean xMajor
= GL_FALSE
;
402 ASSERT(ctx
->Light
.ShadeModel
== GL_FLAT
);
404 INIT_SPAN(span
, GL_LINE
, 0, SPAN_RGBA
,
405 SPAN_XY
| SPAN_Z
| SPAN_FOG
);
406 /*span.arrayMask |= (SPAN_XY | SPAN_Z | SPAN_FOG);
407 span.interpMask |= SPAN_RGBA;*/
408 span
.red
= ChanToFixed(vert1
->color
[0]);
409 span
.green
= ChanToFixed(vert1
->color
[1]);
410 span
.blue
= ChanToFixed(vert1
->color
[2]);
411 span
.alpha
= ChanToFixed(vert1
->color
[3]);
423 span.xArray[span.end] = X; \
424 span.yArray[span.end] = Y; \
425 span.zArray[span.end] = Z; \
426 span.fogArray[span.end] = fog0; \
429 #include "s_linetemp.h"
431 if (ctx
->Line
.StippleFlag
) {
432 span
.arrayMask
|= SPAN_MASK
;
433 compute_stipple_mask(ctx
, span
.end
, span
.mask
);
436 if (ctx
->Line
.Width
> 1.0) {
437 draw_wide_line(ctx
, &span
, xMajor
);
440 _mesa_write_rgba_span(ctx
, &span
);
445 /* Flat-shaded, textured, any width, maybe stippled */
446 static void flat_textured_line( GLcontext
*ctx
,
447 const SWvertex
*vert0
,
448 const SWvertex
*vert1
)
450 GLboolean xMajor
= GL_FALSE
;
453 ASSERT(ctx
->Light
.ShadeModel
== GL_FLAT
);
455 INIT_SPAN(span
, GL_LINE
, 0, SPAN_RGBA
| SPAN_SPEC
,
456 SPAN_XY
| SPAN_Z
| SPAN_FOG
| SPAN_TEXTURE
| SPAN_RGBA
);
457 /*span.arrayMask |= (SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_TEXTURE | SPAN_LAMBDA);
458 span.interpMask |= (SPAN_RGBA | SPAN_SPEC);*/
459 span
.red
= ChanToFixed(vert1
->color
[0]);
460 span
.green
= ChanToFixed(vert1
->color
[1]);
461 span
.blue
= ChanToFixed(vert1
->color
[2]);
462 span
.alpha
= ChanToFixed(vert1
->color
[3]);
467 span
.specRed
= ChanToFixed(vert1
->specular
[0]);
468 span
.specGreen
= ChanToFixed(vert1
->specular
[1]);
469 span
.specBlue
= ChanToFixed(vert1
->specular
[2]);
470 span
.specRedStep
= 0;
471 span
.specGreenStep
= 0;
472 span
.specBlueStep
= 0;
481 span.xArray[span.end] = X; \
482 span.yArray[span.end] = Y; \
483 span.zArray[span.end] = Z; \
484 span.fogArray[span.end] = fog0; \
485 span.texcoords[0][span.end][0] = fragTexcoord[0]; \
486 span.texcoords[0][span.end][1] = fragTexcoord[1]; \
487 span.texcoords[0][span.end][2] = fragTexcoord[2]; \
488 span.lambda[0][span.end] = 0.0; \
491 #include "s_linetemp.h"
493 if (ctx
->Line
.StippleFlag
) {
494 span
.arrayMask
|= SPAN_MASK
;
495 compute_stipple_mask(ctx
, span
.end
, span
.mask
);
498 if (ctx
->Line
.Width
> 1.0) {
499 draw_wide_line(ctx
, &span
, xMajor
);
502 _mesa_write_texture_span(ctx
, &span
);
508 /* Smooth-shaded, textured, any width, maybe stippled */
509 static void smooth_textured_line( GLcontext
*ctx
,
510 const SWvertex
*vert0
,
511 const SWvertex
*vert1
)
513 GLboolean xMajor
= GL_FALSE
;
516 ASSERT(ctx
->Light
.ShadeModel
== GL_SMOOTH
);
518 INIT_SPAN(span
, GL_LINE
, 0, 0,
519 SPAN_XY
| SPAN_Z
| SPAN_FOG
| SPAN_RGBA
| SPAN_TEXTURE
| SPAN_LAMBDA
);
520 /*span.arrayMask |= (SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_RGBA | SPAN_TEXTURE | SPAN_LAMBDA);*/
527 #define INTERP_ALPHA 1
531 span.xArray[span.end] = X; \
532 span.yArray[span.end] = Y; \
533 span.zArray[span.end] = Z; \
534 span.fogArray[span.end] = fog0; \
535 span.color.rgba[span.end][RCOMP] = FixedToInt(r0); \
536 span.color.rgba[span.end][GCOMP] = FixedToInt(g0); \
537 span.color.rgba[span.end][BCOMP] = FixedToInt(b0); \
538 span.color.rgba[span.end][ACOMP] = FixedToInt(a0); \
539 span.texcoords[0][span.end][0] = fragTexcoord[0]; \
540 span.texcoords[0][span.end][1] = fragTexcoord[1]; \
541 span.texcoords[0][span.end][2] = fragTexcoord[2]; \
542 span.lambda[0][span.end] = 0.0; \
545 #include "s_linetemp.h"
547 if (ctx
->Line
.StippleFlag
) {
548 span
.arrayMask
|= SPAN_MASK
;
549 compute_stipple_mask(ctx
, span
.end
, span
.mask
);
552 if (ctx
->Line
.Width
> 1.0) {
553 draw_wide_line(ctx
, &span
, xMajor
);
556 _mesa_write_texture_span(ctx
, &span
);
561 /* Smooth-shaded, multitextured, any width, maybe stippled, separate specular
562 * color interpolation.
564 static void smooth_multitextured_line( GLcontext
*ctx
,
565 const SWvertex
*vert0
,
566 const SWvertex
*vert1
)
568 GLboolean xMajor
= GL_FALSE
;
572 ASSERT(ctx
->Light
.ShadeModel
== GL_SMOOTH
);
574 INIT_SPAN(span
, GL_LINE
, 0, 0,
575 SPAN_XY
| SPAN_Z
| SPAN_FOG
| SPAN_RGBA
| SPAN_SPEC
| SPAN_TEXTURE
| SPAN_LAMBDA
);
576 /*span.arrayMask |= (SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_RGBA | SPAN_SPEC | SPAN_TEXTURE | SPAN_LAMBDA);*/
583 #define INTERP_SPEC 1
584 #define INTERP_ALPHA 1
585 #define INTERP_MULTITEX 1
588 span.xArray[span.end] = X; \
589 span.yArray[span.end] = Y; \
590 span.zArray[span.end] = Z; \
591 span.fogArray[span.end] = fog0; \
592 span.color.rgba[span.end][RCOMP] = FixedToInt(r0); \
593 span.color.rgba[span.end][GCOMP] = FixedToInt(g0); \
594 span.color.rgba[span.end][BCOMP] = FixedToInt(b0); \
595 span.color.rgba[span.end][ACOMP] = FixedToInt(a0); \
596 span.specArray[span.end][RCOMP] = FixedToInt(sr0); \
597 span.specArray[span.end][GCOMP] = FixedToInt(sb0); \
598 span.specArray[span.end][BCOMP] = FixedToInt(sb0); \
599 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
600 if (ctx->Texture.Unit[u]._ReallyEnabled) { \
601 span.texcoords[u][span.end][0] = fragTexcoord[u][0]; \
602 span.texcoords[u][span.end][1] = fragTexcoord[u][1]; \
603 span.texcoords[u][span.end][2] = fragTexcoord[u][2]; \
604 span.lambda[u][span.end] = 0.0; \
609 #include "s_linetemp.h"
611 if (ctx
->Line
.StippleFlag
) {
612 span
.arrayMask
|= SPAN_MASK
;
613 compute_stipple_mask(ctx
, span
.end
, span
.mask
);
616 if (ctx
->Line
.Width
> 1.0) {
617 draw_wide_line(ctx
, &span
, xMajor
);
620 _mesa_write_texture_span(ctx
, &span
);
625 /* Flat-shaded, multitextured, any width, maybe stippled, separate specular
626 * color interpolation.
628 static void flat_multitextured_line( GLcontext
*ctx
,
629 const SWvertex
*vert0
,
630 const SWvertex
*vert1
)
632 GLboolean xMajor
= GL_FALSE
;
636 ASSERT(ctx
->Light
.ShadeModel
== GL_FLAT
);
638 INIT_SPAN(span
, GL_LINE
, 0, SPAN_RGBA
| SPAN_SPEC
,
639 SPAN_XY
| SPAN_Z
| SPAN_FOG
| SPAN_TEXTURE
| SPAN_LAMBDA
);
640 /*span.arrayMask |= (SPAN_XY | SPAN_Z | SPAN_FOG | SPAN_TEXTURE | SPAN_LAMBDA);
641 span.interpMask |= (SPAN_RGBA | SPAN_SPEC);*/
642 span
.red
= ChanToFixed(vert1
->color
[0]);
643 span
.green
= ChanToFixed(vert1
->color
[1]);
644 span
.blue
= ChanToFixed(vert1
->color
[2]);
645 span
.alpha
= ChanToFixed(vert1
->color
[3]);
650 span
.specRed
= ChanToFixed(vert1
->specular
[0]);
651 span
.specGreen
= ChanToFixed(vert1
->specular
[1]);
652 span
.specBlue
= ChanToFixed(vert1
->specular
[2]);
653 span
.specRedStep
= 0;
654 span
.specGreenStep
= 0;
655 span
.specBlueStep
= 0;
661 #define INTERP_MULTITEX 1
664 span.xArray[span.end] = X; \
665 span.yArray[span.end] = Y; \
666 span.zArray[span.end] = Z; \
667 span.fogArray[span.end] = fog0; \
668 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
669 if (ctx->Texture.Unit[u]._ReallyEnabled) { \
670 span.texcoords[u][span.end][0] = fragTexcoord[u][0]; \
671 span.texcoords[u][span.end][1] = fragTexcoord[u][1]; \
672 span.texcoords[u][span.end][2] = fragTexcoord[u][2]; \
673 span.lambda[u][span.end] = 0.0; \
678 #include "s_linetemp.h"
680 if (ctx
->Line
.StippleFlag
) {
681 span
.arrayMask
|= SPAN_MASK
;
682 compute_stipple_mask(ctx
, span
.end
, span
.mask
);
685 if (ctx
->Line
.Width
> 1.0) {
686 draw_wide_line(ctx
, &span
, xMajor
);
689 _mesa_write_texture_span(ctx
, &span
);
694 void _swrast_add_spec_terms_line( GLcontext
*ctx
,
698 SWvertex
*ncv0
= (SWvertex
*)v0
;
699 SWvertex
*ncv1
= (SWvertex
*)v1
;
701 COPY_CHAN4( c
[0], ncv0
->color
);
702 COPY_CHAN4( c
[1], ncv1
->color
);
703 ACC_3V( ncv0
->color
, ncv0
->specular
);
704 ACC_3V( ncv1
->color
, ncv1
->specular
);
705 SWRAST_CONTEXT(ctx
)->SpecLine( ctx
, ncv0
, ncv1
);
706 COPY_CHAN4( ncv0
->color
, c
[0] );
707 COPY_CHAN4( ncv1
->color
, c
[1] );
713 _mesa_print_line_function(GLcontext
*ctx
); /* silence compiler warning */
715 _mesa_print_line_function(GLcontext
*ctx
)
717 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
719 printf("Line Func == ");
720 if (swrast
->Line
== flat_ci_line
)
721 printf("flat_ci_line\n");
722 else if (swrast
->Line
== flat_rgba_line
)
723 printf("flat_rgba_line\n");
724 else if (swrast
->Line
== smooth_ci_line
)
725 printf("smooth_ci_line\n");
726 else if (swrast
->Line
== smooth_rgba_line
)
727 printf("smooth_rgba_line\n");
728 else if (swrast
->Line
== general_smooth_ci_line
)
729 printf("general_smooth_ci_line\n");
730 else if (swrast
->Line
== general_flat_ci_line
)
731 printf("general_flat_ci_line\n");
732 else if (swrast
->Line
== general_smooth_rgba_line
)
733 printf("general_smooth_rgba_line\n");
734 else if (swrast
->Line
== general_flat_rgba_line
)
735 printf("general_flat_rgba_line\n");
736 else if (swrast
->Line
== flat_textured_line
)
737 printf("flat_textured_line\n");
738 else if (swrast
->Line
== smooth_textured_line
)
739 printf("smooth_textured_line\n");
740 else if (swrast
->Line
== smooth_multitextured_line
)
741 printf("smooth_multitextured_line\n");
742 else if (swrast
->Line
== flat_multitextured_line
)
743 printf("flat_multitextured_line\n");
745 printf("Driver func %p\n", (void *) swrast
->Line
);
753 /* record the current line function name */
754 static const char *lineFuncName
= NULL
;
756 #define USE(lineFunc) \
758 lineFuncName = #lineFunc; \
759 /*printf("%s\n", lineFuncName);*/ \
760 swrast->Line = lineFunc; \
765 #define USE(lineFunc) swrast->Line = lineFunc
772 * Determine which line drawing function to use given the current
775 * Please update the summary flag _SWRAST_NEW_LINE if you add or remove
776 * tests to this code.
779 _swrast_choose_line( GLcontext
*ctx
)
781 SWcontext
*swrast
= SWRAST_CONTEXT(ctx
);
782 const GLboolean rgbmode
= ctx
->Visual
.rgbMode
;
784 if (ctx
->RenderMode
== GL_RENDER
) {
785 if (ctx
->Line
.SmoothFlag
) {
786 /* antialiased lines */
787 _swrast_choose_aa_line_function(ctx
);
788 ASSERT(swrast
->Triangle
);
790 else if (ctx
->Texture
._ReallyEnabled
) {
791 if (ctx
->Texture
._ReallyEnabled
> TEXTURE0_ANY
||
792 (ctx
->_TriangleCaps
& DD_SEPARATE_SPECULAR
)) {
793 /* multi-texture and/or separate specular color */
794 if (ctx
->Light
.ShadeModel
== GL_SMOOTH
)
795 USE(smooth_multitextured_line
);
797 USE(flat_multitextured_line
);
800 if (ctx
->Light
.ShadeModel
== GL_SMOOTH
) {
801 USE(smooth_textured_line
);
804 USE(flat_textured_line
);
809 if (ctx
->Light
.ShadeModel
== GL_SMOOTH
) {
810 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
|| ctx
->Line
.Width
!= 1.0
811 || ctx
->Line
.StippleFlag
) {
813 USE(general_smooth_rgba_line
);
815 USE(general_smooth_ci_line
);
819 USE(smooth_rgba_line
);
825 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
|| ctx
->Line
.Width
!= 1.0
826 || ctx
->Line
.StippleFlag
) {
828 USE(general_flat_rgba_line
);
830 USE(general_flat_ci_line
);
841 else if (ctx
->RenderMode
== GL_FEEDBACK
) {
842 USE(_mesa_feedback_line
);
845 ASSERT(ctx
->RenderMode
== GL_SELECT
);
846 USE(_mesa_select_line
);
849 /*_mesa_print_line_function(ctx);*/