1 /* $Id: lines.c,v 1.17 2000/10/27 16:44:40 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
;
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, 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, fog0);
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, 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, fog0);
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 GLfixed
*pbfog
= ctx
->PB
->fog
;
286 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
289 ctx
->PB
->mono
= GL_FALSE
;
294 #define INTERP_ALPHA 1
300 pbfog[count] = fog0; \
301 pbrgba[count][RCOMP] = FixedToInt(r0); \
302 pbrgba[count][GCOMP] = FixedToInt(g0); \
303 pbrgba[count][BCOMP] = FixedToInt(b0); \
304 pbrgba[count][ACOMP] = FixedToInt(a0); \
307 #include "linetemp.h"
309 ctx
->PB
->count
= count
;
314 #define CHECK_FULL(count) \
315 if (count >= PB_SIZE-MAX_WIDTH) { \
316 ctx->PB->count = count; \
318 count = ctx->PB->count; \
323 /* Smooth shaded, color index, any width, maybe stippled */
324 static void general_smooth_ci_line( GLcontext
*ctx
,
325 GLuint vert0
, GLuint vert1
, GLuint pvert
)
327 GLint count
= ctx
->PB
->count
;
328 GLint
*pbx
= ctx
->PB
->x
;
329 GLint
*pby
= ctx
->PB
->y
;
330 GLdepth
*pbz
= ctx
->PB
->z
;
331 GLfixed
*pbfog
= ctx
->PB
->fog
;
332 GLuint
*pbi
= ctx
->PB
->index
;
335 ctx
->PB
->mono
= GL_FALSE
;
337 if (ctx
->Line
.StippleFlag
) {
341 #define INTERP_INDEX 1
348 pbfog[count] = fog0; \
352 #include "linetemp.h"
356 if (ctx
->Line
.Width
==2.0F
) {
357 /* special case: unstippled and width=2 */
360 #define INTERP_INDEX 1
361 #define XMAJOR_PLOT(X,Y) \
362 pbx[count] = X; pbx[count+1] = X; \
363 pby[count] = Y; pby[count+1] = Y+1; \
364 pbz[count] = Z; pbz[count+1] = Z; \
365 pbfog[count] = fog0; pbfog[count+1] = fog0; \
366 pbi[count] = I; pbi[count+1] = I; \
369 #define YMAJOR_PLOT(X,Y) \
370 pbx[count] = X; pbx[count+1] = X+1; \
371 pby[count] = Y; pby[count+1] = Y; \
372 pbz[count] = Z; pbz[count+1] = Z; \
373 pbfog[count] = fog0; pbfog[count+1] = fog0; \
374 pbi[count] = I; pbi[count+1] = I; \
377 #include "linetemp.h"
380 /* unstippled, any width */
383 #define INTERP_INDEX 1
390 pbfog[count] = fog0; \
393 #include "linetemp.h"
397 ctx
->PB
->count
= count
;
402 /* Flat shaded, color index, any width, maybe stippled */
403 static void general_flat_ci_line( GLcontext
*ctx
,
404 GLuint vert0
, GLuint vert1
, GLuint pvert
)
407 GLint
*pbx
= ctx
->PB
->x
;
408 GLint
*pby
= ctx
->PB
->y
;
409 GLdepth
*pbz
= ctx
->PB
->z
;
410 GLfixed
*pbfog
= ctx
->PB
->fog
;
411 PB_SET_INDEX( ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
412 count
= ctx
->PB
->count
;
414 if (ctx
->Line
.StippleFlag
) {
415 /* stippled, any width */
424 pbfog[count] = fog0; \
427 #include "linetemp.h"
431 if (ctx
->Line
.Width
==2.0F
) {
432 /* special case: unstippled and width=2 */
435 #define XMAJOR_PLOT(X,Y) \
436 pbx[count] = X; pbx[count+1] = X; \
437 pby[count] = Y; pby[count+1] = Y+1; \
438 pbz[count] = Z; pbz[count+1] = Z; \
439 pbfog[count] = fog0; pbfog[count+1] = fog0; \
442 #define YMAJOR_PLOT(X,Y) \
443 pbx[count] = X; pbx[count+1] = X+1; \
444 pby[count] = Y; pby[count+1] = Y; \
445 pbz[count] = Z; pbz[count+1] = Z; \
446 pbfog[count] = fog0; pbfog[count+1] = fog0; \
449 #include "linetemp.h"
452 /* unstippled, any width */
460 pbfog[count] = fog0; \
463 #include "linetemp.h"
467 ctx
->PB
->count
= count
;
473 static void general_smooth_rgba_line( GLcontext
*ctx
,
474 GLuint vert0
, GLuint vert1
, GLuint pvert
)
476 GLint count
= ctx
->PB
->count
;
477 GLint
*pbx
= ctx
->PB
->x
;
478 GLint
*pby
= ctx
->PB
->y
;
479 GLdepth
*pbz
= ctx
->PB
->z
;
480 GLfixed
*pbfog
= ctx
->PB
->fog
;
481 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
484 ctx
->PB
->mono
= GL_FALSE
;
486 if (ctx
->Line
.StippleFlag
) {
491 #define INTERP_ALPHA 1
498 pbfog[count] = fog0; \
499 pbrgba[count][RCOMP] = FixedToInt(r0); \
500 pbrgba[count][GCOMP] = FixedToInt(g0); \
501 pbrgba[count][BCOMP] = FixedToInt(b0); \
502 pbrgba[count][ACOMP] = FixedToInt(a0); \
505 #include "linetemp.h"
509 if (ctx
->Line
.Width
==2.0F
) {
510 /* special case: unstippled and width=2 */
514 #define INTERP_ALPHA 1
515 #define XMAJOR_PLOT(X,Y) \
516 pbx[count] = X; pbx[count+1] = X; \
517 pby[count] = Y; pby[count+1] = Y+1; \
518 pbz[count] = Z; pbz[count+1] = Z; \
519 pbfog[count] = fog0; pbfog[count+1] = fog0; \
520 pbrgba[count][RCOMP] = FixedToInt(r0); \
521 pbrgba[count][GCOMP] = FixedToInt(g0); \
522 pbrgba[count][BCOMP] = FixedToInt(b0); \
523 pbrgba[count][ACOMP] = FixedToInt(a0); \
524 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
525 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
526 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
527 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
530 #define YMAJOR_PLOT(X,Y) \
531 pbx[count] = X; pbx[count+1] = X+1; \
532 pby[count] = Y; pby[count+1] = Y; \
533 pbz[count] = Z; pbz[count+1] = Z; \
534 pbfog[count] = fog0; pbfog[count+1] = fog0; \
535 pbrgba[count][RCOMP] = FixedToInt(r0); \
536 pbrgba[count][GCOMP] = FixedToInt(g0); \
537 pbrgba[count][BCOMP] = FixedToInt(b0); \
538 pbrgba[count][ACOMP] = FixedToInt(a0); \
539 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
540 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
541 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
542 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
545 #include "linetemp.h"
548 /* unstippled, any width */
552 #define INTERP_ALPHA 1
558 pbfog[count] = fog0; \
559 pbrgba[count][RCOMP] = FixedToInt(r0); \
560 pbrgba[count][GCOMP] = FixedToInt(g0); \
561 pbrgba[count][BCOMP] = FixedToInt(b0); \
562 pbrgba[count][ACOMP] = FixedToInt(a0); \
565 #include "linetemp.h"
569 ctx
->PB
->count
= count
;
574 static void general_flat_rgba_line( GLcontext
*ctx
,
575 GLuint vert0
, GLuint vert1
, GLuint pvert
)
577 const GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
578 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
580 if (ctx
->Line
.StippleFlag
) {
586 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
587 #include "linetemp.h"
591 if (ctx
->Line
.Width
==2.0F
) {
592 /* special case: unstippled and width=2 */
595 #define XMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0); \
596 PB_WRITE_PIXEL(ctx->PB, X, Y+1, Z, fog0);
597 #define YMAJOR_PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0); \
598 PB_WRITE_PIXEL(ctx->PB, X+1, Y, Z, fog0);
599 #include "linetemp.h"
602 /* unstippled, any width */
606 #define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z, fog0);
607 #include "linetemp.h"
615 /* Flat-shaded, textured, any width, maybe stippled */
616 static void flat_textured_line( GLcontext
*ctx
,
617 GLuint vert0
, GLuint vert1
, GLuint pv
)
620 GLint
*pbx
= ctx
->PB
->x
;
621 GLint
*pby
= ctx
->PB
->y
;
622 GLdepth
*pbz
= ctx
->PB
->z
;
623 GLfixed
*pbfog
= ctx
->PB
->fog
;
624 GLfloat
*pbs
= ctx
->PB
->s
[0];
625 GLfloat
*pbt
= ctx
->PB
->t
[0];
626 GLfloat
*pbu
= ctx
->PB
->u
[0];
627 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
628 PB_SET_COLOR( ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
629 count
= ctx
->PB
->count
;
631 if (ctx
->Line
.StippleFlag
) {
643 pbfog[count] = fog0; \
644 pbs[count] = fragTexcoord[0];\
645 pbt[count] = fragTexcoord[1];\
646 pbu[count] = fragTexcoord[2];\
650 #include "linetemp.h"
663 pbfog[count] = fog0; \
664 pbs[count] = fragTexcoord[0];\
665 pbt[count] = fragTexcoord[1];\
666 pbu[count] = fragTexcoord[2];\
670 #include "linetemp.h"
673 ctx
->PB
->count
= count
;
679 /* Smooth-shaded, textured, any width, maybe stippled */
680 static void smooth_textured_line( GLcontext
*ctx
,
681 GLuint vert0
, GLuint vert1
, GLuint pvert
)
683 GLint count
= ctx
->PB
->count
;
684 GLint
*pbx
= ctx
->PB
->x
;
685 GLint
*pby
= ctx
->PB
->y
;
686 GLdepth
*pbz
= ctx
->PB
->z
;
687 GLfixed
*pbfog
= ctx
->PB
->fog
;
688 GLfloat
*pbs
= ctx
->PB
->s
[0];
689 GLfloat
*pbt
= ctx
->PB
->t
[0];
690 GLfloat
*pbu
= ctx
->PB
->u
[0];
691 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
694 ctx
->PB
->mono
= GL_FALSE
;
696 if (ctx
->Line
.StippleFlag
) {
701 #define INTERP_ALPHA 1
710 pbfog[count] = fog0; \
711 pbs[count] = fragTexcoord[0]; \
712 pbt[count] = fragTexcoord[1]; \
713 pbu[count] = fragTexcoord[2]; \
714 pbrgba[count][RCOMP] = FixedToInt(r0); \
715 pbrgba[count][GCOMP] = FixedToInt(g0); \
716 pbrgba[count][BCOMP] = FixedToInt(b0); \
717 pbrgba[count][ACOMP] = FixedToInt(a0); \
721 #include "linetemp.h"
728 #define INTERP_ALPHA 1
736 pbfog[count] = fog0; \
737 pbs[count] = fragTexcoord[0]; \
738 pbt[count] = fragTexcoord[1]; \
739 pbu[count] = fragTexcoord[2]; \
740 pbrgba[count][RCOMP] = FixedToInt(r0); \
741 pbrgba[count][GCOMP] = FixedToInt(g0); \
742 pbrgba[count][BCOMP] = FixedToInt(b0); \
743 pbrgba[count][ACOMP] = FixedToInt(a0); \
747 #include "linetemp.h"
750 ctx
->PB
->count
= count
;
755 /* Smooth-shaded, multitextured, any width, maybe stippled, separate specular
756 * color interpolation.
758 static void smooth_multitextured_line( GLcontext
*ctx
,
759 GLuint vert0
, GLuint vert1
, GLuint pvert
)
761 GLint count
= ctx
->PB
->count
;
762 GLint
*pbx
= ctx
->PB
->x
;
763 GLint
*pby
= ctx
->PB
->y
;
764 GLdepth
*pbz
= ctx
->PB
->z
;
765 GLfixed
*pbfog
= ctx
->PB
->fog
;
766 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
767 GLubyte (*pbspec
)[3] = ctx
->PB
->spec
;
770 ctx
->PB
->mono
= GL_FALSE
;
772 if (ctx
->Line
.StippleFlag
) {
777 #define INTERP_SPEC 1
778 #define INTERP_ALPHA 1
779 #define INTERP_MULTITEX 1
788 pbfog[count] = fog0; \
789 pbrgba[count][RCOMP] = FixedToInt(r0); \
790 pbrgba[count][GCOMP] = FixedToInt(g0); \
791 pbrgba[count][BCOMP] = FixedToInt(b0); \
792 pbrgba[count][ACOMP] = FixedToInt(a0); \
793 pbspec[count][RCOMP] = FixedToInt(sr0); \
794 pbspec[count][GCOMP] = FixedToInt(sg0); \
795 pbspec[count][BCOMP] = FixedToInt(sb0); \
796 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
797 if (ctx->Texture.Unit[u].ReallyEnabled) { \
798 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
799 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
800 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
801 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
807 #include "linetemp.h"
814 #define INTERP_SPEC 1
815 #define INTERP_ALPHA 1
816 #define INTERP_MULTITEX 1
824 pbfog[count] = fog0; \
825 pbrgba[count][RCOMP] = FixedToInt(r0); \
826 pbrgba[count][GCOMP] = FixedToInt(g0); \
827 pbrgba[count][BCOMP] = FixedToInt(b0); \
828 pbrgba[count][ACOMP] = FixedToInt(a0); \
829 pbspec[count][RCOMP] = FixedToInt(sr0); \
830 pbspec[count][GCOMP] = FixedToInt(sg0); \
831 pbspec[count][BCOMP] = FixedToInt(sb0); \
832 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
833 if (ctx->Texture.Unit[u].ReallyEnabled) { \
834 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
835 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
836 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
837 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
843 #include "linetemp.h"
846 ctx
->PB
->count
= count
;
851 /* Flat-shaded, multitextured, any width, maybe stippled, separate specular
852 * color interpolation.
854 static void flat_multitextured_line( GLcontext
*ctx
,
855 GLuint vert0
, GLuint vert1
, GLuint pvert
)
857 GLint count
= ctx
->PB
->count
;
858 GLint
*pbx
= ctx
->PB
->x
;
859 GLint
*pby
= ctx
->PB
->y
;
860 GLdepth
*pbz
= ctx
->PB
->z
;
861 GLfixed
*pbfog
= ctx
->PB
->fog
;
862 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
863 GLubyte (*pbspec
)[3] = ctx
->PB
->spec
;
864 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
865 GLubyte sRed
= ctx
->VB
->SecondaryColorPtr
->data
? ctx
->VB
->SecondaryColorPtr
->data
[pvert
][0] : 0;
866 GLubyte sGreen
= ctx
->VB
->SecondaryColorPtr
->data
? ctx
->VB
->SecondaryColorPtr
->data
[pvert
][1] : 0;
867 GLubyte sBlue
= ctx
->VB
->SecondaryColorPtr
->data
? ctx
->VB
->SecondaryColorPtr
->data
[pvert
][2] : 0;
871 ctx
->PB
->mono
= GL_FALSE
;
873 if (ctx
->Line
.StippleFlag
) {
877 #define INTERP_ALPHA 1
878 #define INTERP_MULTITEX 1
887 pbfog[count] = fog0; \
888 pbrgba[count][RCOMP] = color[0]; \
889 pbrgba[count][GCOMP] = color[1]; \
890 pbrgba[count][BCOMP] = color[2]; \
891 pbrgba[count][ACOMP] = color[3]; \
892 pbspec[count][RCOMP] = sRed; \
893 pbspec[count][GCOMP] = sGreen; \
894 pbspec[count][BCOMP] = sBlue; \
895 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
896 if (ctx->Texture.Unit[u].ReallyEnabled) { \
897 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
898 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
899 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
900 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
906 #include "linetemp.h"
912 #define INTERP_ALPHA 1
913 #define INTERP_MULTITEX 1
921 pbfog[count] = fog0; \
922 pbrgba[count][RCOMP] = color[0]; \
923 pbrgba[count][GCOMP] = color[1]; \
924 pbrgba[count][BCOMP] = color[2]; \
925 pbrgba[count][ACOMP] = color[3]; \
926 pbspec[count][RCOMP] = sRed; \
927 pbspec[count][GCOMP] = sGreen; \
928 pbspec[count][BCOMP] = sBlue; \
929 for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
930 if (ctx->Texture.Unit[u].ReallyEnabled) { \
931 ctx->PB->s[u][0] = fragTexcoord[u][0]; \
932 ctx->PB->s[u][1] = fragTexcoord[u][1]; \
933 ctx->PB->s[u][2] = fragTexcoord[u][2]; \
934 ctx->PB->s[u][3] = fragTexcoord[u][3]; \
940 #include "linetemp.h"
943 ctx
->PB
->count
= count
;
951 * Antialiased 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_rgba_line( GLcontext
*ctx
,
958 GLuint vert0
, GLuint vert1
, GLuint pvert
)
960 #define INTERP_RGBA 1
963 PB_WRITE_RGBA_PIXEL( pb, (x), (y), z, fog0, \
964 red, green, blue, coverage ); \
966 #include "lnaatemp.h"
970 * Antialiased Textured RGBA line
972 * This AA line function isn't terribly efficient but it's pretty
973 * straight-forward to understand. Also, it doesn't exactly conform
974 * to the specification.
976 static void aa_tex_rgba_line( GLcontext
*ctx
,
977 GLuint vert0
, GLuint vert1
, GLuint pvert
)
979 #define INTERP_RGBA 1
983 PB_WRITE_TEX_PIXEL( pb, (x), (y), z, fog0, \
984 red, green, blue, coverage, \
985 fragTexcoord[0], fragTexcoord[1], fragTexcoord[2] ); \
987 #include "lnaatemp.h"
992 * Antialiased Multitextured RGBA line
994 * This AA line function isn't terribly efficient but it's pretty
995 * straight-forward to understand. Also, it doesn't exactly conform
996 * to the specification.
998 static void aa_multitex_rgba_line( GLcontext
*ctx
,
999 GLuint vert0
, GLuint vert1
, GLuint pvert
)
1001 #define INTERP_RGBA 1
1002 #define INTERP_SPEC 1
1003 #define INTERP_MULTITEX 1
1004 #define PLOT(x, y) \
1006 PB_WRITE_MULTITEX_SPEC_PIXEL( pb, (x), (y), z, fog0, \
1007 red, green, blue, coverage, specRed, specGreen, specBlue, \
1010 #include "lnaatemp.h"
1015 * Antialiased CI line. Same comments for RGBA antialiased lines apply.
1017 static void aa_ci_line( GLcontext
*ctx
,
1018 GLuint vert0
, GLuint vert1
, GLuint pvert
)
1020 #define INTERP_INDEX 1
1021 #define PLOT(x, y) \
1023 PB_WRITE_CI_PIXEL( pb, (x), (y), z, fog0, index + coverage ); \
1025 #include "lnaatemp.h"
1030 * Null rasterizer for measuring transformation speed.
1032 static void null_line( GLcontext
*ctx
, GLuint v1
, GLuint v2
, GLuint pv
)
1044 _mesa_print_line_function(GLcontext
*ctx
)
1046 printf("Line Func == ");
1047 if (ctx
->Driver
.LineFunc
== flat_ci_line
)
1048 printf("flat_ci_line\n");
1049 else if (ctx
->Driver
.LineFunc
== flat_ci_z_line
)
1050 printf("flat_ci_z_line\n");
1051 else if (ctx
->Driver
.LineFunc
== flat_rgba_line
)
1052 printf("flat_rgba_line\n");
1053 else if (ctx
->Driver
.LineFunc
== flat_rgba_z_line
)
1054 printf("flat_rgba_z_line\n");
1055 else if (ctx
->Driver
.LineFunc
== smooth_ci_line
)
1056 printf("smooth_ci_line\n");
1057 else if (ctx
->Driver
.LineFunc
== smooth_ci_z_line
)
1058 printf("smooth_ci_z_line\n");
1059 else if (ctx
->Driver
.LineFunc
== smooth_rgba_line
)
1060 printf("smooth_rgba_line\n");
1061 else if (ctx
->Driver
.LineFunc
== smooth_rgba_z_line
)
1062 printf("smooth_rgba_z_line\n");
1063 else if (ctx
->Driver
.LineFunc
== general_smooth_ci_line
)
1064 printf("general_smooth_ci_line\n");
1065 else if (ctx
->Driver
.LineFunc
== general_flat_ci_line
)
1066 printf("general_flat_ci_line\n");
1067 else if (ctx
->Driver
.LineFunc
== general_smooth_rgba_line
)
1068 printf("general_smooth_rgba_line\n");
1069 else if (ctx
->Driver
.LineFunc
== general_flat_rgba_line
)
1070 printf("general_flat_rgba_line\n");
1071 else if (ctx
->Driver
.LineFunc
== flat_textured_line
)
1072 printf("flat_textured_line\n");
1073 else if (ctx
->Driver
.LineFunc
== smooth_textured_line
)
1074 printf("smooth_textured_line\n");
1075 else if (ctx
->Driver
.LineFunc
== smooth_multitextured_line
)
1076 printf("smooth_multitextured_line\n");
1077 else if (ctx
->Driver
.LineFunc
== flat_multitextured_line
)
1078 printf("flat_multitextured_line\n");
1079 else if (ctx
->Driver
.LineFunc
== aa_rgba_line
)
1080 printf("aa_rgba_line\n");
1081 else if (ctx
->Driver
.LineFunc
== aa_tex_rgba_line
)
1082 printf("aa_tex_rgba_line\n");
1083 else if (ctx
->Driver
.LineFunc
== aa_multitex_rgba_line
)
1084 printf("aa_multitex_rgba_line\n");
1085 else if (ctx
->Driver
.LineFunc
== aa_ci_line
)
1086 printf("aa_ci_line\n");
1087 else if (ctx
->Driver
.LineFunc
== null_line
)
1088 printf("null_line\n");
1090 printf("Driver func %p\n", ctx
->Driver
.LineFunc
);
1097 * Determine which line drawing function to use given the current
1098 * rendering context.
1100 void gl_set_line_function( GLcontext
*ctx
)
1102 GLboolean rgbmode
= ctx
->Visual
.RGBAflag
;
1103 /* TODO: antialiased lines */
1105 if (ctx
->RenderMode
==GL_RENDER
) {
1106 if (ctx
->NoRaster
) {
1107 ctx
->Driver
.LineFunc
= null_line
;
1110 if (ctx
->Driver
.LineFunc
) {
1111 /* Device driver will draw lines. */
1115 if (ctx
->Line
.SmoothFlag
) {
1116 /* antialiased lines */
1118 if (ctx
->Texture
.ReallyEnabled
) {
1119 if (ctx
->Texture
.MultiTextureEnabled
1120 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
1121 || ctx
->Fog
.ColorSumEnabled
)
1122 /* Multitextured! */
1123 ctx
->Driver
.LineFunc
= aa_multitex_rgba_line
;
1125 ctx
->Driver
.LineFunc
= aa_tex_rgba_line
;
1127 ctx
->Driver
.LineFunc
= aa_rgba_line
;
1131 ctx
->Driver
.LineFunc
= aa_ci_line
;
1134 else if (ctx
->Texture
.ReallyEnabled
) {
1135 if (ctx
->Texture
.MultiTextureEnabled
1136 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
) {
1137 /* multi-texture and/or separate specular color */
1138 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
)
1139 ctx
->Driver
.LineFunc
= smooth_multitextured_line
;
1141 ctx
->Driver
.LineFunc
= flat_multitextured_line
;
1144 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1145 ctx
->Driver
.LineFunc
= smooth_textured_line
;
1148 ctx
->Driver
.LineFunc
= flat_textured_line
;
1152 else if (ctx
->Line
.Width
!=1.0 || ctx
->Line
.StippleFlag
1153 || ctx
->Line
.SmoothFlag
) {
1154 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1156 ctx
->Driver
.LineFunc
= general_smooth_rgba_line
;
1158 ctx
->Driver
.LineFunc
= general_smooth_ci_line
;
1162 ctx
->Driver
.LineFunc
= general_flat_rgba_line
;
1164 ctx
->Driver
.LineFunc
= general_flat_ci_line
;
1168 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1169 /* Width==1, non-stippled, smooth-shaded */
1170 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
1172 ctx
->Driver
.LineFunc
= smooth_rgba_z_line
;
1174 ctx
->Driver
.LineFunc
= smooth_ci_z_line
;
1178 ctx
->Driver
.LineFunc
= smooth_rgba_line
;
1180 ctx
->Driver
.LineFunc
= smooth_ci_line
;
1184 /* Width==1, non-stippled, flat-shaded */
1185 if (ctx
->Depth
.Test
|| ctx
->Fog
.Enabled
) {
1187 ctx
->Driver
.LineFunc
= flat_rgba_z_line
;
1189 ctx
->Driver
.LineFunc
= flat_ci_z_line
;
1193 ctx
->Driver
.LineFunc
= flat_rgba_line
;
1195 ctx
->Driver
.LineFunc
= flat_ci_line
;
1200 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
1201 ctx
->Driver
.LineFunc
= gl_feedback_line
;
1204 /* GL_SELECT mode */
1205 ctx
->Driver
.LineFunc
= gl_select_line
;
1208 /*_mesa_print_line_function(ctx);*/