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_SPEC( v, c )
30 #define VERT_COPY_SPEC( v0, v1 )
31 #define VERT_SAVE_SPEC( idx )
32 #define VERT_RESTORE_SPEC( idx )
35 static void TAG(unfilled_tri)( struct gl_context *ctx,
37 GLuint e0, GLuint e1, GLuint e2 )
39 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
40 GLubyte *ef = VB->EdgeFlag;
44 v[0] = (VERTEX *)GET_VERTEX(e0);
45 v[1] = (VERTEX *)GET_VERTEX(e1);
46 v[2] = (VERTEX *)GET_VERTEX(e2);
48 if (ctx->Light.ShadeModel == GL_FLAT && HAVE_HW_FLATSHADE) {
51 VERT_COPY_RGBA(v[0], v[2]);
52 VERT_COPY_RGBA(v[1], v[2]);
57 VERT_COPY_SPEC(v[0], v[2]);
58 VERT_COPY_SPEC(v[1], v[2]);
62 /* fprintf(stderr, "%s %s %d %d %d\n", __FUNCTION__, */
63 /* _mesa_lookup_enum_by_nr( mode ), */
64 /* ef[e0], ef[e1], ef[e2]); */
66 if (mode == GL_POINT) {
68 if (ef[e0]) POINT( v[0] );
69 if (ef[e1]) POINT( v[1] );
70 if (ef[e2]) POINT( v[2] );
74 if (RENDER_PRIMITIVE == GL_POLYGON) {
75 if (ef[e2]) LINE( v[2], v[0] );
76 if (ef[e0]) LINE( v[0], v[1] );
77 if (ef[e1]) LINE( v[1], v[2] );
80 if (ef[e0]) LINE( v[0], v[1] );
81 if (ef[e1]) LINE( v[1], v[2] );
82 if (ef[e2]) LINE( v[2], v[0] );
86 if (ctx->Light.ShadeModel == GL_FLAT && HAVE_HW_FLATSHADE) {
98 static void TAG(unfilled_quad)( struct gl_context *ctx,
100 GLuint e0, GLuint e1,
101 GLuint e2, GLuint e3 )
103 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
104 GLubyte *ef = VB->EdgeFlag;
108 v[0] = (VERTEX *)GET_VERTEX(e0);
109 v[1] = (VERTEX *)GET_VERTEX(e1);
110 v[2] = (VERTEX *)GET_VERTEX(e2);
111 v[3] = (VERTEX *)GET_VERTEX(e3);
113 /* Hardware flatshading breaks down here. If the hardware doesn't
114 * support flatshading, this will already have been done:
116 if (ctx->Light.ShadeModel == GL_FLAT && HAVE_HW_FLATSHADE) {
120 VERT_COPY_RGBA(v[0], v[3]);
121 VERT_COPY_RGBA(v[1], v[3]);
122 VERT_COPY_RGBA(v[2], v[3]);
128 VERT_COPY_SPEC(v[0], v[3]);
129 VERT_COPY_SPEC(v[1], v[3]);
130 VERT_COPY_SPEC(v[2], v[3]);
134 if (mode == GL_POINT) {
135 RASTERIZE(GL_POINTS);
136 if (ef[e0]) POINT( v[0] );
137 if (ef[e1]) POINT( v[1] );
138 if (ef[e2]) POINT( v[2] );
139 if (ef[e3]) POINT( v[3] );
143 if (ef[e0]) LINE( v[0], v[1] );
144 if (ef[e1]) LINE( v[1], v[2] );
145 if (ef[e2]) LINE( v[2], v[3] );
146 if (ef[e3]) LINE( v[3], v[0] );
149 if (ctx->Light.ShadeModel == GL_FLAT && HAVE_HW_FLATSHADE) {
150 VERT_RESTORE_RGBA(0);
151 VERT_RESTORE_RGBA(1);
152 VERT_RESTORE_RGBA(2);
155 VERT_RESTORE_SPEC(0);
156 VERT_RESTORE_SPEC(1);
157 VERT_RESTORE_SPEC(2);
165 #undef VERT_COPY_SPEC
166 #undef VERT_SAVE_SPEC
167 #undef VERT_RESTORE_SPEC