1 /* $Id: lines.c,v 1.15 2000/09/30 18:42:29 brianp 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
;
60 ctx
->NewState
|= NEW_RASTER_OPS
;
61 if (ctx
->Driver
.LineWidth
)
62 (*ctx
->Driver
.LineWidth
)(ctx
, width
);
69 _mesa_LineStipple( GLint factor
, GLushort pattern
)
71 GET_CURRENT_CONTEXT(ctx
);
72 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glLineStipple");
73 ctx
->Line
.StippleFactor
= CLAMP( factor
, 1, 256 );
74 ctx
->Line
.StipplePattern
= pattern
;
75 ctx
->NewState
|= NEW_RASTER_OPS
;
77 if (ctx
->Driver
.LineStipple
)
78 ctx
->Driver
.LineStipple( ctx
, factor
, pattern
);
83 /**********************************************************************/
84 /***** Rasterization *****/
85 /**********************************************************************/
89 * There are 4 pairs (RGBA, CI) of line drawing functions:
90 * 1. simple: width=1 and no special rasterization functions (fastest)
91 * 2. flat: width=1, non-stippled, flat-shaded, any raster operations
92 * 3. smooth: width=1, non-stippled, smooth-shaded, any raster operations
93 * 4. general: any other kind of line (slowest)
98 * All line drawing functions have the same arguments:
99 * v1, v2 - indexes of first and second endpoints into vertex buffer arrays
100 * pv - provoking vertex: which vertex color/index to use for flat shading.
108 #if MAX_WIDTH > MAX_HEIGHT
109 # define MAXPOINTS MAX_WIDTH
111 # define MAXPOINTS MAX_HEIGHT
115 /* Flat, color index line */
116 static void flat_ci_line( GLcontext
*ctx
,
117 GLuint vert0
, GLuint vert1
, GLuint pvert
)
119 PB_SET_INDEX( ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
122 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, 0);
124 #include "linetemp.h"
131 /* Flat, color index line with Z interpolation/testing */
132 static void flat_ci_z_line( GLcontext
*ctx
,
133 GLuint vert0
, GLuint vert1
, GLuint pvert
)
135 PB_SET_INDEX( ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
139 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
141 #include "linetemp.h"
148 /* Flat-shaded, RGBA line */
149 static void flat_rgba_line( GLcontext
*ctx
,
150 GLuint vert0
, GLuint vert1
, GLuint pvert
)
152 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
153 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
156 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, 0);
158 #include "linetemp.h"
165 /* Flat-shaded, RGBA line with Z interpolation/testing */
166 static void flat_rgba_z_line( GLcontext
*ctx
,
167 GLuint vert0
, GLuint vert1
, GLuint pvert
)
169 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
170 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
174 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
176 #include "linetemp.h"
183 /* Smooth shaded, color index line */
184 static void smooth_ci_line( GLcontext
*ctx
,
185 GLuint vert0
, GLuint vert1
, GLuint pvert
)
187 GLint count
= ctx
->PB
->count
;
188 GLint
*pbx
= ctx
->PB
->x
;
189 GLint
*pby
= ctx
->PB
->y
;
190 GLuint
*pbi
= ctx
->PB
->index
;
193 ctx
->PB
->mono
= GL_FALSE
;
196 #define INTERP_INDEX 1
204 #include "linetemp.h"
206 ctx
->PB
->count
= count
;
212 /* Smooth shaded, color index line with Z interpolation/testing */
213 static void smooth_ci_z_line( GLcontext
*ctx
,
214 GLuint vert0
, GLuint vert1
, GLuint pvert
)
216 GLint count
= ctx
->PB
->count
;
217 GLint
*pbx
= ctx
->PB
->x
;
218 GLint
*pby
= ctx
->PB
->y
;
219 GLdepth
*pbz
= ctx
->PB
->z
;
220 GLuint
*pbi
= ctx
->PB
->index
;
223 ctx
->PB
->mono
= GL_FALSE
;
227 #define INTERP_INDEX 1
236 #include "linetemp.h"
238 ctx
->PB
->count
= count
;
244 /* Smooth-shaded, RGBA line */
245 static void smooth_rgba_line( GLcontext
*ctx
,
246 GLuint vert0
, GLuint vert1
, GLuint pvert
)
248 GLint count
= ctx
->PB
->count
;
249 GLint
*pbx
= ctx
->PB
->x
;
250 GLint
*pby
= ctx
->PB
->y
;
251 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
254 ctx
->PB
->mono
= GL_FALSE
;
258 #define INTERP_ALPHA 1
263 pbrgba[count][RCOMP] = FixedToInt(r0); \
264 pbrgba[count][GCOMP] = FixedToInt(g0); \
265 pbrgba[count][BCOMP] = FixedToInt(b0); \
266 pbrgba[count][ACOMP] = FixedToInt(a0); \
269 #include "linetemp.h"
271 ctx
->PB
->count
= count
;
277 /* Smooth-shaded, RGBA line with Z interpolation/testing */
278 static void smooth_rgba_z_line( GLcontext
*ctx
,
279 GLuint vert0
, GLuint vert1
, GLuint pvert
)
281 GLint count
= ctx
->PB
->count
;
282 GLint
*pbx
= ctx
->PB
->x
;
283 GLint
*pby
= ctx
->PB
->y
;
284 GLdepth
*pbz
= ctx
->PB
->z
;
285 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
288 ctx
->PB
->mono
= GL_FALSE
;
293 #define INTERP_ALPHA 1
299 pbrgba[count][RCOMP] = FixedToInt(r0); \
300 pbrgba[count][GCOMP] = FixedToInt(g0); \
301 pbrgba[count][BCOMP] = FixedToInt(b0); \
302 pbrgba[count][ACOMP] = FixedToInt(a0); \
305 #include "linetemp.h"
307 ctx
->PB
->count
= count
;
312 #define CHECK_FULL(count) \
313 if (count >= PB_SIZE-MAX_WIDTH) { \
314 ctx->PB->count = count; \
316 count = ctx->PB->count; \
321 /* Smooth shaded, color index, any width, maybe stippled */
322 static void general_smooth_ci_line( GLcontext
*ctx
,
323 GLuint vert0
, GLuint vert1
, GLuint pvert
)
325 GLint count
= ctx
->PB
->count
;
326 GLint
*pbx
= ctx
->PB
->x
;
327 GLint
*pby
= ctx
->PB
->y
;
328 GLdepth
*pbz
= ctx
->PB
->z
;
329 GLuint
*pbi
= ctx
->PB
->index
;
332 ctx
->PB
->mono
= GL_FALSE
;
334 if (ctx
->Line
.StippleFlag
) {
338 #define INTERP_INDEX 1
348 #include "linetemp.h"
352 if (ctx
->Line
.Width
==2.0F
) {
353 /* special case: unstippled and width=2 */
356 #define INTERP_INDEX 1
357 #define XMAJOR_PLOT(X,Y) \
358 pbx[count] = X; pbx[count+1] = X; \
359 pby[count] = Y; pby[count+1] = Y+1; \
360 pbz[count] = Z; pbz[count+1] = Z; \
361 pbi[count] = I; pbi[count+1] = I; \
364 #define YMAJOR_PLOT(X,Y) \
365 pbx[count] = X; pbx[count+1] = X+1; \
366 pby[count] = Y; pby[count+1] = Y; \
367 pbz[count] = Z; pbz[count+1] = Z; \
368 pbi[count] = I; pbi[count+1] = I; \
371 #include "linetemp.h"
374 /* unstippled, any width */
377 #define INTERP_INDEX 1
386 #include "linetemp.h"
390 ctx
->PB
->count
= count
;
395 /* Flat shaded, color index, any width, maybe stippled */
396 static void general_flat_ci_line( GLcontext
*ctx
,
397 GLuint vert0
, GLuint vert1
, GLuint pvert
)
400 GLint
*pbx
= ctx
->PB
->x
;
401 GLint
*pby
= ctx
->PB
->y
;
402 GLdepth
*pbz
= ctx
->PB
->z
;
403 PB_SET_INDEX( ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
404 count
= ctx
->PB
->count
;
406 if (ctx
->Line
.StippleFlag
) {
407 /* stippled, any width */
418 #include "linetemp.h"
422 if (ctx
->Line
.Width
==2.0F
) {
423 /* special case: unstippled and width=2 */
426 #define XMAJOR_PLOT(X,Y) \
427 pbx[count] = X; pbx[count+1] = X; \
428 pby[count] = Y; pby[count+1] = Y+1; \
429 pbz[count] = Z; pbz[count+1] = Z; \
432 #define YMAJOR_PLOT(X,Y) \
433 pbx[count] = X; pbx[count+1] = X+1; \
434 pby[count] = Y; pby[count+1] = Y; \
435 pbz[count] = Z; pbz[count+1] = Z; \
438 #include "linetemp.h"
441 /* unstippled, any width */
451 #include "linetemp.h"
455 ctx
->PB
->count
= count
;
461 static void general_smooth_rgba_line( GLcontext
*ctx
,
462 GLuint vert0
, GLuint vert1
, GLuint pvert
)
464 GLint count
= ctx
->PB
->count
;
465 GLint
*pbx
= ctx
->PB
->x
;
466 GLint
*pby
= ctx
->PB
->y
;
467 GLdepth
*pbz
= ctx
->PB
->z
;
468 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
471 ctx
->PB
->mono
= GL_FALSE
;
473 if (ctx
->Line
.StippleFlag
) {
478 #define INTERP_ALPHA 1
485 pbrgba[count][RCOMP] = FixedToInt(r0); \
486 pbrgba[count][GCOMP] = FixedToInt(g0); \
487 pbrgba[count][BCOMP] = FixedToInt(b0); \
488 pbrgba[count][ACOMP] = FixedToInt(a0); \
491 #include "linetemp.h"
495 if (ctx
->Line
.Width
==2.0F
) {
496 /* special case: unstippled and width=2 */
500 #define INTERP_ALPHA 1
501 #define XMAJOR_PLOT(X,Y) \
502 pbx[count] = X; pbx[count+1] = X; \
503 pby[count] = Y; pby[count+1] = Y+1; \
504 pbz[count] = Z; pbz[count+1] = Z; \
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 #define YMAJOR_PLOT(X,Y) \
516 pbx[count] = X; pbx[count+1] = X+1; \
517 pby[count] = Y; pby[count+1] = Y; \
518 pbz[count] = Z; pbz[count+1] = Z; \
519 pbrgba[count][RCOMP] = FixedToInt(r0); \
520 pbrgba[count][GCOMP] = FixedToInt(g0); \
521 pbrgba[count][BCOMP] = FixedToInt(b0); \
522 pbrgba[count][ACOMP] = FixedToInt(a0); \
523 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
524 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
525 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
526 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
529 #include "linetemp.h"
532 /* unstippled, any width */
536 #define INTERP_ALPHA 1
542 pbrgba[count][RCOMP] = FixedToInt(r0); \
543 pbrgba[count][GCOMP] = FixedToInt(g0); \
544 pbrgba[count][BCOMP] = FixedToInt(b0); \
545 pbrgba[count][ACOMP] = FixedToInt(a0); \
548 #include "linetemp.h"
552 ctx
->PB
->count
= count
;
557 static void general_flat_rgba_line( GLcontext
*ctx
,
558 GLuint vert0
, GLuint vert1
, GLuint pvert
)
560 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
561 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
563 if (ctx
->Line
.StippleFlag
) {
569 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
570 #include "linetemp.h"
574 if (ctx
->Line
.Width
==2.0F
) {
575 /* special case: unstippled and width=2 */
578 #define XMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z); \
579 PB_WRITE_PIXEL(ctx->PB, X, Y+1, Z);
580 #define YMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z); \
581 PB_WRITE_PIXEL(ctx->PB, X+1, Y, Z);
582 #include "linetemp.h"
585 /* unstippled, any width */
589 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
590 #include "linetemp.h"
598 /* Flat-shaded, textured, any width, maybe stippled */
599 static void flat_textured_line( GLcontext
*ctx
,
600 GLuint vert0
, GLuint vert1
, GLuint pv
)
603 GLint
*pbx
= ctx
->PB
->x
;
604 GLint
*pby
= ctx
->PB
->y
;
605 GLdepth
*pbz
= ctx
->PB
->z
;
606 GLfloat
*pbs
= ctx
->PB
->s
[0];
607 GLfloat
*pbt
= ctx
->PB
->t
[0];
608 GLfloat
*pbu
= ctx
->PB
->u
[0];
609 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
610 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
611 count
= ctx
->PB
->count
;
613 if (ctx
->Line
.StippleFlag
) {
625 pbs[count] = fragTexcoord[0];\
626 pbt[count] = fragTexcoord[1];\
627 pbu[count] = fragTexcoord[2];\
631 #include "linetemp.h"
644 pbs[count] = fragTexcoord[0];\
645 pbt[count] = fragTexcoord[1];\
646 pbu[count] = fragTexcoord[2];\
650 #include "linetemp.h"
653 ctx
->PB
->count
= count
;
659 /* Smooth-shaded, textured, any width, maybe stippled */
660 static void smooth_textured_line( GLcontext
*ctx
,
661 GLuint vert0
, GLuint vert1
, GLuint pvert
)
663 GLint count
= ctx
->PB
->count
;
664 GLint
*pbx
= ctx
->PB
->x
;
665 GLint
*pby
= ctx
->PB
->y
;
666 GLdepth
*pbz
= ctx
->PB
->z
;
667 GLfloat
*pbs
= ctx
->PB
->s
[0];
668 GLfloat
*pbt
= ctx
->PB
->t
[0];
669 GLfloat
*pbu
= ctx
->PB
->u
[0];
670 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
673 ctx
->PB
->mono
= GL_FALSE
;
675 if (ctx
->Line
.StippleFlag
) {
680 #define INTERP_ALPHA 1
689 pbs[count] = fragTexcoord[0]; \
690 pbt[count] = fragTexcoord[1]; \
691 pbu[count] = fragTexcoord[2]; \
692 pbrgba[count][RCOMP] = FixedToInt(r0); \
693 pbrgba[count][GCOMP] = FixedToInt(g0); \
694 pbrgba[count][BCOMP] = FixedToInt(b0); \
695 pbrgba[count][ACOMP] = FixedToInt(a0); \
699 #include "linetemp.h"
706 #define INTERP_ALPHA 1
714 pbs[count] = fragTexcoord[0]; \
715 pbt[count] = fragTexcoord[1]; \
716 pbu[count] = fragTexcoord[2]; \
717 pbrgba[count][RCOMP] = FixedToInt(r0); \
718 pbrgba[count][GCOMP] = FixedToInt(g0); \
719 pbrgba[count][BCOMP] = FixedToInt(b0); \
720 pbrgba[count][ACOMP] = FixedToInt(a0); \
724 #include "linetemp.h"
727 ctx
->PB
->count
= count
;
732 /* Smooth-shaded, multitextured, any width, maybe stippled, separate specular
733 * color interpolation.
735 static void smooth_multitextured_line( GLcontext
*ctx
,
736 GLuint vert0
, GLuint vert1
, GLuint pvert
)
738 GLint count
= ctx
->PB
->count
;
739 GLint
*pbx
= ctx
->PB
->x
;
740 GLint
*pby
= ctx
->PB
->y
;
741 GLdepth
*pbz
= ctx
->PB
->z
;
742 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
743 GLubyte (*pbspec
)[3] = ctx
->PB
->spec
;
746 ctx
->PB
->mono
= GL_FALSE
;
748 if (ctx
->Line
.StippleFlag
) {
753 #define INTERP_SPEC 1
754 #define INTERP_ALPHA 1
755 #define INTERP_MULTITEX 1
764 pbrgba[count][RCOMP] = FixedToInt(r0); \
765 pbrgba[count][GCOMP] = FixedToInt(g0); \
766 pbrgba[count][BCOMP] = FixedToInt(b0); \
767 pbrgba[count][ACOMP] = FixedToInt(a0); \
768 pbspec[count][RCOMP] = FixedToInt(sr0); \
769 pbspec[count][GCOMP] = FixedToInt(sg0); \
770 pbspec[count][BCOMP] = FixedToInt(sb0); \
771 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
772 if (ctx->Texture.Unit[u].ReallyEnabled) { \
773 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
774 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
775 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
776 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
782 #include "linetemp.h"
789 #define INTERP_SPEC 1
790 #define INTERP_ALPHA 1
791 #define INTERP_MULTITEX 1
799 pbrgba[count][RCOMP] = FixedToInt(r0); \
800 pbrgba[count][GCOMP] = FixedToInt(g0); \
801 pbrgba[count][BCOMP] = FixedToInt(b0); \
802 pbrgba[count][ACOMP] = FixedToInt(a0); \
803 pbspec[count][RCOMP] = FixedToInt(sr0); \
804 pbspec[count][GCOMP] = FixedToInt(sg0); \
805 pbspec[count][BCOMP] = FixedToInt(sb0); \
806 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
807 if (ctx->Texture.Unit[u].ReallyEnabled) { \
808 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
809 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
810 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
811 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
817 #include "linetemp.h"
820 ctx
->PB
->count
= count
;
825 /* Flat-shaded, multitextured, any width, maybe stippled, separate specular
826 * color interpolation.
828 static void flat_multitextured_line( GLcontext
*ctx
,
829 GLuint vert0
, GLuint vert1
, GLuint pvert
)
831 GLint count
= ctx
->PB
->count
;
832 GLint
*pbx
= ctx
->PB
->x
;
833 GLint
*pby
= ctx
->PB
->y
;
834 GLdepth
*pbz
= ctx
->PB
->z
;
835 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
836 GLubyte (*pbspec
)[3] = ctx
->PB
->spec
;
837 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
838 GLubyte sRed
= ctx
->VB
->Specular
? ctx
->VB
->Specular
[pvert
][0] : 0;
839 GLubyte sGreen
= ctx
->VB
->Specular
? ctx
->VB
->Specular
[pvert
][1] : 0;
840 GLubyte sBlue
= ctx
->VB
->Specular
? ctx
->VB
->Specular
[pvert
][2] : 0;
844 ctx
->PB
->mono
= GL_FALSE
;
846 if (ctx
->Line
.StippleFlag
) {
850 #define INTERP_ALPHA 1
851 #define INTERP_MULTITEX 1
860 pbrgba[count][RCOMP] = color[0]; \
861 pbrgba[count][GCOMP] = color[1]; \
862 pbrgba[count][BCOMP] = color[2]; \
863 pbrgba[count][ACOMP] = color[3]; \
864 pbspec[count][RCOMP] = sRed; \
865 pbspec[count][GCOMP] = sGreen; \
866 pbspec[count][BCOMP] = sBlue; \
867 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
868 if (ctx->Texture.Unit[u].ReallyEnabled) { \
869 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
870 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
871 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
872 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
878 #include "linetemp.h"
884 #define INTERP_ALPHA 1
885 #define INTERP_MULTITEX 1
893 pbrgba[count][RCOMP] = color[0]; \
894 pbrgba[count][GCOMP] = color[1]; \
895 pbrgba[count][BCOMP] = color[2]; \
896 pbrgba[count][ACOMP] = color[3]; \
897 pbspec[count][RCOMP] = sRed; \
898 pbspec[count][GCOMP] = sGreen; \
899 pbspec[count][BCOMP] = sBlue; \
900 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
901 if (ctx->Texture.Unit[u].ReallyEnabled) { \
902 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
903 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
904 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
905 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
911 #include "linetemp.h"
914 ctx
->PB
->count
= count
;
922 * Antialiased RGBA line
924 * This AA line function isn't terribly efficient but it's pretty
925 * straight-forward to understand. Also, it doesn't exactly conform
926 * to the specification.
928 static void aa_rgba_line( GLcontext
*ctx
,
929 GLuint vert0
, GLuint vert1
, GLuint pvert
)
931 #define INTERP_RGBA 1
934 PB_WRITE_RGBA_PIXEL( pb, (x), (y), z, \
935 red, green, blue, coverage ); \
937 #include "lnaatemp.h"
941 * Antialiased Textured RGBA line
943 * This AA line function isn't terribly efficient but it's pretty
944 * straight-forward to understand. Also, it doesn't exactly conform
945 * to the specification.
947 static void aa_tex_rgba_line( GLcontext
*ctx
,
948 GLuint vert0
, GLuint vert1
, GLuint pvert
)
950 #define INTERP_RGBA 1
954 PB_WRITE_TEX_PIXEL( pb, (x), (y), z, red, green, blue, coverage, \
955 fragTexcoord[0], fragTexcoord[1], fragTexcoord[2] ); \
957 #include "lnaatemp.h"
962 * Antialiased Multitextured RGBA line
964 * This AA line function isn't terribly efficient but it's pretty
965 * straight-forward to understand. Also, it doesn't exactly conform
966 * to the specification.
968 static void aa_multitex_rgba_line( GLcontext
*ctx
,
969 GLuint vert0
, GLuint vert1
, GLuint pvert
)
971 #define INTERP_RGBA 1
972 #define INTERP_SPEC 1
973 #define INTERP_MULTITEX 1
976 PB_WRITE_MULTITEX_SPEC_PIXEL( pb, (x), (y), z, \
977 red, green, blue, coverage, specRed, specGreen, specBlue, \
980 #include "lnaatemp.h"
985 * Antialiased CI line. Same comments for RGBA antialiased lines apply.
987 static void aa_ci_line( GLcontext
*ctx
,
988 GLuint vert0
, GLuint vert1
, GLuint pvert
)
990 #define INTERP_INDEX 1
993 PB_WRITE_CI_PIXEL( pb, (x), (y), z, index + coverage ); \
995 #include "lnaatemp.h"
1000 * Null rasterizer for measuring transformation speed.
1002 static void null_line( GLcontext
*ctx
, GLuint v1
, GLuint v2
, GLuint pv
)
1014 _mesa_print_line_function(GLcontext
*ctx
)
1016 printf("Line Func == ");
1017 if (ctx
->Driver
.LineFunc
== flat_ci_line
)
1018 printf("flat_ci_line\n");
1019 else if (ctx
->Driver
.LineFunc
== flat_ci_z_line
)
1020 printf("flat_ci_z_line\n");
1021 else if (ctx
->Driver
.LineFunc
== flat_rgba_line
)
1022 printf("flat_rgba_line\n");
1023 else if (ctx
->Driver
.LineFunc
== flat_rgba_z_line
)
1024 printf("flat_rgba_z_line\n");
1025 else if (ctx
->Driver
.LineFunc
== smooth_ci_line
)
1026 printf("smooth_ci_line\n");
1027 else if (ctx
->Driver
.LineFunc
== smooth_ci_z_line
)
1028 printf("smooth_ci_z_line\n");
1029 else if (ctx
->Driver
.LineFunc
== smooth_rgba_line
)
1030 printf("smooth_rgba_line\n");
1031 else if (ctx
->Driver
.LineFunc
== smooth_rgba_z_line
)
1032 printf("smooth_rgba_z_line\n");
1033 else if (ctx
->Driver
.LineFunc
== general_smooth_ci_line
)
1034 printf("general_smooth_ci_line\n");
1035 else if (ctx
->Driver
.LineFunc
== general_flat_ci_line
)
1036 printf("general_flat_ci_line\n");
1037 else if (ctx
->Driver
.LineFunc
== general_smooth_rgba_line
)
1038 printf("general_smooth_rgba_line\n");
1039 else if (ctx
->Driver
.LineFunc
== general_flat_rgba_line
)
1040 printf("general_flat_rgba_line\n");
1041 else if (ctx
->Driver
.LineFunc
== flat_textured_line
)
1042 printf("flat_textured_line\n");
1043 else if (ctx
->Driver
.LineFunc
== smooth_textured_line
)
1044 printf("smooth_textured_line\n");
1045 else if (ctx
->Driver
.LineFunc
== smooth_multitextured_line
)
1046 printf("smooth_multitextured_line\n");
1047 else if (ctx
->Driver
.LineFunc
== flat_multitextured_line
)
1048 printf("flat_multitextured_line\n");
1049 else if (ctx
->Driver
.LineFunc
== aa_rgba_line
)
1050 printf("aa_rgba_line\n");
1051 else if (ctx
->Driver
.LineFunc
== aa_tex_rgba_line
)
1052 printf("aa_tex_rgba_line\n");
1053 else if (ctx
->Driver
.LineFunc
== aa_multitex_rgba_line
)
1054 printf("aa_multitex_rgba_line\n");
1055 else if (ctx
->Driver
.LineFunc
== aa_ci_line
)
1056 printf("aa_ci_line\n");
1057 else if (ctx
->Driver
.LineFunc
== null_line
)
1058 printf("null_line\n");
1060 printf("Driver func %p\n", ctx
->Driver
.PointsFunc
);
1067 * Determine which line drawing function to use given the current
1068 * rendering context.
1070 void gl_set_line_function( GLcontext
*ctx
)
1072 GLboolean rgbmode
= ctx
->Visual
.RGBAflag
;
1073 /* TODO: antialiased lines */
1075 if (ctx
->RenderMode
==GL_RENDER
) {
1076 if (ctx
->NoRaster
) {
1077 ctx
->Driver
.LineFunc
= null_line
;
1080 if (ctx
->Driver
.LineFunc
) {
1081 /* Device driver will draw lines. */
1085 if (ctx
->Line
.SmoothFlag
) {
1086 /* antialiased lines */
1088 if (ctx
->Texture
.ReallyEnabled
) {
1089 if (ctx
->Texture
.ReallyEnabled
>= TEXTURE1_1D
1090 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
)
1091 /* Multitextured! */
1092 ctx
->Driver
.LineFunc
= aa_multitex_rgba_line
;
1094 ctx
->Driver
.LineFunc
= aa_tex_rgba_line
;
1096 ctx
->Driver
.LineFunc
= aa_rgba_line
;
1100 ctx
->Driver
.LineFunc
= aa_ci_line
;
1103 else if (ctx
->Texture
.ReallyEnabled
) {
1104 if (ctx
->Texture
.ReallyEnabled
>= TEXTURE1_1D
1105 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
) {
1106 /* multi-texture and/or separate specular color */
1107 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
)
1108 ctx
->Driver
.LineFunc
= smooth_multitextured_line
;
1110 ctx
->Driver
.LineFunc
= flat_multitextured_line
;
1113 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1114 ctx
->Driver
.LineFunc
= smooth_textured_line
;
1117 ctx
->Driver
.LineFunc
= flat_textured_line
;
1121 else if (ctx
->Line
.Width
!=1.0 || ctx
->Line
.StippleFlag
1122 || ctx
->Line
.SmoothFlag
) {
1123 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1125 ctx
->Driver
.LineFunc
= general_smooth_rgba_line
;
1127 ctx
->Driver
.LineFunc
= general_smooth_ci_line
;
1131 ctx
->Driver
.LineFunc
= general_flat_rgba_line
;
1133 ctx
->Driver
.LineFunc
= general_flat_ci_line
;
1137 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1138 /* Width==1, non-stippled, smooth-shaded */
1139 if (ctx
->Depth
.Test
|| ctx
->FogMode
== FOG_FRAGMENT
) {
1141 ctx
->Driver
.LineFunc
= smooth_rgba_z_line
;
1143 ctx
->Driver
.LineFunc
= smooth_ci_z_line
;
1147 ctx
->Driver
.LineFunc
= smooth_rgba_line
;
1149 ctx
->Driver
.LineFunc
= smooth_ci_line
;
1153 /* Width==1, non-stippled, flat-shaded */
1154 if (ctx
->Depth
.Test
|| ctx
->FogMode
== FOG_FRAGMENT
) {
1156 ctx
->Driver
.LineFunc
= flat_rgba_z_line
;
1158 ctx
->Driver
.LineFunc
= flat_ci_z_line
;
1162 ctx
->Driver
.LineFunc
= flat_rgba_line
;
1164 ctx
->Driver
.LineFunc
= flat_ci_line
;
1169 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
1170 ctx
->Driver
.LineFunc
= gl_feedback_line
;
1173 /* GL_SELECT mode */
1174 ctx
->Driver
.LineFunc
= gl_select_line
;
1177 /*_mesa_print_line_function(ctx);*/