1 /* $Id: lines.c,v 1.19 2000/10/30 13:32:00 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.
47 _mesa_LineWidth( GLfloat width
)
49 GET_CURRENT_CONTEXT(ctx
);
51 gl_error( ctx
, GL_INVALID_VALUE
, "glLineWidth" );
54 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glLineWidth");
56 if (ctx
->Line
.Width
!= width
) {
57 ctx
->Line
.Width
= width
;
58 ctx
->TriangleCaps
&= ~DD_LINE_WIDTH
;
59 if (width
!= 1.0) ctx
->TriangleCaps
|= DD_LINE_WIDTH
;
61 ctx
->NewState
|= _NEW_LINE
;
63 if (ctx
->Driver
.LineWidth
)
64 (*ctx
->Driver
.LineWidth
)(ctx
, width
);
71 _mesa_LineStipple( GLint factor
, GLushort pattern
)
73 GET_CURRENT_CONTEXT(ctx
);
74 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glLineStipple");
75 ctx
->Line
.StippleFactor
= CLAMP( factor
, 1, 256 );
76 ctx
->Line
.StipplePattern
= pattern
;
78 ctx
->NewState
|= _NEW_LINE
;
80 if (ctx
->Driver
.LineStipple
)
81 ctx
->Driver
.LineStipple( ctx
, factor
, pattern
);
86 /**********************************************************************/
87 /***** Rasterization *****/
88 /**********************************************************************/
92 * There are 4 pairs (RGBA, CI) of line drawing functions:
93 * 1. simple: width=1 and no special rasterization functions (fastest)
94 * 2. flat: width=1, non-stippled, flat-shaded, any raster operations
95 * 3. smooth: width=1, non-stippled, smooth-shaded, any raster operations
96 * 4. general: any other kind of line (slowest)
101 * All line drawing functions have the same arguments:
102 * v1, v2 - indexes of first and second endpoints into vertex buffer arrays
103 * pv - provoking vertex: which vertex color/index to use for flat shading.
111 #if MAX_WIDTH > MAX_HEIGHT
112 # define MAXPOINTS MAX_WIDTH
114 # define MAXPOINTS MAX_HEIGHT
118 /* Flat, color index line */
119 static void flat_ci_line( GLcontext
*ctx
,
120 GLuint vert0
, GLuint vert1
, GLuint pvert
)
122 PB_SET_INDEX( ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
125 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, 0, 0);
127 #include "linetemp.h"
134 /* Flat, color index line with Z interpolation/testing */
135 static void flat_ci_z_line( GLcontext
*ctx
,
136 GLuint vert0
, GLuint vert1
, GLuint pvert
)
138 PB_SET_INDEX( ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
142 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
144 #include "linetemp.h"
151 /* Flat-shaded, RGBA line */
152 static void flat_rgba_line( GLcontext
*ctx
,
153 GLuint vert0
, GLuint vert1
, GLuint pvert
)
155 const GLchan
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
156 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
159 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, 0, 0);
161 #include "linetemp.h"
168 /* Flat-shaded, RGBA line with Z interpolation/testing */
169 static void flat_rgba_z_line( GLcontext
*ctx
,
170 GLuint vert0
, GLuint vert1
, GLuint pvert
)
172 const GLchan
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
173 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
177 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
179 #include "linetemp.h"
186 /* Smooth shaded, color index line */
187 static void smooth_ci_line( GLcontext
*ctx
,
188 GLuint vert0
, GLuint vert1
, GLuint pvert
)
190 GLint count
= ctx
->PB
->count
;
191 GLint
*pbx
= ctx
->PB
->x
;
192 GLint
*pby
= ctx
->PB
->y
;
193 GLuint
*pbi
= ctx
->PB
->index
;
196 ctx
->PB
->mono
= GL_FALSE
;
199 #define INTERP_INDEX 1
207 #include "linetemp.h"
209 ctx
->PB
->count
= count
;
215 /* Smooth shaded, color index line with Z interpolation/testing */
216 static void smooth_ci_z_line( GLcontext
*ctx
,
217 GLuint vert0
, GLuint vert1
, GLuint pvert
)
219 GLint count
= ctx
->PB
->count
;
220 GLint
*pbx
= ctx
->PB
->x
;
221 GLint
*pby
= ctx
->PB
->y
;
222 GLdepth
*pbz
= ctx
->PB
->z
;
223 GLuint
*pbi
= ctx
->PB
->index
;
226 ctx
->PB
->mono
= GL_FALSE
;
230 #define INTERP_INDEX 1
239 #include "linetemp.h"
241 ctx
->PB
->count
= count
;
247 /* Smooth-shaded, RGBA line */
248 static void smooth_rgba_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 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
257 ctx
->PB
->mono
= GL_FALSE
;
261 #define INTERP_ALPHA 1
266 pbrgba[count][RCOMP] = FixedToInt(r0); \
267 pbrgba[count][GCOMP] = FixedToInt(g0); \
268 pbrgba[count][BCOMP] = FixedToInt(b0); \
269 pbrgba[count][ACOMP] = FixedToInt(a0); \
272 #include "linetemp.h"
274 ctx
->PB
->count
= count
;
280 /* Smooth-shaded, RGBA line with Z interpolation/testing */
281 static void smooth_rgba_z_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 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
293 ctx
->PB
->mono
= GL_FALSE
;
298 #define INTERP_ALPHA 1
304 pbfog[count] = fog0; \
305 pbrgba[count][RCOMP] = FixedToInt(r0); \
306 pbrgba[count][GCOMP] = FixedToInt(g0); \
307 pbrgba[count][BCOMP] = FixedToInt(b0); \
308 pbrgba[count][ACOMP] = FixedToInt(a0); \
311 #include "linetemp.h"
313 ctx
->PB
->count
= count
;
318 #define CHECK_FULL(count) \
319 if (count >= PB_SIZE-MAX_WIDTH) { \
320 ctx->PB->count = count; \
322 count = ctx->PB->count; \
327 /* Smooth shaded, color index, any width, maybe stippled */
328 static void general_smooth_ci_line( GLcontext
*ctx
,
329 GLuint vert0
, GLuint vert1
, GLuint pvert
)
331 GLint count
= ctx
->PB
->count
;
332 GLint
*pbx
= ctx
->PB
->x
;
333 GLint
*pby
= ctx
->PB
->y
;
334 GLdepth
*pbz
= ctx
->PB
->z
;
335 GLfixed
*pbfog
= ctx
->PB
->fog
;
336 GLuint
*pbi
= ctx
->PB
->index
;
339 ctx
->PB
->mono
= GL_FALSE
;
341 if (ctx
->Line
.StippleFlag
) {
345 #define INTERP_INDEX 1
352 pbfog[count] = fog0; \
356 #include "linetemp.h"
360 if (ctx
->Line
.Width
==2.0F
) {
361 /* special case: unstippled and width=2 */
364 #define INTERP_INDEX 1
365 #define XMAJOR_PLOT(X,Y) \
366 pbx[count] = X; pbx[count+1] = X; \
367 pby[count] = Y; pby[count+1] = Y+1; \
368 pbz[count] = Z; pbz[count+1] = Z; \
369 pbfog[count] = fog0; pbfog[count+1] = fog0; \
370 pbi[count] = I; pbi[count+1] = I; \
373 #define YMAJOR_PLOT(X,Y) \
374 pbx[count] = X; pbx[count+1] = X+1; \
375 pby[count] = Y; pby[count+1] = Y; \
376 pbz[count] = Z; pbz[count+1] = Z; \
377 pbfog[count] = fog0; pbfog[count+1] = fog0; \
378 pbi[count] = I; pbi[count+1] = I; \
381 #include "linetemp.h"
384 /* unstippled, any width */
387 #define INTERP_INDEX 1
394 pbfog[count] = fog0; \
397 #include "linetemp.h"
401 ctx
->PB
->count
= count
;
406 /* Flat shaded, color index, any width, maybe stippled */
407 static void general_flat_ci_line( GLcontext
*ctx
,
408 GLuint vert0
, GLuint vert1
, GLuint pvert
)
411 GLint
*pbx
= ctx
->PB
->x
;
412 GLint
*pby
= ctx
->PB
->y
;
413 GLdepth
*pbz
= ctx
->PB
->z
;
414 GLfixed
*pbfog
= ctx
->PB
->fog
;
415 PB_SET_INDEX( ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
416 count
= ctx
->PB
->count
;
418 if (ctx
->Line
.StippleFlag
) {
419 /* stippled, any width */
428 pbfog[count] = fog0; \
431 #include "linetemp.h"
435 if (ctx
->Line
.Width
==2.0F
) {
436 /* special case: unstippled and width=2 */
439 #define XMAJOR_PLOT(X,Y) \
440 pbx[count] = X; pbx[count+1] = X; \
441 pby[count] = Y; pby[count+1] = Y+1; \
442 pbz[count] = Z; pbz[count+1] = Z; \
443 pbfog[count] = fog0; pbfog[count+1] = fog0; \
446 #define YMAJOR_PLOT(X,Y) \
447 pbx[count] = X; pbx[count+1] = X+1; \
448 pby[count] = Y; pby[count+1] = Y; \
449 pbz[count] = Z; pbz[count+1] = Z; \
450 pbfog[count] = fog0; pbfog[count+1] = fog0; \
453 #include "linetemp.h"
456 /* unstippled, any width */
464 pbfog[count] = fog0; \
467 #include "linetemp.h"
471 ctx
->PB
->count
= count
;
477 static void general_smooth_rgba_line( GLcontext
*ctx
,
478 GLuint vert0
, GLuint vert1
, GLuint pvert
)
480 GLint count
= ctx
->PB
->count
;
481 GLint
*pbx
= ctx
->PB
->x
;
482 GLint
*pby
= ctx
->PB
->y
;
483 GLdepth
*pbz
= ctx
->PB
->z
;
484 GLfixed
*pbfog
= ctx
->PB
->fog
;
485 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
489 ctx
->PB
->mono
= GL_FALSE
;
491 if (ctx
->Line
.StippleFlag
) {
496 #define INTERP_ALPHA 1
503 pbfog[count] = fog0; \
504 pbrgba[count][RCOMP] = FixedToInt(r0); \
505 pbrgba[count][GCOMP] = FixedToInt(g0); \
506 pbrgba[count][BCOMP] = FixedToInt(b0); \
507 pbrgba[count][ACOMP] = FixedToInt(a0); \
510 #include "linetemp.h"
514 if (ctx
->Line
.Width
==2.0F
) {
515 /* special case: unstippled and width=2 */
519 #define INTERP_ALPHA 1
520 #define XMAJOR_PLOT(X,Y) \
521 pbx[count] = X; pbx[count+1] = X; \
522 pby[count] = Y; pby[count+1] = Y+1; \
523 pbz[count] = Z; pbz[count+1] = Z; \
524 pbfog[count] = fog0; pbfog[count+1] = fog0; \
525 pbrgba[count][RCOMP] = FixedToInt(r0); \
526 pbrgba[count][GCOMP] = FixedToInt(g0); \
527 pbrgba[count][BCOMP] = FixedToInt(b0); \
528 pbrgba[count][ACOMP] = FixedToInt(a0); \
529 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
530 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
531 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
532 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
535 #define YMAJOR_PLOT(X,Y) \
536 pbx[count] = X; pbx[count+1] = X+1; \
537 pby[count] = Y; pby[count+1] = Y; \
538 pbz[count] = Z; pbz[count+1] = Z; \
539 pbfog[count] = fog0; pbfog[count+1] = fog0; \
540 pbrgba[count][RCOMP] = FixedToInt(r0); \
541 pbrgba[count][GCOMP] = FixedToInt(g0); \
542 pbrgba[count][BCOMP] = FixedToInt(b0); \
543 pbrgba[count][ACOMP] = FixedToInt(a0); \
544 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
545 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
546 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
547 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
550 #include "linetemp.h"
553 /* unstippled, any width */
557 #define INTERP_ALPHA 1
563 pbfog[count] = fog0; \
564 pbrgba[count][RCOMP] = FixedToInt(r0); \
565 pbrgba[count][GCOMP] = FixedToInt(g0); \
566 pbrgba[count][BCOMP] = FixedToInt(b0); \
567 pbrgba[count][ACOMP] = FixedToInt(a0); \
570 #include "linetemp.h"
574 ctx
->PB
->count
= count
;
579 static void general_flat_rgba_line( GLcontext
*ctx
,
580 GLuint vert0
, GLuint vert1
, GLuint pvert
)
582 const GLchan
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
583 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
585 if (ctx
->Line
.StippleFlag
) {
591 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
592 #include "linetemp.h"
596 if (ctx
->Line
.Width
==2.0F
) {
597 /* special case: unstippled and width=2 */
600 #define XMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0); \
601 PB_WRITE_PIXEL(ctx->PB, X, Y+1, Z, fog0);
602 #define YMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0); \
603 PB_WRITE_PIXEL(ctx->PB, X+1, Y, Z, fog0);
604 #include "linetemp.h"
607 /* unstippled, any width */
611 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
612 #include "linetemp.h"
620 /* Flat-shaded, textured, any width, maybe stippled */
621 static void flat_textured_line( GLcontext
*ctx
,
622 GLuint vert0
, GLuint vert1
, GLuint pv
)
625 GLint
*pbx
= ctx
->PB
->x
;
626 GLint
*pby
= ctx
->PB
->y
;
627 GLdepth
*pbz
= ctx
->PB
->z
;
628 GLfixed
*pbfog
= ctx
->PB
->fog
;
629 GLfloat
*pbs
= ctx
->PB
->s
[0];
630 GLfloat
*pbt
= ctx
->PB
->t
[0];
631 GLfloat
*pbu
= ctx
->PB
->u
[0];
632 GLchan
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
633 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
634 count
= ctx
->PB
->count
;
636 if (ctx
->Line
.StippleFlag
) {
648 pbfog[count] = fog0; \
649 pbs[count] = fragTexcoord[0];\
650 pbt[count] = fragTexcoord[1];\
651 pbu[count] = fragTexcoord[2];\
655 #include "linetemp.h"
668 pbfog[count] = fog0; \
669 pbs[count] = fragTexcoord[0];\
670 pbt[count] = fragTexcoord[1];\
671 pbu[count] = fragTexcoord[2];\
675 #include "linetemp.h"
678 ctx
->PB
->count
= count
;
684 /* Smooth-shaded, textured, any width, maybe stippled */
685 static void smooth_textured_line( GLcontext
*ctx
,
686 GLuint vert0
, GLuint vert1
, GLuint pvert
)
688 GLint count
= ctx
->PB
->count
;
689 GLint
*pbx
= ctx
->PB
->x
;
690 GLint
*pby
= ctx
->PB
->y
;
691 GLdepth
*pbz
= ctx
->PB
->z
;
692 GLfixed
*pbfog
= ctx
->PB
->fog
;
693 GLfloat
*pbs
= ctx
->PB
->s
[0];
694 GLfloat
*pbt
= ctx
->PB
->t
[0];
695 GLfloat
*pbu
= ctx
->PB
->u
[0];
696 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
699 ctx
->PB
->mono
= GL_FALSE
;
701 if (ctx
->Line
.StippleFlag
) {
706 #define INTERP_ALPHA 1
715 pbfog[count] = fog0; \
716 pbs[count] = fragTexcoord[0]; \
717 pbt[count] = fragTexcoord[1]; \
718 pbu[count] = fragTexcoord[2]; \
719 pbrgba[count][RCOMP] = FixedToInt(r0); \
720 pbrgba[count][GCOMP] = FixedToInt(g0); \
721 pbrgba[count][BCOMP] = FixedToInt(b0); \
722 pbrgba[count][ACOMP] = FixedToInt(a0); \
726 #include "linetemp.h"
733 #define INTERP_ALPHA 1
741 pbfog[count] = fog0; \
742 pbs[count] = fragTexcoord[0]; \
743 pbt[count] = fragTexcoord[1]; \
744 pbu[count] = fragTexcoord[2]; \
745 pbrgba[count][RCOMP] = FixedToInt(r0); \
746 pbrgba[count][GCOMP] = FixedToInt(g0); \
747 pbrgba[count][BCOMP] = FixedToInt(b0); \
748 pbrgba[count][ACOMP] = FixedToInt(a0); \
752 #include "linetemp.h"
755 ctx
->PB
->count
= count
;
760 /* Smooth-shaded, multitextured, any width, maybe stippled, separate specular
761 * color interpolation.
763 static void smooth_multitextured_line( GLcontext
*ctx
,
764 GLuint vert0
, GLuint vert1
, GLuint pvert
)
766 GLint count
= ctx
->PB
->count
;
767 GLint
*pbx
= ctx
->PB
->x
;
768 GLint
*pby
= ctx
->PB
->y
;
769 GLdepth
*pbz
= ctx
->PB
->z
;
770 GLfixed
*pbfog
= ctx
->PB
->fog
;
771 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
772 GLchan (*pbspec
)[3] = ctx
->PB
->spec
;
776 ctx
->PB
->mono
= GL_FALSE
;
778 if (ctx
->Line
.StippleFlag
) {
783 #define INTERP_SPEC 1
784 #define INTERP_ALPHA 1
785 #define INTERP_MULTITEX 1
794 pbfog[count] = fog0; \
795 pbrgba[count][RCOMP] = FixedToInt(r0); \
796 pbrgba[count][GCOMP] = FixedToInt(g0); \
797 pbrgba[count][BCOMP] = FixedToInt(b0); \
798 pbrgba[count][ACOMP] = FixedToInt(a0); \
799 pbspec[count][RCOMP] = FixedToInt(sr0); \
800 pbspec[count][GCOMP] = FixedToInt(sg0); \
801 pbspec[count][BCOMP] = FixedToInt(sb0); \
802 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
803 if (ctx->Texture.Unit[u].ReallyEnabled) { \
804 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
805 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
806 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
807 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
813 #include "linetemp.h"
820 #define INTERP_SPEC 1
821 #define INTERP_ALPHA 1
822 #define INTERP_MULTITEX 1
830 pbfog[count] = fog0; \
831 pbrgba[count][RCOMP] = FixedToInt(r0); \
832 pbrgba[count][GCOMP] = FixedToInt(g0); \
833 pbrgba[count][BCOMP] = FixedToInt(b0); \
834 pbrgba[count][ACOMP] = FixedToInt(a0); \
835 pbspec[count][RCOMP] = FixedToInt(sr0); \
836 pbspec[count][GCOMP] = FixedToInt(sg0); \
837 pbspec[count][BCOMP] = FixedToInt(sb0); \
838 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
839 if (ctx->Texture.Unit[u].ReallyEnabled) { \
840 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
841 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
842 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
843 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
849 #include "linetemp.h"
852 ctx
->PB
->count
= count
;
857 /* Flat-shaded, multitextured, any width, maybe stippled, separate specular
858 * color interpolation.
860 static void flat_multitextured_line( GLcontext
*ctx
,
861 GLuint vert0
, GLuint vert1
, GLuint pvert
)
863 GLint count
= ctx
->PB
->count
;
864 GLint
*pbx
= ctx
->PB
->x
;
865 GLint
*pby
= ctx
->PB
->y
;
866 GLdepth
*pbz
= ctx
->PB
->z
;
867 GLfixed
*pbfog
= ctx
->PB
->fog
;
868 GLchan (*pbrgba
)[4] = ctx
->PB
->rgba
;
869 GLchan (*pbspec
)[3] = ctx
->PB
->spec
;
870 GLchan
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
871 GLchan sRed
= ctx
->VB
->SecondaryColorPtr
->data
? ctx
->VB
->SecondaryColorPtr
->data
[pvert
][0] : 0;
872 GLchan sGreen
= ctx
->VB
->SecondaryColorPtr
->data
? ctx
->VB
->SecondaryColorPtr
->data
[pvert
][1] : 0;
873 GLchan sBlue
= ctx
->VB
->SecondaryColorPtr
->data
? ctx
->VB
->SecondaryColorPtr
->data
[pvert
][2] : 0;
877 ctx
->PB
->mono
= GL_FALSE
;
879 if (ctx
->Line
.StippleFlag
) {
883 #define INTERP_ALPHA 1
884 #define INTERP_MULTITEX 1
893 pbfog[count] = fog0; \
894 pbrgba[count][RCOMP] = color[0]; \
895 pbrgba[count][GCOMP] = color[1]; \
896 pbrgba[count][BCOMP] = color[2]; \
897 pbrgba[count][ACOMP] = color[3]; \
898 pbspec[count][RCOMP] = sRed; \
899 pbspec[count][GCOMP] = sGreen; \
900 pbspec[count][BCOMP] = sBlue; \
901 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
902 if (ctx->Texture.Unit[u].ReallyEnabled) { \
903 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
904 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
905 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
906 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
912 #include "linetemp.h"
918 #define INTERP_ALPHA 1
919 #define INTERP_MULTITEX 1
927 pbfog[count] = fog0; \
928 pbrgba[count][RCOMP] = color[0]; \
929 pbrgba[count][GCOMP] = color[1]; \
930 pbrgba[count][BCOMP] = color[2]; \
931 pbrgba[count][ACOMP] = color[3]; \
932 pbspec[count][RCOMP] = sRed; \
933 pbspec[count][GCOMP] = sGreen; \
934 pbspec[count][BCOMP] = sBlue; \
935 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
936 if (ctx->Texture.Unit[u].ReallyEnabled) { \
937 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
938 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
939 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
940 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
946 #include "linetemp.h"
949 ctx
->PB
->count
= count
;
957 * Antialiased RGBA line
959 * This AA line function isn't terribly efficient but it's pretty
960 * straight-forward to understand. Also, it doesn't exactly conform
961 * to the specification.
963 static void aa_rgba_line( GLcontext
*ctx
,
964 GLuint vert0
, GLuint vert1
, GLuint pvert
)
966 #define INTERP_RGBA 1
969 PB_WRITE_RGBA_PIXEL( pb, (x), (y), z, fog0, \
970 red, green, blue, coverage ); \
972 #include "lnaatemp.h"
976 * Antialiased Textured RGBA line
978 * This AA line function isn't terribly efficient but it's pretty
979 * straight-forward to understand. Also, it doesn't exactly conform
980 * to the specification.
982 static void aa_tex_rgba_line( GLcontext
*ctx
,
983 GLuint vert0
, GLuint vert1
, GLuint pvert
)
985 #define INTERP_RGBA 1
989 PB_WRITE_TEX_PIXEL( pb, (x), (y), z, fog0, \
990 red, green, blue, coverage, \
991 fragTexcoord[0], fragTexcoord[1], fragTexcoord[2] ); \
993 #include "lnaatemp.h"
998 * Antialiased Multitextured RGBA line
1000 * This AA line function isn't terribly efficient but it's pretty
1001 * straight-forward to understand. Also, it doesn't exactly conform
1002 * to the specification.
1004 static void aa_multitex_rgba_line( GLcontext
*ctx
,
1005 GLuint vert0
, GLuint vert1
, GLuint pvert
)
1007 #define INTERP_RGBA 1
1008 #define INTERP_SPEC 1
1009 #define INTERP_MULTITEX 1
1010 #define PLOT(x, y) \
1012 PB_WRITE_MULTITEX_SPEC_PIXEL( pb, (x), (y), z, fog0, \
1013 red, green, blue, coverage, specRed, specGreen, specBlue, \
1016 #include "lnaatemp.h"
1021 * Antialiased CI line. Same comments for RGBA antialiased lines apply.
1023 static void aa_ci_line( GLcontext
*ctx
,
1024 GLuint vert0
, GLuint vert1
, GLuint pvert
)
1026 #define INTERP_INDEX 1
1027 #define PLOT(x, y) \
1029 PB_WRITE_CI_PIXEL( pb, (x), (y), z, fog0, index + coverage ); \
1031 #include "lnaatemp.h"
1036 * Null rasterizer for measuring transformation speed.
1038 static void null_line( GLcontext
*ctx
, GLuint v1
, GLuint v2
, GLuint pv
)
1050 _mesa_print_line_function(GLcontext
*ctx
)
1052 printf("Line Func == ");
1053 if (ctx
->Driver
.LineFunc
== flat_ci_line
)
1054 printf("flat_ci_line\n");
1055 else if (ctx
->Driver
.LineFunc
== flat_ci_z_line
)
1056 printf("flat_ci_z_line\n");
1057 else if (ctx
->Driver
.LineFunc
== flat_rgba_line
)
1058 printf("flat_rgba_line\n");
1059 else if (ctx
->Driver
.LineFunc
== flat_rgba_z_line
)
1060 printf("flat_rgba_z_line\n");
1061 else if (ctx
->Driver
.LineFunc
== smooth_ci_line
)
1062 printf("smooth_ci_line\n");
1063 else if (ctx
->Driver
.LineFunc
== smooth_ci_z_line
)
1064 printf("smooth_ci_z_line\n");
1065 else if (ctx
->Driver
.LineFunc
== smooth_rgba_line
)
1066 printf("smooth_rgba_line\n");
1067 else if (ctx
->Driver
.LineFunc
== smooth_rgba_z_line
)
1068 printf("smooth_rgba_z_line\n");
1069 else if (ctx
->Driver
.LineFunc
== general_smooth_ci_line
)
1070 printf("general_smooth_ci_line\n");
1071 else if (ctx
->Driver
.LineFunc
== general_flat_ci_line
)
1072 printf("general_flat_ci_line\n");
1073 else if (ctx
->Driver
.LineFunc
== general_smooth_rgba_line
)
1074 printf("general_smooth_rgba_line\n");
1075 else if (ctx
->Driver
.LineFunc
== general_flat_rgba_line
)
1076 printf("general_flat_rgba_line\n");
1077 else if (ctx
->Driver
.LineFunc
== flat_textured_line
)
1078 printf("flat_textured_line\n");
1079 else if (ctx
->Driver
.LineFunc
== smooth_textured_line
)
1080 printf("smooth_textured_line\n");
1081 else if (ctx
->Driver
.LineFunc
== smooth_multitextured_line
)
1082 printf("smooth_multitextured_line\n");
1083 else if (ctx
->Driver
.LineFunc
== flat_multitextured_line
)
1084 printf("flat_multitextured_line\n");
1085 else if (ctx
->Driver
.LineFunc
== aa_rgba_line
)
1086 printf("aa_rgba_line\n");
1087 else if (ctx
->Driver
.LineFunc
== aa_tex_rgba_line
)
1088 printf("aa_tex_rgba_line\n");
1089 else if (ctx
->Driver
.LineFunc
== aa_multitex_rgba_line
)
1090 printf("aa_multitex_rgba_line\n");
1091 else if (ctx
->Driver
.LineFunc
== aa_ci_line
)
1092 printf("aa_ci_line\n");
1093 else if (ctx
->Driver
.LineFunc
== null_line
)
1094 printf("null_line\n");
1096 printf("Driver func %p\n", ctx
->Driver
.LineFunc
);
1103 * Determine which line drawing function to use given the current
1104 * rendering context.
1106 * Please update the summary flag _SWRAST_NEW_LINE if you add or remove
1107 * tests to this code.
1109 void gl_set_line_function( GLcontext
*ctx
)
1111 GLboolean rgbmode
= ctx
->Visual
.RGBAflag
;
1112 /* TODO: antialiased lines */
1114 if (ctx
->RenderMode
==GL_RENDER
) {
1115 if (ctx
->NoRaster
) {
1116 ctx
->Driver
.LineFunc
= null_line
;
1119 if (ctx
->Driver
.LineFunc
) {
1120 /* Device driver will draw lines. */
1124 if (ctx
->Line
.SmoothFlag
) {
1125 /* antialiased lines */
1127 if (ctx
->Texture
.ReallyEnabled
) {
1128 if (ctx
->Texture
.MultiTextureEnabled
1129 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
1130 || ctx
->Fog
.ColorSumEnabled
)
1131 /* Multitextured! */
1132 ctx
->Driver
.LineFunc
= aa_multitex_rgba_line
;
1134 ctx
->Driver
.LineFunc
= aa_tex_rgba_line
;
1136 ctx
->Driver
.LineFunc
= aa_rgba_line
;
1140 ctx
->Driver
.LineFunc
= aa_ci_line
;
1143 else if (ctx
->Texture
.ReallyEnabled
) {
1144 if (ctx
->Texture
.MultiTextureEnabled
1145 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
1146 || ctx
->Fog
.ColorSumEnabled
) {
1147 /* multi-texture and/or separate specular color */
1148 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
)
1149 ctx
->Driver
.LineFunc
= smooth_multitextured_line
;
1151 ctx
->Driver
.LineFunc
= flat_multitextured_line
;
1154 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1155 ctx
->Driver
.LineFunc
= smooth_textured_line
;
1158 ctx
->Driver
.LineFunc
= flat_textured_line
;
1162 else if (ctx
->Line
.Width
!=1.0 || ctx
->Line
.StippleFlag
1163 || ctx
->Line
.SmoothFlag
) {
1164 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1166 ctx
->Driver
.LineFunc
= general_smooth_rgba_line
;
1168 ctx
->Driver
.LineFunc
= general_smooth_ci_line
;
1172 ctx
->Driver
.LineFunc
= general_flat_rgba_line
;
1174 ctx
->Driver
.LineFunc
= general_flat_ci_line
;
1178 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1179 /* Width==1, non-stippled, smooth-shaded */
1180 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
1182 ctx
->Driver
.LineFunc
= smooth_rgba_z_line
;
1184 ctx
->Driver
.LineFunc
= smooth_ci_z_line
;
1188 ctx
->Driver
.LineFunc
= smooth_rgba_line
;
1190 ctx
->Driver
.LineFunc
= smooth_ci_line
;
1194 /* Width==1, non-stippled, flat-shaded */
1195 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
1197 ctx
->Driver
.LineFunc
= flat_rgba_z_line
;
1199 ctx
->Driver
.LineFunc
= flat_ci_z_line
;
1203 ctx
->Driver
.LineFunc
= flat_rgba_line
;
1205 ctx
->Driver
.LineFunc
= flat_ci_line
;
1210 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
1211 ctx
->Driver
.LineFunc
= gl_feedback_line
;
1214 /* GL_SELECT mode */
1215 ctx
->Driver
.LineFunc
= gl_select_line
;
1218 /*_mesa_print_line_function(ctx);*/