1 /* $Id: s_lines.c,v 1.1 2000/10/31 18:00:04 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.
39 /**********************************************************************/
40 /***** Rasterization *****/
41 /**********************************************************************/
45 * There are 4 pairs (RGBA, CI) of line drawing functions:
46 * 1. simple: width=1 and no special rasterization functions (fastest)
47 * 2. flat: width=1, non-stippled, flat-shaded, any raster operations
48 * 3. smooth: width=1, non-stippled, smooth-shaded, any raster operations
49 * 4. general: any other kind of line (slowest)
54 * All line drawing functions have the same arguments:
55 * v1, v2 - indexes of first and second endpoints into vertex buffer arrays
56 * pv - provoking vertex: which vertex color/index to use for flat shading.
64 #if MAX_WIDTH > MAX_HEIGHT
65 # define MAXPOINTS MAX_WIDTH
67 # define MAXPOINTS MAX_HEIGHT
71 /* Flat, color index line */
72 static void flat_ci_line( GLcontext
*ctx
,
73 GLuint vert0
, GLuint vert1
, GLuint pvert
)
75 PB_SET_INDEX( ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
78 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, 0, 0);
80 #include "s_linetemp.h"
87 /* Flat, color index line with Z interpolation/testing */
88 static void flat_ci_z_line( GLcontext
*ctx
,
89 GLuint vert0
, GLuint vert1
, GLuint pvert
)
91 PB_SET_INDEX( ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
95 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
97 #include "s_linetemp.h"
104 /* Flat-shaded, RGBA line */
105 static void flat_rgba_line( GLcontext
*ctx
,
106 GLuint vert0
, GLuint vert1
, GLuint pvert
)
108 const GLchan
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
109 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
112 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, 0, 0);
114 #include "s_linetemp.h"
121 /* Flat-shaded, RGBA line with Z interpolation/testing */
122 static void flat_rgba_z_line( GLcontext
*ctx
,
123 GLuint vert0
, GLuint vert1
, GLuint pvert
)
125 const GLchan
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
126 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
130 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
132 #include "s_linetemp.h"
139 /* Smooth shaded, color index line */
140 static void smooth_ci_line( GLcontext
*ctx
,
141 GLuint vert0
, GLuint vert1
, GLuint pvert
)
143 GLint count
= ctx
->PB
->count
;
144 GLint
*pbx
= ctx
->PB
->x
;
145 GLint
*pby
= ctx
->PB
->y
;
146 GLuint
*pbi
= ctx
->PB
->index
;
149 ctx
->PB
->mono
= GL_FALSE
;
152 #define INTERP_INDEX 1
160 #include "s_linetemp.h"
162 ctx
->PB
->count
= count
;
168 /* Smooth shaded, color index line with Z interpolation/testing */
169 static void smooth_ci_z_line( GLcontext
*ctx
,
170 GLuint vert0
, GLuint vert1
, GLuint pvert
)
172 GLint count
= ctx
->PB
->count
;
173 GLint
*pbx
= ctx
->PB
->x
;
174 GLint
*pby
= ctx
->PB
->y
;
175 GLdepth
*pbz
= ctx
->PB
->z
;
176 GLuint
*pbi
= ctx
->PB
->index
;
179 ctx
->PB
->mono
= GL_FALSE
;
183 #define INTERP_INDEX 1
192 #include "s_linetemp.h"
194 ctx
->PB
->count
= count
;
200 /* Smooth-shaded, RGBA line */
201 static void smooth_rgba_line( GLcontext
*ctx
,
202 GLuint vert0
, GLuint vert1
, GLuint pvert
)
204 GLint count
= ctx
->PB
->count
;
205 GLint
*pbx
= ctx
->PB
->x
;
206 GLint
*pby
= ctx
->PB
->y
;
207 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
210 ctx
->PB
->mono
= GL_FALSE
;
214 #define INTERP_ALPHA 1
219 pbrgba[count][RCOMP] = FixedToInt(r0); \
220 pbrgba[count][GCOMP] = FixedToInt(g0); \
221 pbrgba[count][BCOMP] = FixedToInt(b0); \
222 pbrgba[count][ACOMP] = FixedToInt(a0); \
225 #include "s_linetemp.h"
227 ctx
->PB
->count
= count
;
233 /* Smooth-shaded, RGBA line with Z interpolation/testing */
234 static void smooth_rgba_z_line( GLcontext
*ctx
,
235 GLuint vert0
, GLuint vert1
, GLuint pvert
)
237 GLint count
= ctx
->PB
->count
;
238 GLint
*pbx
= ctx
->PB
->x
;
239 GLint
*pby
= ctx
->PB
->y
;
240 GLdepth
*pbz
= ctx
->PB
->z
;
241 GLfixed
*pbfog
= ctx
->PB
->fog
;
242 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
246 ctx
->PB
->mono
= GL_FALSE
;
251 #define INTERP_ALPHA 1
257 pbfog[count] = fog0; \
258 pbrgba[count][RCOMP] = FixedToInt(r0); \
259 pbrgba[count][GCOMP] = FixedToInt(g0); \
260 pbrgba[count][BCOMP] = FixedToInt(b0); \
261 pbrgba[count][ACOMP] = FixedToInt(a0); \
264 #include "s_linetemp.h"
266 ctx
->PB
->count
= count
;
271 #define CHECK_FULL(count) \
272 if (count >= PB_SIZE-MAX_WIDTH) { \
273 ctx->PB->count = count; \
275 count = ctx->PB->count; \
280 /* Smooth shaded, color index, any width, maybe stippled */
281 static void general_smooth_ci_line( GLcontext
*ctx
,
282 GLuint vert0
, GLuint vert1
, GLuint pvert
)
284 GLint count
= ctx
->PB
->count
;
285 GLint
*pbx
= ctx
->PB
->x
;
286 GLint
*pby
= ctx
->PB
->y
;
287 GLdepth
*pbz
= ctx
->PB
->z
;
288 GLfixed
*pbfog
= ctx
->PB
->fog
;
289 GLuint
*pbi
= ctx
->PB
->index
;
292 ctx
->PB
->mono
= GL_FALSE
;
294 if (ctx
->Line
.StippleFlag
) {
298 #define INTERP_INDEX 1
305 pbfog[count] = fog0; \
309 #include "s_linetemp.h"
313 if (ctx
->Line
.Width
==2.0F
) {
314 /* special case: unstippled and width=2 */
317 #define INTERP_INDEX 1
318 #define XMAJOR_PLOT(X,Y) \
319 pbx[count] = X; pbx[count+1] = X; \
320 pby[count] = Y; pby[count+1] = Y+1; \
321 pbz[count] = Z; pbz[count+1] = Z; \
322 pbfog[count] = fog0; pbfog[count+1] = fog0; \
323 pbi[count] = I; pbi[count+1] = I; \
326 #define YMAJOR_PLOT(X,Y) \
327 pbx[count] = X; pbx[count+1] = X+1; \
328 pby[count] = Y; pby[count+1] = Y; \
329 pbz[count] = Z; pbz[count+1] = Z; \
330 pbfog[count] = fog0; pbfog[count+1] = fog0; \
331 pbi[count] = I; pbi[count+1] = I; \
334 #include "s_linetemp.h"
337 /* unstippled, any width */
340 #define INTERP_INDEX 1
347 pbfog[count] = fog0; \
350 #include "s_linetemp.h"
354 ctx
->PB
->count
= count
;
359 /* Flat shaded, color index, any width, maybe stippled */
360 static void general_flat_ci_line( GLcontext
*ctx
,
361 GLuint vert0
, GLuint vert1
, GLuint pvert
)
364 GLint
*pbx
= ctx
->PB
->x
;
365 GLint
*pby
= ctx
->PB
->y
;
366 GLdepth
*pbz
= ctx
->PB
->z
;
367 GLfixed
*pbfog
= ctx
->PB
->fog
;
368 PB_SET_INDEX( ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
369 count
= ctx
->PB
->count
;
371 if (ctx
->Line
.StippleFlag
) {
372 /* stippled, any width */
381 pbfog[count] = fog0; \
384 #include "s_linetemp.h"
388 if (ctx
->Line
.Width
==2.0F
) {
389 /* special case: unstippled and width=2 */
392 #define XMAJOR_PLOT(X,Y) \
393 pbx[count] = X; pbx[count+1] = X; \
394 pby[count] = Y; pby[count+1] = Y+1; \
395 pbz[count] = Z; pbz[count+1] = Z; \
396 pbfog[count] = fog0; pbfog[count+1] = fog0; \
399 #define YMAJOR_PLOT(X,Y) \
400 pbx[count] = X; pbx[count+1] = X+1; \
401 pby[count] = Y; pby[count+1] = Y; \
402 pbz[count] = Z; pbz[count+1] = Z; \
403 pbfog[count] = fog0; pbfog[count+1] = fog0; \
406 #include "s_linetemp.h"
409 /* unstippled, any width */
417 pbfog[count] = fog0; \
420 #include "s_linetemp.h"
424 ctx
->PB
->count
= count
;
430 static void general_smooth_rgba_line( GLcontext
*ctx
,
431 GLuint vert0
, GLuint vert1
, GLuint pvert
)
433 GLint count
= ctx
->PB
->count
;
434 GLint
*pbx
= ctx
->PB
->x
;
435 GLint
*pby
= ctx
->PB
->y
;
436 GLdepth
*pbz
= ctx
->PB
->z
;
437 GLfixed
*pbfog
= ctx
->PB
->fog
;
438 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
442 ctx
->PB
->mono
= GL_FALSE
;
444 if (ctx
->Line
.StippleFlag
) {
449 #define INTERP_ALPHA 1
456 pbfog[count] = fog0; \
457 pbrgba[count][RCOMP] = FixedToInt(r0); \
458 pbrgba[count][GCOMP] = FixedToInt(g0); \
459 pbrgba[count][BCOMP] = FixedToInt(b0); \
460 pbrgba[count][ACOMP] = FixedToInt(a0); \
463 #include "s_linetemp.h"
467 if (ctx
->Line
.Width
==2.0F
) {
468 /* special case: unstippled and width=2 */
472 #define INTERP_ALPHA 1
473 #define XMAJOR_PLOT(X,Y) \
474 pbx[count] = X; pbx[count+1] = X; \
475 pby[count] = Y; pby[count+1] = Y+1; \
476 pbz[count] = Z; pbz[count+1] = Z; \
477 pbfog[count] = fog0; pbfog[count+1] = fog0; \
478 pbrgba[count][RCOMP] = FixedToInt(r0); \
479 pbrgba[count][GCOMP] = FixedToInt(g0); \
480 pbrgba[count][BCOMP] = FixedToInt(b0); \
481 pbrgba[count][ACOMP] = FixedToInt(a0); \
482 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
483 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
484 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
485 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
488 #define YMAJOR_PLOT(X,Y) \
489 pbx[count] = X; pbx[count+1] = X+1; \
490 pby[count] = Y; pby[count+1] = Y; \
491 pbz[count] = Z; pbz[count+1] = Z; \
492 pbfog[count] = fog0; pbfog[count+1] = fog0; \
493 pbrgba[count][RCOMP] = FixedToInt(r0); \
494 pbrgba[count][GCOMP] = FixedToInt(g0); \
495 pbrgba[count][BCOMP] = FixedToInt(b0); \
496 pbrgba[count][ACOMP] = FixedToInt(a0); \
497 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
498 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
499 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
500 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
503 #include "s_linetemp.h"
506 /* unstippled, any width */
510 #define INTERP_ALPHA 1
516 pbfog[count] = fog0; \
517 pbrgba[count][RCOMP] = FixedToInt(r0); \
518 pbrgba[count][GCOMP] = FixedToInt(g0); \
519 pbrgba[count][BCOMP] = FixedToInt(b0); \
520 pbrgba[count][ACOMP] = FixedToInt(a0); \
523 #include "s_linetemp.h"
527 ctx
->PB
->count
= count
;
532 static void general_flat_rgba_line( GLcontext
*ctx
,
533 GLuint vert0
, GLuint vert1
, GLuint pvert
)
535 const GLchan
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
536 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
538 if (ctx
->Line
.StippleFlag
) {
544 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
545 #include "s_linetemp.h"
549 if (ctx
->Line
.Width
==2.0F
) {
550 /* special case: unstippled and width=2 */
553 #define XMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0); \
554 PB_WRITE_PIXEL(ctx->PB, X, Y+1, Z, fog0);
555 #define YMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0); \
556 PB_WRITE_PIXEL(ctx->PB, X+1, Y, Z, fog0);
557 #include "s_linetemp.h"
560 /* unstippled, any width */
564 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
565 #include "s_linetemp.h"
573 /* Flat-shaded, textured, any width, maybe stippled */
574 static void flat_textured_line( GLcontext
*ctx
,
575 GLuint vert0
, GLuint vert1
, GLuint pv
)
578 GLint
*pbx
= ctx
->PB
->x
;
579 GLint
*pby
= ctx
->PB
->y
;
580 GLdepth
*pbz
= ctx
->PB
->z
;
581 GLfixed
*pbfog
= ctx
->PB
->fog
;
582 GLfloat
*pbs
= ctx
->PB
->s
[0];
583 GLfloat
*pbt
= ctx
->PB
->t
[0];
584 GLfloat
*pbu
= ctx
->PB
->u
[0];
585 GLchan
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
586 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
587 count
= ctx
->PB
->count
;
589 if (ctx
->Line
.StippleFlag
) {
601 pbfog[count] = fog0; \
602 pbs[count] = fragTexcoord[0];\
603 pbt[count] = fragTexcoord[1];\
604 pbu[count] = fragTexcoord[2];\
608 #include "s_linetemp.h"
621 pbfog[count] = fog0; \
622 pbs[count] = fragTexcoord[0];\
623 pbt[count] = fragTexcoord[1];\
624 pbu[count] = fragTexcoord[2];\
628 #include "s_linetemp.h"
631 ctx
->PB
->count
= count
;
637 /* Smooth-shaded, textured, any width, maybe stippled */
638 static void smooth_textured_line( GLcontext
*ctx
,
639 GLuint vert0
, GLuint vert1
, GLuint pvert
)
641 GLint count
= ctx
->PB
->count
;
642 GLint
*pbx
= ctx
->PB
->x
;
643 GLint
*pby
= ctx
->PB
->y
;
644 GLdepth
*pbz
= ctx
->PB
->z
;
645 GLfixed
*pbfog
= ctx
->PB
->fog
;
646 GLfloat
*pbs
= ctx
->PB
->s
[0];
647 GLfloat
*pbt
= ctx
->PB
->t
[0];
648 GLfloat
*pbu
= ctx
->PB
->u
[0];
649 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
652 ctx
->PB
->mono
= GL_FALSE
;
654 if (ctx
->Line
.StippleFlag
) {
659 #define INTERP_ALPHA 1
668 pbfog[count] = fog0; \
669 pbs[count] = fragTexcoord[0]; \
670 pbt[count] = fragTexcoord[1]; \
671 pbu[count] = fragTexcoord[2]; \
672 pbrgba[count][RCOMP] = FixedToInt(r0); \
673 pbrgba[count][GCOMP] = FixedToInt(g0); \
674 pbrgba[count][BCOMP] = FixedToInt(b0); \
675 pbrgba[count][ACOMP] = FixedToInt(a0); \
679 #include "s_linetemp.h"
686 #define INTERP_ALPHA 1
694 pbfog[count] = fog0; \
695 pbs[count] = fragTexcoord[0]; \
696 pbt[count] = fragTexcoord[1]; \
697 pbu[count] = fragTexcoord[2]; \
698 pbrgba[count][RCOMP] = FixedToInt(r0); \
699 pbrgba[count][GCOMP] = FixedToInt(g0); \
700 pbrgba[count][BCOMP] = FixedToInt(b0); \
701 pbrgba[count][ACOMP] = FixedToInt(a0); \
705 #include "s_linetemp.h"
708 ctx
->PB
->count
= count
;
713 /* Smooth-shaded, multitextured, any width, maybe stippled, separate specular
714 * color interpolation.
716 static void smooth_multitextured_line( GLcontext
*ctx
,
717 GLuint vert0
, GLuint vert1
, GLuint pvert
)
719 GLint count
= ctx
->PB
->count
;
720 GLint
*pbx
= ctx
->PB
->x
;
721 GLint
*pby
= ctx
->PB
->y
;
722 GLdepth
*pbz
= ctx
->PB
->z
;
723 GLfixed
*pbfog
= ctx
->PB
->fog
;
724 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
725 GLchan (*pbspec
)[3] = ctx
->PB
->spec
;
729 ctx
->PB
->mono
= GL_FALSE
;
731 if (ctx
->Line
.StippleFlag
) {
736 #define INTERP_SPEC 1
737 #define INTERP_ALPHA 1
738 #define INTERP_MULTITEX 1
747 pbfog[count] = fog0; \
748 pbrgba[count][RCOMP] = FixedToInt(r0); \
749 pbrgba[count][GCOMP] = FixedToInt(g0); \
750 pbrgba[count][BCOMP] = FixedToInt(b0); \
751 pbrgba[count][ACOMP] = FixedToInt(a0); \
752 pbspec[count][RCOMP] = FixedToInt(sr0); \
753 pbspec[count][GCOMP] = FixedToInt(sg0); \
754 pbspec[count][BCOMP] = FixedToInt(sb0); \
755 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
756 if (ctx->Texture.Unit[u].ReallyEnabled) { \
757 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
758 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
759 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
760 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
766 #include "s_linetemp.h"
773 #define INTERP_SPEC 1
774 #define INTERP_ALPHA 1
775 #define INTERP_MULTITEX 1
783 pbfog[count] = fog0; \
784 pbrgba[count][RCOMP] = FixedToInt(r0); \
785 pbrgba[count][GCOMP] = FixedToInt(g0); \
786 pbrgba[count][BCOMP] = FixedToInt(b0); \
787 pbrgba[count][ACOMP] = FixedToInt(a0); \
788 pbspec[count][RCOMP] = FixedToInt(sr0); \
789 pbspec[count][GCOMP] = FixedToInt(sg0); \
790 pbspec[count][BCOMP] = FixedToInt(sb0); \
791 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
792 if (ctx->Texture.Unit[u].ReallyEnabled) { \
793 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
794 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
795 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
796 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
802 #include "s_linetemp.h"
805 ctx
->PB
->count
= count
;
810 /* Flat-shaded, multitextured, any width, maybe stippled, separate specular
811 * color interpolation.
813 static void flat_multitextured_line( GLcontext
*ctx
,
814 GLuint vert0
, GLuint vert1
, GLuint pvert
)
816 GLint count
= ctx
->PB
->count
;
817 GLint
*pbx
= ctx
->PB
->x
;
818 GLint
*pby
= ctx
->PB
->y
;
819 GLdepth
*pbz
= ctx
->PB
->z
;
820 GLfixed
*pbfog
= ctx
->PB
->fog
;
821 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
822 GLchan (*pbspec
)[3] = ctx
->PB
->spec
;
823 GLchan
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
824 GLchan sRed
= ctx
->VB
->SecondaryColorPtr
->data
? ctx
->VB
->SecondaryColorPtr
->data
[pvert
][0] : 0;
825 GLchan sGreen
= ctx
->VB
->SecondaryColorPtr
->data
? ctx
->VB
->SecondaryColorPtr
->data
[pvert
][1] : 0;
826 GLchan sBlue
= ctx
->VB
->SecondaryColorPtr
->data
? ctx
->VB
->SecondaryColorPtr
->data
[pvert
][2] : 0;
830 ctx
->PB
->mono
= GL_FALSE
;
832 if (ctx
->Line
.StippleFlag
) {
836 #define INTERP_ALPHA 1
837 #define INTERP_MULTITEX 1
846 pbfog[count] = fog0; \
847 pbrgba[count][RCOMP] = color[0]; \
848 pbrgba[count][GCOMP] = color[1]; \
849 pbrgba[count][BCOMP] = color[2]; \
850 pbrgba[count][ACOMP] = color[3]; \
851 pbspec[count][RCOMP] = sRed; \
852 pbspec[count][GCOMP] = sGreen; \
853 pbspec[count][BCOMP] = sBlue; \
854 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
855 if (ctx->Texture.Unit[u].ReallyEnabled) { \
856 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
857 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
858 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
859 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
865 #include "s_linetemp.h"
871 #define INTERP_ALPHA 1
872 #define INTERP_MULTITEX 1
880 pbfog[count] = fog0; \
881 pbrgba[count][RCOMP] = color[0]; \
882 pbrgba[count][GCOMP] = color[1]; \
883 pbrgba[count][BCOMP] = color[2]; \
884 pbrgba[count][ACOMP] = color[3]; \
885 pbspec[count][RCOMP] = sRed; \
886 pbspec[count][GCOMP] = sGreen; \
887 pbspec[count][BCOMP] = sBlue; \
888 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
889 if (ctx->Texture.Unit[u].ReallyEnabled) { \
890 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
891 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
892 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
893 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
899 #include "s_linetemp.h"
902 ctx
->PB
->count
= count
;
910 * Antialiased RGBA line
912 * This AA line function isn't terribly efficient but it's pretty
913 * straight-forward to understand. Also, it doesn't exactly conform
914 * to the specification.
916 static void aa_rgba_line( GLcontext
*ctx
,
917 GLuint vert0
, GLuint vert1
, GLuint pvert
)
919 #define INTERP_RGBA 1
922 PB_WRITE_RGBA_PIXEL( pb, (x), (y), z, fog0, \
923 red, green, blue, coverage ); \
925 #include "s_lnaatemp.h"
929 * Antialiased Textured RGBA line
931 * This AA line function isn't terribly efficient but it's pretty
932 * straight-forward to understand. Also, it doesn't exactly conform
933 * to the specification.
935 static void aa_tex_rgba_line( GLcontext
*ctx
,
936 GLuint vert0
, GLuint vert1
, GLuint pvert
)
938 #define INTERP_RGBA 1
942 PB_WRITE_TEX_PIXEL( pb, (x), (y), z, fog0, \
943 red, green, blue, coverage, \
944 fragTexcoord[0], fragTexcoord[1], fragTexcoord[2] ); \
946 #include "s_lnaatemp.h"
951 * Antialiased Multitextured RGBA line
953 * This AA line function isn't terribly efficient but it's pretty
954 * straight-forward to understand. Also, it doesn't exactly conform
955 * to the specification.
957 static void aa_multitex_rgba_line( GLcontext
*ctx
,
958 GLuint vert0
, GLuint vert1
, GLuint pvert
)
960 #define INTERP_RGBA 1
961 #define INTERP_SPEC 1
962 #define INTERP_MULTITEX 1
965 PB_WRITE_MULTITEX_SPEC_PIXEL( pb, (x), (y), z, fog0, \
966 red, green, blue, coverage, specRed, specGreen, specBlue, \
969 #include "s_lnaatemp.h"
974 * Antialiased CI line. Same comments for RGBA antialiased lines apply.
976 static void aa_ci_line( GLcontext
*ctx
,
977 GLuint vert0
, GLuint vert1
, GLuint pvert
)
979 #define INTERP_INDEX 1
982 PB_WRITE_CI_PIXEL( pb, (x), (y), z, fog0, index + coverage ); \
984 #include "s_lnaatemp.h"
989 * Null rasterizer for measuring transformation speed.
991 static void null_line( GLcontext
*ctx
, GLuint v1
, GLuint v2
, GLuint pv
)
1003 _mesa_print_line_function(GLcontext
*ctx
)
1005 printf("Line Func == ");
1006 if (ctx
->Driver
.LineFunc
== flat_ci_line
)
1007 printf("flat_ci_line\n");
1008 else if (ctx
->Driver
.LineFunc
== flat_ci_z_line
)
1009 printf("flat_ci_z_line\n");
1010 else if (ctx
->Driver
.LineFunc
== flat_rgba_line
)
1011 printf("flat_rgba_line\n");
1012 else if (ctx
->Driver
.LineFunc
== flat_rgba_z_line
)
1013 printf("flat_rgba_z_line\n");
1014 else if (ctx
->Driver
.LineFunc
== smooth_ci_line
)
1015 printf("smooth_ci_line\n");
1016 else if (ctx
->Driver
.LineFunc
== smooth_ci_z_line
)
1017 printf("smooth_ci_z_line\n");
1018 else if (ctx
->Driver
.LineFunc
== smooth_rgba_line
)
1019 printf("smooth_rgba_line\n");
1020 else if (ctx
->Driver
.LineFunc
== smooth_rgba_z_line
)
1021 printf("smooth_rgba_z_line\n");
1022 else if (ctx
->Driver
.LineFunc
== general_smooth_ci_line
)
1023 printf("general_smooth_ci_line\n");
1024 else if (ctx
->Driver
.LineFunc
== general_flat_ci_line
)
1025 printf("general_flat_ci_line\n");
1026 else if (ctx
->Driver
.LineFunc
== general_smooth_rgba_line
)
1027 printf("general_smooth_rgba_line\n");
1028 else if (ctx
->Driver
.LineFunc
== general_flat_rgba_line
)
1029 printf("general_flat_rgba_line\n");
1030 else if (ctx
->Driver
.LineFunc
== flat_textured_line
)
1031 printf("flat_textured_line\n");
1032 else if (ctx
->Driver
.LineFunc
== smooth_textured_line
)
1033 printf("smooth_textured_line\n");
1034 else if (ctx
->Driver
.LineFunc
== smooth_multitextured_line
)
1035 printf("smooth_multitextured_line\n");
1036 else if (ctx
->Driver
.LineFunc
== flat_multitextured_line
)
1037 printf("flat_multitextured_line\n");
1038 else if (ctx
->Driver
.LineFunc
== aa_rgba_line
)
1039 printf("aa_rgba_line\n");
1040 else if (ctx
->Driver
.LineFunc
== aa_tex_rgba_line
)
1041 printf("aa_tex_rgba_line\n");
1042 else if (ctx
->Driver
.LineFunc
== aa_multitex_rgba_line
)
1043 printf("aa_multitex_rgba_line\n");
1044 else if (ctx
->Driver
.LineFunc
== aa_ci_line
)
1045 printf("aa_ci_line\n");
1046 else if (ctx
->Driver
.LineFunc
== null_line
)
1047 printf("null_line\n");
1049 printf("Driver func %p\n", ctx
->Driver
.LineFunc
);
1056 * Determine which line drawing function to use given the current
1057 * rendering context.
1059 * Please update the summary flag _SWRAST_NEW_LINE if you add or remove
1060 * tests to this code.
1063 _swrast_set_line_function( GLcontext
*ctx
)
1065 GLboolean rgbmode
= ctx
->Visual
.RGBAflag
;
1066 /* TODO: antialiased lines */
1068 if (ctx
->RenderMode
==GL_RENDER
) {
1069 if (ctx
->NoRaster
) {
1070 ctx
->Driver
.LineFunc
= null_line
;
1073 if (ctx
->Driver
.LineFunc
) {
1074 /* Device driver will draw lines. */
1078 if (ctx
->Line
.SmoothFlag
) {
1079 /* antialiased lines */
1081 if (ctx
->Texture
.ReallyEnabled
) {
1082 if (ctx
->Texture
.MultiTextureEnabled
1083 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
1084 || ctx
->Fog
.ColorSumEnabled
)
1085 /* Multitextured! */
1086 ctx
->Driver
.LineFunc
= aa_multitex_rgba_line
;
1088 ctx
->Driver
.LineFunc
= aa_tex_rgba_line
;
1090 ctx
->Driver
.LineFunc
= aa_rgba_line
;
1094 ctx
->Driver
.LineFunc
= aa_ci_line
;
1097 else if (ctx
->Texture
.ReallyEnabled
) {
1098 if (ctx
->Texture
.MultiTextureEnabled
1099 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
1100 || ctx
->Fog
.ColorSumEnabled
) {
1101 /* multi-texture and/or separate specular color */
1102 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
)
1103 ctx
->Driver
.LineFunc
= smooth_multitextured_line
;
1105 ctx
->Driver
.LineFunc
= flat_multitextured_line
;
1108 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1109 ctx
->Driver
.LineFunc
= smooth_textured_line
;
1112 ctx
->Driver
.LineFunc
= flat_textured_line
;
1116 else if (ctx
->Line
.Width
!=1.0 || ctx
->Line
.StippleFlag
1117 || ctx
->Line
.SmoothFlag
) {
1118 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1120 ctx
->Driver
.LineFunc
= general_smooth_rgba_line
;
1122 ctx
->Driver
.LineFunc
= general_smooth_ci_line
;
1126 ctx
->Driver
.LineFunc
= general_flat_rgba_line
;
1128 ctx
->Driver
.LineFunc
= general_flat_ci_line
;
1132 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1133 /* Width==1, non-stippled, smooth-shaded */
1134 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
1136 ctx
->Driver
.LineFunc
= smooth_rgba_z_line
;
1138 ctx
->Driver
.LineFunc
= smooth_ci_z_line
;
1142 ctx
->Driver
.LineFunc
= smooth_rgba_line
;
1144 ctx
->Driver
.LineFunc
= smooth_ci_line
;
1148 /* Width==1, non-stippled, flat-shaded */
1149 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
1151 ctx
->Driver
.LineFunc
= flat_rgba_z_line
;
1153 ctx
->Driver
.LineFunc
= flat_ci_z_line
;
1157 ctx
->Driver
.LineFunc
= flat_rgba_line
;
1159 ctx
->Driver
.LineFunc
= flat_ci_line
;
1164 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
1165 ctx
->Driver
.LineFunc
= gl_feedback_line
;
1168 /* GL_SELECT mode */
1169 ctx
->Driver
.LineFunc
= gl_select_line
;
1172 /*_mesa_print_line_function(ctx);*/