2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Keith Whitwell <keith@tungstengraphics.com>
29 #define VERT_SET_IND( v, c )
30 #define VERT_COPY_IND( v0, v1 )
31 #define VERT_SAVE_IND( idx )
32 #define VERT_RESTORE_IND( idx )
36 #define VERT_SET_SPEC( v, c )
37 #define VERT_COPY_SPEC( v0, v1 )
38 #define VERT_SAVE_SPEC( idx )
39 #define VERT_RESTORE_SPEC( idx )
42 static void TAG(unfilled_tri
)( GLcontext
*ctx
,
44 GLuint e0
, GLuint e1
, GLuint e2
)
46 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
47 GLubyte
*ef
= VB
->EdgeFlag
;
51 v
[0] = (VERTEX
*)GET_VERTEX(e0
);
52 v
[1] = (VERTEX
*)GET_VERTEX(e1
);
53 v
[2] = (VERTEX
*)GET_VERTEX(e2
);
55 if (ctx
->Light
.ShadeModel
== GL_FLAT
&& HAVE_HW_FLATSHADE
) {
59 VERT_COPY_RGBA(v
[0], v
[2]);
60 VERT_COPY_RGBA(v
[1], v
[2]);
65 VERT_COPY_SPEC(v
[0], v
[2]);
66 VERT_COPY_SPEC(v
[1], v
[2]);
71 VERT_COPY_IND(v
[0], v
[2]);
72 VERT_COPY_IND(v
[1], v
[2]);
76 /* fprintf(stderr, "%s %s %d %d %d\n", __FUNCTION__, */
77 /* _mesa_lookup_enum_by_nr( mode ), */
78 /* ef[e0], ef[e1], ef[e2]); */
80 if (mode
== GL_POINT
) {
82 if (ef
[e0
]) POINT( v
[0] );
83 if (ef
[e1
]) POINT( v
[1] );
84 if (ef
[e2
]) POINT( v
[2] );
88 if (RENDER_PRIMITIVE
== GL_POLYGON
) {
89 if (ef
[e2
]) LINE( v
[2], v
[0] );
90 if (ef
[e0
]) LINE( v
[0], v
[1] );
91 if (ef
[e1
]) LINE( v
[1], v
[2] );
94 if (ef
[e0
]) LINE( v
[0], v
[1] );
95 if (ef
[e1
]) LINE( v
[1], v
[2] );
96 if (ef
[e2
]) LINE( v
[2], v
[0] );
100 if (ctx
->Light
.ShadeModel
== GL_FLAT
&& HAVE_HW_FLATSHADE
) {
102 VERT_RESTORE_RGBA(0);
103 VERT_RESTORE_RGBA(1);
106 VERT_RESTORE_SPEC(0);
107 VERT_RESTORE_SPEC(1);
117 static void TAG(unfilled_quad
)( GLcontext
*ctx
,
119 GLuint e0
, GLuint e1
,
120 GLuint e2
, GLuint e3
)
122 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
123 GLubyte
*ef
= VB
->EdgeFlag
;
127 v
[0] = (VERTEX
*)GET_VERTEX(e0
);
128 v
[1] = (VERTEX
*)GET_VERTEX(e1
);
129 v
[2] = (VERTEX
*)GET_VERTEX(e2
);
130 v
[3] = (VERTEX
*)GET_VERTEX(e3
);
132 /* Hardware flatshading breaks down here. If the hardware doesn't
133 * support flatshading, this will already have been done:
135 if (ctx
->Light
.ShadeModel
== GL_FLAT
&& HAVE_HW_FLATSHADE
) {
140 VERT_COPY_RGBA(v
[0], v
[3]);
141 VERT_COPY_RGBA(v
[1], v
[3]);
142 VERT_COPY_RGBA(v
[2], v
[3]);
148 VERT_COPY_SPEC(v
[0], v
[3]);
149 VERT_COPY_SPEC(v
[1], v
[3]);
150 VERT_COPY_SPEC(v
[2], v
[3]);
156 VERT_COPY_IND(v
[0], v
[3]);
157 VERT_COPY_IND(v
[1], v
[3]);
158 VERT_COPY_IND(v
[2], v
[3]);
162 if (mode
== GL_POINT
) {
163 RASTERIZE(GL_POINTS
);
164 if (ef
[e0
]) POINT( v
[0] );
165 if (ef
[e1
]) POINT( v
[1] );
166 if (ef
[e2
]) POINT( v
[2] );
167 if (ef
[e3
]) POINT( v
[3] );
171 if (ef
[e0
]) LINE( v
[0], v
[1] );
172 if (ef
[e1
]) LINE( v
[1], v
[2] );
173 if (ef
[e2
]) LINE( v
[2], v
[3] );
174 if (ef
[e3
]) LINE( v
[3], v
[0] );
177 if (ctx
->Light
.ShadeModel
== GL_FLAT
&& HAVE_HW_FLATSHADE
) {
179 VERT_RESTORE_RGBA(0);
180 VERT_RESTORE_RGBA(1);
181 VERT_RESTORE_RGBA(2);
184 VERT_RESTORE_SPEC(0);
185 VERT_RESTORE_SPEC(1);
186 VERT_RESTORE_SPEC(2);
201 #undef VERT_RESTORE_IND
206 #undef VERT_COPY_SPEC
207 #undef VERT_SAVE_SPEC
208 #undef VERT_RESTORE_SPEC