3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * Keith Whitwell <keith@tungstengraphics.com>
30 #define VERT_SET_IND( v, c )
31 #define VERT_COPY_IND( v0, v1 )
32 #define VERT_SAVE_IND( idx )
33 #define VERT_RESTORE_IND( idx )
37 #define VERT_SET_SPEC( v, c )
38 #define VERT_COPY_SPEC( v0, v1 )
39 #define VERT_SAVE_SPEC( idx )
40 #define VERT_RESTORE_SPEC( idx )
43 static void TAG(unfilled_tri
)( GLcontext
*ctx
,
45 GLuint e0
, GLuint e1
, GLuint e2
)
47 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
48 GLubyte
*ef
= VB
->EdgeFlag
;
52 v
[0] = (VERTEX
*)GET_VERTEX(e0
);
53 v
[1] = (VERTEX
*)GET_VERTEX(e1
);
54 v
[2] = (VERTEX
*)GET_VERTEX(e2
);
56 if ((ctx
->_TriangleCaps
& DD_FLATSHADE
) && HAVE_HW_FLATSHADE
) {
60 VERT_COPY_RGBA(v
[0], v
[2]);
61 VERT_COPY_RGBA(v
[1], v
[2]);
66 VERT_COPY_SPEC(v
[0], v
[2]);
67 VERT_COPY_SPEC(v
[1], v
[2]);
72 VERT_COPY_IND(v
[0], v
[2]);
73 VERT_COPY_IND(v
[1], v
[2]);
77 /* fprintf(stderr, "%s %s %d %d %d\n", __FUNCTION__, */
78 /* _mesa_lookup_enum_by_nr( mode ), */
79 /* ef[e0], ef[e1], ef[e2]); */
81 if (mode
== GL_POINT
) {
83 if (ef
[e0
]) POINT( v
[0] );
84 if (ef
[e1
]) POINT( v
[1] );
85 if (ef
[e2
]) POINT( v
[2] );
89 if (RENDER_PRIMITIVE
== GL_POLYGON
) {
90 if (ef
[e2
]) LINE( v
[2], v
[0] );
91 if (ef
[e0
]) LINE( v
[0], v
[1] );
92 if (ef
[e1
]) LINE( v
[1], v
[2] );
95 if (ef
[e0
]) LINE( v
[0], v
[1] );
96 if (ef
[e1
]) LINE( v
[1], v
[2] );
97 if (ef
[e2
]) LINE( v
[2], v
[0] );
101 if ((ctx
->_TriangleCaps
& DD_FLATSHADE
) && HAVE_HW_FLATSHADE
) {
103 VERT_RESTORE_RGBA(0);
104 VERT_RESTORE_RGBA(1);
107 VERT_RESTORE_SPEC(0);
108 VERT_RESTORE_SPEC(1);
118 static void TAG(unfilled_quad
)( GLcontext
*ctx
,
120 GLuint e0
, GLuint e1
,
121 GLuint e2
, GLuint e3
)
123 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
124 GLubyte
*ef
= VB
->EdgeFlag
;
128 v
[0] = (VERTEX
*)GET_VERTEX(e0
);
129 v
[1] = (VERTEX
*)GET_VERTEX(e1
);
130 v
[2] = (VERTEX
*)GET_VERTEX(e2
);
131 v
[3] = (VERTEX
*)GET_VERTEX(e3
);
133 /* Hardware flatshading breaks down here. If the hardware doesn't
134 * support flatshading, this will already have been done:
136 if ((ctx
->_TriangleCaps
& DD_FLATSHADE
) && HAVE_HW_FLATSHADE
) {
141 VERT_COPY_RGBA(v
[0], v
[3]);
142 VERT_COPY_RGBA(v
[1], v
[3]);
143 VERT_COPY_RGBA(v
[2], v
[3]);
149 VERT_COPY_SPEC(v
[0], v
[3]);
150 VERT_COPY_SPEC(v
[1], v
[3]);
151 VERT_COPY_SPEC(v
[2], v
[3]);
157 VERT_COPY_IND(v
[0], v
[3]);
158 VERT_COPY_IND(v
[1], v
[3]);
159 VERT_COPY_IND(v
[2], v
[3]);
163 if (mode
== GL_POINT
) {
164 RASTERIZE(GL_POINTS
);
165 if (ef
[e0
]) POINT( v
[0] );
166 if (ef
[e1
]) POINT( v
[1] );
167 if (ef
[e2
]) POINT( v
[2] );
168 if (ef
[e3
]) POINT( v
[3] );
172 if (ef
[e0
]) LINE( v
[0], v
[1] );
173 if (ef
[e1
]) LINE( v
[1], v
[2] );
174 if (ef
[e2
]) LINE( v
[2], v
[3] );
175 if (ef
[e3
]) LINE( v
[3], v
[0] );
178 if ((ctx
->_TriangleCaps
& DD_FLATSHADE
) && HAVE_HW_FLATSHADE
) {
180 VERT_RESTORE_RGBA(0);
181 VERT_RESTORE_RGBA(1);
182 VERT_RESTORE_RGBA(2);
185 VERT_RESTORE_SPEC(0);
186 VERT_RESTORE_SPEC(1);
187 VERT_RESTORE_SPEC(2);
202 #undef VERT_RESTORE_IND
207 #undef VERT_COPY_SPEC
208 #undef VERT_SAVE_SPEC
209 #undef VERT_RESTORE_SPEC