Template work
[mesa.git] / src / mesa / drivers / common / t_dd_unfilled.h
1 #if HAVE_RGBA
2 #define VERT_SET_IND( v, c )
3 #define VERT_COPY_IND( v0, v1 )
4 #define VERT_SAVE_IND( idx )
5 #define VERT_RESTORE_IND( idx )
6 #endif
7
8 #if !HAVE_SPEC
9 #define VERT_SET_SPEC( v, c )
10 #define VERT_COPY_SPEC( v0, v1 )
11 #define VERT_SAVE_SPEC( idx )
12 #define VERT_RESTORE_SPEC( idx )
13 #endif
14
15 static void TAG(unfilled_tri)( GLcontext *ctx,
16 GLenum mode,
17 GLuint e0, GLuint e1, GLuint e2 )
18 {
19 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
20 GLubyte *ef = VB->EdgeFlag;
21 VERTEX *v[3];
22 LOCAL_VARS(3);
23
24 v[0] = (VERTEX *)GET_VERTEX(e0);
25 v[1] = (VERTEX *)GET_VERTEX(e1);
26 v[2] = (VERTEX *)GET_VERTEX(e2);
27
28 if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
29 if (HAVE_RGBA) {
30 VERT_SAVE_RGBA(0);
31 VERT_SAVE_RGBA(1);
32 VERT_COPY_RGBA(v[0], v[2]);
33 VERT_COPY_RGBA(v[1], v[2]);
34
35 if (HAVE_SPEC) {
36 VERT_SAVE_SPEC(0);
37 VERT_SAVE_SPEC(1);
38 VERT_COPY_SPEC(v[0], v[2]);
39 VERT_COPY_SPEC(v[1], v[2]);
40 }
41 } else {
42 VERT_SAVE_IND(0);
43 VERT_SAVE_IND(1);
44 VERT_COPY_IND(v[0], v[2]);
45 VERT_COPY_IND(v[1], v[2]);
46 }
47 }
48
49 if (mode == GL_POINT) {
50 RASTERIZE(GL_POINTS);
51 if (ef[e0]) POINT( v[0] );
52 if (ef[e1]) POINT( v[1] );
53 if (ef[e2]) POINT( v[2] );
54 }
55 else {
56 RASTERIZE(GL_LINES);
57 if (RENDER_PRIMITIVE == GL_POLYGON) {
58 if (ef[e2]) LINE( v[2], v[0] );
59 if (ef[e0]) LINE( v[0], v[1] );
60 if (ef[e1]) LINE( v[1], v[2] );
61 }
62 else {
63 if (ef[e0]) LINE( v[0], v[1] );
64 if (ef[e1]) LINE( v[1], v[2] );
65 if (ef[e2]) LINE( v[2], v[0] );
66 }
67 }
68
69 if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
70 if (HAVE_RGBA) {
71 VERT_RESTORE_RGBA(0);
72 VERT_RESTORE_RGBA(1);
73
74 if (HAVE_SPEC) {
75 VERT_RESTORE_SPEC(0);
76 VERT_RESTORE_SPEC(1);
77 }
78 } else {
79 VERT_RESTORE_IND(0);
80 VERT_RESTORE_IND(1);
81 }
82 }
83 }
84
85
86 static void TAG(unfilled_quad)( GLcontext *ctx,
87 GLenum mode,
88 GLuint e0, GLuint e1,
89 GLuint e2, GLuint e3 )
90 {
91 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
92 GLubyte *ef = VB->EdgeFlag;
93 VERTEX *v[4];
94 LOCAL_VARS(4);
95
96 v[0] = (VERTEX *)GET_VERTEX(e0);
97 v[1] = (VERTEX *)GET_VERTEX(e1);
98 v[2] = (VERTEX *)GET_VERTEX(e2);
99 v[3] = (VERTEX *)GET_VERTEX(e3);
100
101 /* Hardware flatshading breaks down here. If the hardware doesn't
102 * support flatshading, this will already have been done:
103 */
104 if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
105 if (HAVE_RGBA) {
106 VERT_SAVE_RGBA(0);
107 VERT_SAVE_RGBA(1);
108 VERT_SAVE_RGBA(2);
109 VERT_COPY_RGBA(v[0], v[3]);
110 VERT_COPY_RGBA(v[1], v[3]);
111 VERT_COPY_RGBA(v[2], v[3]);
112
113 if (HAVE_SPEC) {
114 VERT_SAVE_SPEC(0);
115 VERT_SAVE_SPEC(1);
116 VERT_SAVE_SPEC(2);
117 VERT_COPY_SPEC(v[0], v[3]);
118 VERT_COPY_SPEC(v[1], v[3]);
119 VERT_COPY_SPEC(v[2], v[3]);
120 }
121 } else {
122 VERT_SAVE_IND(0);
123 VERT_SAVE_IND(1);
124 VERT_SAVE_IND(2);
125 VERT_COPY_IND(v[0], v[3]);
126 VERT_COPY_IND(v[1], v[3]);
127 VERT_COPY_IND(v[2], v[3]);
128 }
129 }
130
131 if (mode == GL_POINT) {
132 RASTERIZE(GL_POINTS);
133 if (ef[e0]) POINT( v[0] );
134 if (ef[e1]) POINT( v[1] );
135 if (ef[e2]) POINT( v[2] );
136 if (ef[e3]) POINT( v[3] );
137 }
138 else {
139 RASTERIZE(GL_LINES);
140 if (ef[e0]) LINE( v[0], v[1] );
141 if (ef[e1]) LINE( v[1], v[2] );
142 if (ef[e2]) LINE( v[2], v[3] );
143 if (ef[e3]) LINE( v[3], v[0] );
144 }
145
146 if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
147 if (HAVE_RGBA) {
148 VERT_RESTORE_RGBA(0);
149 VERT_RESTORE_RGBA(1);
150 VERT_RESTORE_RGBA(2);
151
152 if (HAVE_SPEC) {
153 VERT_RESTORE_SPEC(0);
154 VERT_RESTORE_SPEC(1);
155 VERT_RESTORE_SPEC(2);
156 }
157 } else {
158 VERT_RESTORE_IND(0);
159 VERT_RESTORE_IND(1);
160 VERT_RESTORE_IND(2);
161 }
162 }
163 }
164
165
166 #if HAVE_RGBA
167 #undef VERT_SET_IND
168 #undef VERT_COPY_IND
169 #undef VERT_SAVE_IND
170 #undef VERT_RESTORE_IND
171 #endif
172
173 #if !HAVE_SPEC
174 #undef VERT_SET_SPEC
175 #undef VERT_COPY_SPEC
176 #undef VERT_SAVE_SPEC
177 #undef VERT_RESTORE_SPEC
178 #endif
179
180 #undef TAG