1 /* $Id: lines.c,v 1.1 1999/08/19 00:55:41 jtg Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999 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.
46 #include "GL/xf86glx.h"
52 void gl_LineWidth( GLcontext
*ctx
, GLfloat width
)
55 gl_error( ctx
, GL_INVALID_VALUE
, "glLineWidth" );
58 ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx
, "glLineWidth");
60 if (ctx
->Line
.Width
!= width
) {
61 ctx
->Line
.Width
= width
;
62 ctx
->TriangleCaps
&= ~DD_LINE_WIDTH
;
63 if (width
!= 1.0) ctx
->TriangleCaps
|= DD_LINE_WIDTH
;
64 ctx
->NewState
|= NEW_RASTER_OPS
;
70 void gl_LineStipple( GLcontext
*ctx
, GLint factor
, GLushort pattern
)
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
;
80 /**********************************************************************/
81 /***** Rasterization *****/
82 /**********************************************************************/
86 * There are 4 pairs (RGBA, CI) of line drawing functions:
87 * 1. simple: width=1 and no special rasterization functions (fastest)
88 * 2. flat: width=1, non-stippled, flat-shaded, any raster operations
89 * 3. smooth: width=1, non-stippled, smooth-shaded, any raster operations
90 * 4. general: any other kind of line (slowest)
95 * All line drawing functions have the same arguments:
96 * v1, v2 - indexes of first and second endpoints into vertex buffer arrays
97 * pv - provoking vertex: which vertex color/index to use for flat shading.
102 static void feedback_line( GLcontext
*ctx
, GLuint v1
, GLuint v2
, GLuint pv
)
104 struct vertex_buffer
*VB
= ctx
->VB
;
105 GLfloat x1
, y1
, z1
, w1
;
106 GLfloat x2
, y2
, z2
, w2
;
107 GLfloat tex1
[4], tex2
[4], invq
;
108 GLuint texUnit
= ctx
->Texture
.CurrentTransformUnit
;
110 x1
= VB
->Win
.data
[v1
][0];
111 y1
= VB
->Win
.data
[v1
][1];
112 z1
= VB
->Win
.data
[v1
][2] / DEPTH_SCALE
;
113 w1
= (VB
->ClipPtr
->size
== 4 ? VEC_ELT(VB
->ClipPtr
, GLfloat
, v1
)[3] : 1.0);
115 x2
= VB
->Win
.data
[v2
][0];
116 y2
= VB
->Win
.data
[v2
][1];
117 z2
= VB
->Win
.data
[v2
][2] / DEPTH_SCALE
;
118 w2
= (VB
->ClipPtr
->size
== 4 ? VEC_ELT(VB
->ClipPtr
, GLfloat
, v2
)[3] : 1.0);
121 if (VB
->TexCoordPtr
[texUnit
]->size
== 4) {
122 invq
= (VB
->TexCoordPtr
[texUnit
]->data
[v1
][3]==0.0
124 : 1.0F
/ VB
->TexCoordPtr
[texUnit
]->data
[v1
][3]);
126 tex1
[0] = VB
->TexCoordPtr
[texUnit
]->data
[v1
][0] * invq
;
127 tex1
[1] = VB
->TexCoordPtr
[texUnit
]->data
[v1
][1] * invq
;
128 tex1
[2] = VB
->TexCoordPtr
[texUnit
]->data
[v1
][2] * invq
;
129 tex1
[3] = VB
->TexCoordPtr
[texUnit
]->data
[v1
][3];
131 invq
= (VB
->TexCoordPtr
[texUnit
]->data
[v2
][3]==0.0
133 : 1.0F
/ VB
->TexCoordPtr
[texUnit
]->data
[v2
][3]);
135 tex2
[0] = VB
->TexCoordPtr
[texUnit
]->data
[v2
][0] * invq
;
136 tex2
[1] = VB
->TexCoordPtr
[texUnit
]->data
[v2
][1] * invq
;
137 tex2
[2] = VB
->TexCoordPtr
[texUnit
]->data
[v2
][2] * invq
;
138 tex2
[3] = VB
->TexCoordPtr
[texUnit
]->data
[v2
][3];
140 ASSIGN_4V(tex1
, 0,0,0,1);
141 ASSIGN_4V(tex2
, 0,0,0,1);
143 VB
->TexCoordPtr
[texUnit
]->size
,
144 VB
->TexCoordPtr
[texUnit
]->data
[v1
]);
146 VB
->TexCoordPtr
[texUnit
]->size
,
147 VB
->TexCoordPtr
[texUnit
]->data
[v2
]);
151 if (ctx
->StippleCounter
==0) {
152 FEEDBACK_TOKEN( ctx
, (GLfloat
) (GLint
) GL_LINE_RESET_TOKEN
);
155 FEEDBACK_TOKEN( ctx
, (GLfloat
) (GLint
) GL_LINE_TOKEN
);
160 GLubyte
*ubc
= VB
->ColorPtr
->data
[pv
];
161 GLuint index
= VB
->IndexPtr
->data
[pv
];
163 UBYTE_RGBA_TO_FLOAT_RGBA( color
, ubc
);
164 gl_feedback_vertex( ctx
, x1
,y1
,z1
,w1
, color
, (GLfloat
) index
, tex1
);
165 gl_feedback_vertex( ctx
, x2
,y2
,z2
,w2
, color
, (GLfloat
) index
, tex2
);
168 ctx
->StippleCounter
++;
173 static void select_line( GLcontext
*ctx
, GLuint v1
, GLuint v2
, GLuint pv
)
176 gl_update_hitflag( ctx
, ctx
->VB
->Win
.data
[v1
][2] / DEPTH_SCALE
);
177 gl_update_hitflag( ctx
, ctx
->VB
->Win
.data
[v2
][2] / DEPTH_SCALE
);
182 #if MAX_WIDTH > MAX_HEIGHT
183 # define MAXPOINTS MAX_WIDTH
185 # define MAXPOINTS MAX_HEIGHT
189 /* Flat, color index line */
190 static void flat_ci_line( GLcontext
*ctx
,
191 GLuint vert0
, GLuint vert1
, GLuint pvert
)
194 GLint
*pbx
= ctx
->PB
->x
;
195 GLint
*pby
= ctx
->PB
->y
;
196 PB_SET_INDEX( ctx
, ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
197 count
= ctx
->PB
->count
;
206 #include "linetemp.h"
208 ctx
->PB
->count
= count
;
209 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
214 /* Flat, color index line with Z interpolation/testing */
215 static void flat_ci_z_line( GLcontext
*ctx
,
216 GLuint vert0
, GLuint vert1
, GLuint pvert
)
219 GLint
*pbx
= ctx
->PB
->x
;
220 GLint
*pby
= ctx
->PB
->y
;
221 GLdepth
*pbz
= ctx
->PB
->z
;
222 PB_SET_INDEX( ctx
, ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
223 count
= ctx
->PB
->count
;
234 #include "linetemp.h"
236 ctx
->PB
->count
= count
;
237 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
242 /* Flat-shaded, RGBA line */
243 static void flat_rgba_line( GLcontext
*ctx
,
244 GLuint vert0
, GLuint vert1
, GLuint pvert
)
247 GLint
*pbx
= ctx
->PB
->x
;
248 GLint
*pby
= ctx
->PB
->y
;
249 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
250 PB_SET_COLOR( ctx
, ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
251 count
= ctx
->PB
->count
;
260 #include "linetemp.h"
262 ctx
->PB
->count
= count
;
263 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
268 /* Flat-shaded, RGBA line with Z interpolation/testing */
269 static void flat_rgba_z_line( GLcontext
*ctx
,
270 GLuint vert0
, GLuint vert1
, GLuint pvert
)
273 GLint
*pbx
= ctx
->PB
->x
;
274 GLint
*pby
= ctx
->PB
->y
;
275 GLdepth
*pbz
= ctx
->PB
->z
;
276 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
277 PB_SET_COLOR( ctx
, ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
278 count
= ctx
->PB
->count
;
289 #include "linetemp.h"
291 ctx
->PB
->count
= count
;
292 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
297 /* Smooth shaded, color index line */
298 static void smooth_ci_line( GLcontext
*ctx
,
299 GLuint vert0
, GLuint vert1
, GLuint pvert
)
301 GLint count
= ctx
->PB
->count
;
302 GLint
*pbx
= ctx
->PB
->x
;
303 GLint
*pby
= ctx
->PB
->y
;
304 GLuint
*pbi
= ctx
->PB
->i
;
308 #define INTERP_INDEX 1
316 #include "linetemp.h"
318 ctx
->PB
->count
= count
;
319 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
324 /* Smooth shaded, color index line with Z interpolation/testing */
325 static void smooth_ci_z_line( GLcontext
*ctx
,
326 GLuint vert0
, GLuint vert1
, GLuint pvert
)
328 GLint count
= ctx
->PB
->count
;
329 GLint
*pbx
= ctx
->PB
->x
;
330 GLint
*pby
= ctx
->PB
->y
;
331 GLdepth
*pbz
= ctx
->PB
->z
;
332 GLuint
*pbi
= ctx
->PB
->i
;
337 #define INTERP_INDEX 1
346 #include "linetemp.h"
348 ctx
->PB
->count
= count
;
349 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
354 /* Smooth-shaded, RGBA line */
355 static void smooth_rgba_line( GLcontext
*ctx
,
356 GLuint vert0
, GLuint vert1
, GLuint pvert
)
358 GLint count
= ctx
->PB
->count
;
359 GLint
*pbx
= ctx
->PB
->x
;
360 GLint
*pby
= ctx
->PB
->y
;
361 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
366 #define INTERP_ALPHA 1
371 pbrgba[count][RCOMP] = FixedToInt(r0); \
372 pbrgba[count][GCOMP] = FixedToInt(g0); \
373 pbrgba[count][BCOMP] = FixedToInt(b0); \
374 pbrgba[count][ACOMP] = FixedToInt(a0); \
377 #include "linetemp.h"
379 ctx
->PB
->count
= count
;
380 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
385 /* Smooth-shaded, RGBA line with Z interpolation/testing */
386 static void smooth_rgba_z_line( GLcontext
*ctx
,
387 GLuint vert0
, GLuint vert1
, GLuint pvert
)
389 GLint count
= ctx
->PB
->count
;
390 GLint
*pbx
= ctx
->PB
->x
;
391 GLint
*pby
= ctx
->PB
->y
;
392 GLdepth
*pbz
= ctx
->PB
->z
;
393 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
399 #define INTERP_ALPHA 1
405 pbrgba[count][RCOMP] = FixedToInt(r0); \
406 pbrgba[count][GCOMP] = FixedToInt(g0); \
407 pbrgba[count][BCOMP] = FixedToInt(b0); \
408 pbrgba[count][ACOMP] = FixedToInt(a0); \
411 #include "linetemp.h"
413 ctx
->PB
->count
= count
;
414 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
418 #define CHECK_FULL(count) \
419 if (count >= PB_SIZE-MAX_WIDTH) { \
420 ctx->PB->count = count; \
422 count = ctx->PB->count; \
427 /* Smooth shaded, color index, any width, maybe stippled */
428 static void general_smooth_ci_line( GLcontext
*ctx
,
429 GLuint vert0
, GLuint vert1
, GLuint pvert
)
431 GLint count
= ctx
->PB
->count
;
432 GLint
*pbx
= ctx
->PB
->x
;
433 GLint
*pby
= ctx
->PB
->y
;
434 GLdepth
*pbz
= ctx
->PB
->z
;
435 GLuint
*pbi
= ctx
->PB
->i
;
438 if (ctx
->Line
.StippleFlag
) {
442 #define INTERP_INDEX 1
452 #include "linetemp.h"
456 if (ctx
->Line
.Width
==2.0F
) {
457 /* special case: unstippled and width=2 */
460 #define INTERP_INDEX 1
461 #define XMAJOR_PLOT(X,Y) \
462 pbx[count] = X; pbx[count+1] = X; \
463 pby[count] = Y; pby[count+1] = Y+1; \
464 pbz[count] = Z; pbz[count+1] = Z; \
465 pbi[count] = I; pbi[count+1] = I; \
468 #define YMAJOR_PLOT(X,Y) \
469 pbx[count] = X; pbx[count+1] = X+1; \
470 pby[count] = Y; pby[count+1] = Y; \
471 pbz[count] = Z; pbz[count+1] = Z; \
472 pbi[count] = I; pbi[count+1] = I; \
475 #include "linetemp.h"
478 /* unstippled, any width */
481 #define INTERP_INDEX 1
490 #include "linetemp.h"
494 ctx
->PB
->count
= count
;
495 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
499 /* Flat shaded, color index, any width, maybe stippled */
500 static void general_flat_ci_line( GLcontext
*ctx
,
501 GLuint vert0
, GLuint vert1
, GLuint pvert
)
504 GLint
*pbx
= ctx
->PB
->x
;
505 GLint
*pby
= ctx
->PB
->y
;
506 GLdepth
*pbz
= ctx
->PB
->z
;
507 PB_SET_INDEX( ctx
, ctx
->PB
, ctx
->VB
->IndexPtr
->data
[pvert
] );
508 count
= ctx
->PB
->count
;
510 if (ctx
->Line
.StippleFlag
) {
511 /* stippled, any width */
522 #include "linetemp.h"
526 if (ctx
->Line
.Width
==2.0F
) {
527 /* special case: unstippled and width=2 */
530 #define XMAJOR_PLOT(X,Y) \
531 pbx[count] = X; pbx[count+1] = X; \
532 pby[count] = Y; pby[count+1] = Y+1; \
533 pbz[count] = Z; pbz[count+1] = Z; \
536 #define YMAJOR_PLOT(X,Y) \
537 pbx[count] = X; pbx[count+1] = X+1; \
538 pby[count] = Y; pby[count+1] = Y; \
539 pbz[count] = Z; pbz[count+1] = Z; \
542 #include "linetemp.h"
545 /* unstippled, any width */
555 #include "linetemp.h"
559 ctx
->PB
->count
= count
;
560 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
565 static void general_smooth_rgba_line( GLcontext
*ctx
,
566 GLuint vert0
, GLuint vert1
, GLuint pvert
)
568 GLint count
= ctx
->PB
->count
;
569 GLint
*pbx
= ctx
->PB
->x
;
570 GLint
*pby
= ctx
->PB
->y
;
571 GLdepth
*pbz
= ctx
->PB
->z
;
572 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
575 if (ctx
->Line
.StippleFlag
) {
580 #define INTERP_ALPHA 1
587 pbrgba[count][RCOMP] = FixedToInt(r0); \
588 pbrgba[count][GCOMP] = FixedToInt(g0); \
589 pbrgba[count][BCOMP] = FixedToInt(b0); \
590 pbrgba[count][ACOMP] = FixedToInt(a0); \
593 #include "linetemp.h"
597 if (ctx
->Line
.Width
==2.0F
) {
598 /* special case: unstippled and width=2 */
602 #define INTERP_ALPHA 1
603 #define XMAJOR_PLOT(X,Y) \
604 pbx[count] = X; pbx[count+1] = X; \
605 pby[count] = Y; pby[count+1] = Y+1; \
606 pbz[count] = Z; pbz[count+1] = Z; \
607 pbrgba[count][RCOMP] = FixedToInt(r0); \
608 pbrgba[count][GCOMP] = FixedToInt(g0); \
609 pbrgba[count][BCOMP] = FixedToInt(b0); \
610 pbrgba[count][ACOMP] = FixedToInt(a0); \
611 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
612 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
613 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
614 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
617 #define YMAJOR_PLOT(X,Y) \
618 pbx[count] = X; pbx[count+1] = X+1; \
619 pby[count] = Y; pby[count+1] = Y; \
620 pbz[count] = Z; pbz[count+1] = Z; \
621 pbrgba[count][RCOMP] = FixedToInt(r0); \
622 pbrgba[count][GCOMP] = FixedToInt(g0); \
623 pbrgba[count][BCOMP] = FixedToInt(b0); \
624 pbrgba[count][ACOMP] = FixedToInt(a0); \
625 pbrgba[count+1][RCOMP] = FixedToInt(r0); \
626 pbrgba[count+1][GCOMP] = FixedToInt(g0); \
627 pbrgba[count+1][BCOMP] = FixedToInt(b0); \
628 pbrgba[count+1][ACOMP] = FixedToInt(a0); \
631 #include "linetemp.h"
634 /* unstippled, any width */
638 #define INTERP_ALPHA 1
644 pbrgba[count][RCOMP] = FixedToInt(r0); \
645 pbrgba[count][GCOMP] = FixedToInt(g0); \
646 pbrgba[count][BCOMP] = FixedToInt(b0); \
647 pbrgba[count][ACOMP] = FixedToInt(a0); \
650 #include "linetemp.h"
654 ctx
->PB
->count
= count
;
655 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
659 static void general_flat_rgba_line( GLcontext
*ctx
,
660 GLuint vert0
, GLuint vert1
, GLuint pvert
)
663 GLint
*pbx
= ctx
->PB
->x
;
664 GLint
*pby
= ctx
->PB
->y
;
665 GLdepth
*pbz
= ctx
->PB
->z
;
666 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pvert
];
667 PB_SET_COLOR( ctx
, ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
668 count
= ctx
->PB
->count
;
670 if (ctx
->Line
.StippleFlag
) {
682 #include "linetemp.h"
686 if (ctx
->Line
.Width
==2.0F
) {
687 /* special case: unstippled and width=2 */
690 #define XMAJOR_PLOT(X,Y) \
691 pbx[count] = X; pbx[count+1] = X; \
692 pby[count] = Y; pby[count+1] = Y+1; \
693 pbz[count] = Z; pbz[count+1] = Z; \
696 #define YMAJOR_PLOT(X,Y) \
697 pbx[count] = X; pbx[count+1] = X+1; \
698 pby[count] = Y; pby[count+1] = Y; \
699 pbz[count] = Z; pbz[count+1] = Z; \
702 #include "linetemp.h"
705 /* unstippled, any width */
715 #include "linetemp.h"
719 ctx
->PB
->count
= count
;
720 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
724 /* Flat-shaded, textured, any width, maybe stippled */
725 static void flat_textured_line( GLcontext
*ctx
,
726 GLuint vert0
, GLuint vert1
, GLuint pv
)
729 GLint
*pbx
= ctx
->PB
->x
;
730 GLint
*pby
= ctx
->PB
->y
;
731 GLdepth
*pbz
= ctx
->PB
->z
;
732 GLfloat
*pbs
= ctx
->PB
->s
[0];
733 GLfloat
*pbt
= ctx
->PB
->t
[0];
734 GLfloat
*pbu
= ctx
->PB
->u
[0];
735 GLubyte
*color
= ctx
->VB
->ColorPtr
->data
[pv
];
736 PB_SET_COLOR( ctx
, ctx
->PB
, color
[0], color
[1], color
[2], color
[3] );
737 count
= ctx
->PB
->count
;
739 if (ctx
->Line
.StippleFlag
) {
743 #define INTERP_STUV0 1
757 #include "linetemp.h"
763 #define INTERP_STUV0 1
776 #include "linetemp.h"
779 ctx
->PB
->count
= count
;
780 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
785 /* Smooth-shaded, textured, any width, maybe stippled */
786 static void smooth_textured_line( GLcontext
*ctx
,
787 GLuint vert0
, GLuint vert1
, GLuint pvert
)
789 GLint count
= ctx
->PB
->count
;
790 GLint
*pbx
= ctx
->PB
->x
;
791 GLint
*pby
= ctx
->PB
->y
;
792 GLdepth
*pbz
= ctx
->PB
->z
;
793 GLfloat
*pbs
= ctx
->PB
->s
[0];
794 GLfloat
*pbt
= ctx
->PB
->t
[0];
795 GLfloat
*pbu
= ctx
->PB
->u
[0];
796 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
799 if (ctx
->Line
.StippleFlag
) {
804 #define INTERP_ALPHA 1
805 #define INTERP_STUV0 1
816 pbrgba[count][RCOMP] = FixedToInt(r0); \
817 pbrgba[count][GCOMP] = FixedToInt(g0); \
818 pbrgba[count][BCOMP] = FixedToInt(b0); \
819 pbrgba[count][ACOMP] = FixedToInt(a0); \
823 #include "linetemp.h"
830 #define INTERP_ALPHA 1
831 #define INTERP_STUV0 1
841 pbrgba[count][RCOMP] = FixedToInt(r0); \
842 pbrgba[count][GCOMP] = FixedToInt(g0); \
843 pbrgba[count][BCOMP] = FixedToInt(b0); \
844 pbrgba[count][ACOMP] = FixedToInt(a0); \
848 #include "linetemp.h"
851 ctx
->PB
->count
= count
;
852 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
856 /* Smooth-shaded, multitextured, any width, maybe stippled, separate specular
857 * color interpolation.
859 static void smooth_multitextured_line( GLcontext
*ctx
,
860 GLuint vert0
, GLuint vert1
, GLuint pvert
)
862 GLint count
= ctx
->PB
->count
;
863 GLint
*pbx
= ctx
->PB
->x
;
864 GLint
*pby
= ctx
->PB
->y
;
865 GLdepth
*pbz
= ctx
->PB
->z
;
866 GLfloat
*pbs
= ctx
->PB
->s
[0];
867 GLfloat
*pbt
= ctx
->PB
->t
[0];
868 GLfloat
*pbu
= ctx
->PB
->u
[0];
869 GLfloat
*pbs1
= ctx
->PB
->s
[1];
870 GLfloat
*pbt1
= ctx
->PB
->t
[1];
871 GLfloat
*pbu1
= ctx
->PB
->u
[1];
872 GLubyte (*pbrgba
)[4] = ctx
->PB
->rgba
;
873 GLubyte (*pbspec
)[3] = ctx
->PB
->spec
;
876 if (ctx
->Line
.StippleFlag
) {
881 #define INTERP_SPEC 1
882 #define INTERP_ALPHA 1
883 #define INTERP_STUV0 1
884 #define INTERP_STUV1 1
898 pbrgba[count][RCOMP] = FixedToInt(r0); \
899 pbrgba[count][GCOMP] = FixedToInt(g0); \
900 pbrgba[count][BCOMP] = FixedToInt(b0); \
901 pbrgba[count][ACOMP] = FixedToInt(a0); \
902 pbspec[count][RCOMP] = FixedToInt(sr0); \
903 pbspec[count][GCOMP] = FixedToInt(sg0); \
904 pbspec[count][BCOMP] = FixedToInt(sb0); \
908 #include "linetemp.h"
915 #define INTERP_SPEC 1
916 #define INTERP_ALPHA 1
917 #define INTERP_STUV0 1
918 #define INTERP_STUV1 1
931 pbrgba[count][RCOMP] = FixedToInt(r0); \
932 pbrgba[count][GCOMP] = FixedToInt(g0); \
933 pbrgba[count][BCOMP] = FixedToInt(b0); \
934 pbrgba[count][ACOMP] = FixedToInt(a0); \
935 pbspec[count][RCOMP] = FixedToInt(sr0); \
936 pbspec[count][GCOMP] = FixedToInt(sg0); \
937 pbspec[count][BCOMP] = FixedToInt(sb0); \
941 #include "linetemp.h"
944 ctx
->PB
->count
= count
;
945 PB_CHECK_FLUSH( ctx
, ctx
->PB
);
950 * Antialiased RGBA line
952 * This AA line function isn't terribly efficient but it's pretty
953 * straight-forward to understand. Also, it doesn't exactly conform
954 * to the specification.
956 static void aa_rgba_line( GLcontext
*ctx
,
957 GLuint vert0
, GLuint vert1
, GLuint pvert
)
959 #define INTERP_RGBA 1
960 #define PLOT(x, y) { PB_WRITE_RGBA_PIXEL( pb, (x), (y), z, red, green, blue, coverage ); }
961 #include "lnaatemp.h"
965 * Antialiased Textured RGBA line
967 * This AA line function isn't terribly efficient but it's pretty
968 * straight-forward to understand. Also, it doesn't exactly conform
969 * to the specification.
971 static void aa_tex_rgba_line( GLcontext
*ctx
,
972 GLuint vert0
, GLuint vert1
, GLuint pvert
)
974 #define INTERP_RGBA 1
975 #define INTERP_STUV0 1
978 PB_WRITE_TEX_PIXEL( pb, (x), (y), z, red, green, blue, coverage, \
981 #include "lnaatemp.h"
986 * Antialiased Multitextured RGBA line
988 * This AA line function isn't terribly efficient but it's pretty
989 * straight-forward to understand. Also, it doesn't exactly conform
990 * to the specification.
992 static void aa_multitex_rgba_line( GLcontext
*ctx
,
993 GLuint vert0
, GLuint vert1
, GLuint pvert
)
995 #define INTERP_RGBA 1
996 #define INTERP_SPEC 1
997 #define INTERP_STUV0 1
998 #define INTERP_STUV1 1
1001 PB_WRITE_MULTITEX_SPEC_PIXEL( pb, (x), (y), z, \
1002 red, green, blue, coverage, specRed, specGreen, specBlue, \
1003 s, t, u, s1, t1, u1 ); \
1005 #include "lnaatemp.h"
1010 * Antialiased CI line. Same comments for RGBA antialiased lines apply.
1012 static void aa_ci_line( GLcontext
*ctx
,
1013 GLuint vert0
, GLuint vert1
, GLuint pvert
)
1015 #define INTERP_INDEX 1
1016 #define PLOT(x, y) \
1018 PB_WRITE_CI_PIXEL( pb, (x), (y), z, index + coverage ); \
1020 #include "lnaatemp.h"
1025 * Null rasterizer for measuring transformation speed.
1027 static void null_line( GLcontext
*ctx
, GLuint v1
, GLuint v2
, GLuint pv
)
1037 * Determine which line drawing function to use given the current
1038 * rendering context.
1040 void gl_set_line_function( GLcontext
*ctx
)
1042 GLboolean rgbmode
= ctx
->Visual
->RGBAflag
;
1043 /* TODO: antialiased lines */
1045 if (ctx
->RenderMode
==GL_RENDER
) {
1046 if (ctx
->NoRaster
) {
1047 ctx
->Driver
.LineFunc
= null_line
;
1050 if (ctx
->Driver
.LineFunc
) {
1051 /* Device driver will draw lines. */
1055 if (ctx
->Line
.SmoothFlag
) {
1056 /* antialiased lines */
1058 if (ctx
->Texture
.ReallyEnabled
) {
1059 if (ctx
->Texture
.ReallyEnabled
>= TEXTURE1_1D
1060 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
)
1061 /* Multitextured! */
1062 ctx
->Driver
.LineFunc
= aa_multitex_rgba_line
;
1064 ctx
->Driver
.LineFunc
= aa_tex_rgba_line
;
1066 ctx
->Driver
.LineFunc
= aa_rgba_line
;
1070 ctx
->Driver
.LineFunc
= aa_ci_line
;
1073 else if (ctx
->Texture
.ReallyEnabled
) {
1074 if (ctx
->Texture
.ReallyEnabled
>= TEXTURE1_1D
1075 || ctx
->Light
.Model
.ColorControl
==GL_SEPARATE_SPECULAR_COLOR
) {
1076 /* multi-texture and/or separate specular color */
1077 ctx
->Driver
.LineFunc
= smooth_multitextured_line
;
1080 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1081 ctx
->Driver
.LineFunc
= smooth_textured_line
;
1084 ctx
->Driver
.LineFunc
= flat_textured_line
;
1088 else if (ctx
->Line
.Width
!=1.0 || ctx
->Line
.StippleFlag
1089 || ctx
->Line
.SmoothFlag
) {
1090 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1092 ctx
->Driver
.LineFunc
= general_smooth_rgba_line
;
1094 ctx
->Driver
.LineFunc
= general_smooth_ci_line
;
1098 ctx
->Driver
.LineFunc
= general_flat_rgba_line
;
1100 ctx
->Driver
.LineFunc
= general_flat_ci_line
;
1104 if (ctx
->Light
.ShadeModel
==GL_SMOOTH
) {
1105 /* Width==1, non-stippled, smooth-shaded */
1107 || (ctx
->Fog
.Enabled
&& ctx
->Hint
.Fog
==GL_NICEST
)) {
1109 ctx
->Driver
.LineFunc
= smooth_rgba_z_line
;
1111 ctx
->Driver
.LineFunc
= smooth_ci_z_line
;
1115 ctx
->Driver
.LineFunc
= smooth_rgba_line
;
1117 ctx
->Driver
.LineFunc
= smooth_ci_line
;
1121 /* Width==1, non-stippled, flat-shaded */
1123 || (ctx
->Fog
.Enabled
&& ctx
->Hint
.Fog
==GL_NICEST
)) {
1125 ctx
->Driver
.LineFunc
= flat_rgba_z_line
;
1127 ctx
->Driver
.LineFunc
= flat_ci_z_line
;
1131 ctx
->Driver
.LineFunc
= flat_rgba_line
;
1133 ctx
->Driver
.LineFunc
= flat_ci_line
;
1138 else if (ctx
->RenderMode
==GL_FEEDBACK
) {
1139 ctx
->Driver
.LineFunc
= feedback_line
;
1142 /* GL_SELECT mode */
1143 ctx
->Driver
.LineFunc
= select_line
;