1 | /* $Id: aatritemp.h,v 1.1 2000-05-21 19:56:12 jeroen Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Mesa 3-D graphics library
|
---|
5 | * Version: 3.3
|
---|
6 | *
|
---|
7 | * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
|
---|
8 | *
|
---|
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:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included
|
---|
17 | * in all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
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.
|
---|
25 | */
|
---|
26 |
|
---|
27 |
|
---|
28 | /*
|
---|
29 | * Antialiased Triangle Rasterizer Template
|
---|
30 | *
|
---|
31 | * This file is #include'd to generate custom AA triangle rasterizers.
|
---|
32 | * NOTE: this code hasn't been optimized yet. That'll come after it
|
---|
33 | * works correctly.
|
---|
34 | *
|
---|
35 | * The following macros may be defined to indicate what auxillary information
|
---|
36 | * must be copmuted across the triangle:
|
---|
37 | * DO_Z - if defined, compute Z values
|
---|
38 | * DO_RGBA - if defined, compute RGBA values
|
---|
39 | * DO_INDEX - if defined, compute color index values
|
---|
40 | * DO_SPEC - if defined, compute specular RGB values
|
---|
41 | * DO_STUV0 - if defined, compute unit 0 STRQ texcoords
|
---|
42 | * DO_STUV1 - if defined, compute unit 1 STRQ texcoords
|
---|
43 | */
|
---|
44 |
|
---|
45 | /*void triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/
|
---|
46 | {
|
---|
47 | const struct vertex_buffer *VB = ctx->VB;
|
---|
48 | const GLfloat *p0 = VB->Win.data[v0];
|
---|
49 | const GLfloat *p1 = VB->Win.data[v1];
|
---|
50 | const GLfloat *p2 = VB->Win.data[v2];
|
---|
51 | GLint vMin, vMid, vMax;
|
---|
52 | GLint iyMin, iyMax;
|
---|
53 | GLfloat yMin, yMax;
|
---|
54 | GLboolean ltor;
|
---|
55 | GLfloat majDx, majDy;
|
---|
56 | #ifdef DO_Z
|
---|
57 | GLfloat zPlane[4]; /* Z (depth) */
|
---|
58 | GLdepth z[MAX_WIDTH];
|
---|
59 | #endif
|
---|
60 | #ifdef DO_RGBA
|
---|
61 | GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4]; /* color */
|
---|
62 | GLubyte rgba[MAX_WIDTH][4];
|
---|
63 | #endif
|
---|
64 | #ifdef DO_INDEX
|
---|
65 | GLfloat iPlane[4]; /* color index */
|
---|
66 | GLuint index[MAX_WIDTH];
|
---|
67 | #endif
|
---|
68 | #ifdef DO_SPEC
|
---|
69 | GLfloat srPlane[4], sgPlane[4], sbPlane[4]; /* spec color */
|
---|
70 | GLubyte spec[MAX_WIDTH][4];
|
---|
71 | #endif
|
---|
72 | #ifdef DO_STUV0
|
---|
73 | GLfloat s0Plane[4], t0Plane[4], u0Plane[4], v0Plane[4]; /* texture 0 */
|
---|
74 | GLfloat width0, height0;
|
---|
75 | GLfloat s[MAX_TEXTURE_UNITS][MAX_WIDTH];
|
---|
76 | GLfloat t[MAX_TEXTURE_UNITS][MAX_WIDTH];
|
---|
77 | GLfloat u[MAX_TEXTURE_UNITS][MAX_WIDTH];
|
---|
78 | GLfloat lambda[MAX_TEXTURE_UNITS][MAX_WIDTH];
|
---|
79 | #endif
|
---|
80 | #ifdef DO_STUV1
|
---|
81 | GLfloat s1Plane[4], t1Plane[4], u1Plane[4], v1Plane[4]; /* texture 1 */
|
---|
82 | GLfloat width1, height1;
|
---|
83 | #endif
|
---|
84 | GLfloat bf = ctx->backface_sign;
|
---|
85 |
|
---|
86 | /* determine bottom to top order of vertices */
|
---|
87 | {
|
---|
88 | GLfloat y0 = VB->Win.data[v0][1];
|
---|
89 | GLfloat y1 = VB->Win.data[v1][1];
|
---|
90 | GLfloat y2 = VB->Win.data[v2][1];
|
---|
91 | if (y0 <= y1) {
|
---|
92 | if (y1 <= y2) {
|
---|
93 | vMin = v0; vMid = v1; vMax = v2; /* y0<=y1<=y2 */
|
---|
94 | }
|
---|
95 | else if (y2 <= y0) {
|
---|
96 | vMin = v2; vMid = v0; vMax = v1; /* y2<=y0<=y1 */
|
---|
97 | }
|
---|
98 | else {
|
---|
99 | vMin = v0; vMid = v2; vMax = v1; bf = -bf; /* y0<=y2<=y1 */
|
---|
100 | }
|
---|
101 | }
|
---|
102 | else {
|
---|
103 | if (y0 <= y2) {
|
---|
104 | vMin = v1; vMid = v0; vMax = v2; bf = -bf; /* y1<=y0<=y2 */
|
---|
105 | }
|
---|
106 | else if (y2 <= y1) {
|
---|
107 | vMin = v2; vMid = v1; vMax = v0; bf = -bf; /* y2<=y1<=y0 */
|
---|
108 | }
|
---|
109 | else {
|
---|
110 | vMin = v1; vMid = v2; vMax = v0; /* y1<=y2<=y0 */
|
---|
111 | }
|
---|
112 | }
|
---|
113 | }
|
---|
114 |
|
---|
115 | majDx = VB->Win.data[vMax][0] - VB->Win.data[vMin][0];
|
---|
116 | majDy = VB->Win.data[vMax][1] - VB->Win.data[vMin][1];
|
---|
117 |
|
---|
118 | {
|
---|
119 | const GLfloat botDx = VB->Win.data[vMid][0] - VB->Win.data[vMin][0];
|
---|
120 | const GLfloat botDy = VB->Win.data[vMid][1] - VB->Win.data[vMin][1];
|
---|
121 | const GLfloat area = majDx * botDy - botDx * majDy;
|
---|
122 | ltor = (GLboolean) (area < 0.0F);
|
---|
123 | /* Do backface culling */
|
---|
124 | if (area * bf < 0 || area * area < .0025)
|
---|
125 | return;
|
---|
126 | }
|
---|
127 |
|
---|
128 | /* plane setup */
|
---|
129 | #ifdef DO_Z
|
---|
130 | compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane);
|
---|
131 | #endif
|
---|
132 | #ifdef DO_RGBA
|
---|
133 | if (ctx->Light.ShadeModel == GL_SMOOTH) {
|
---|
134 | GLubyte (*rgba)[4] = VB->ColorPtr->data;
|
---|
135 | compute_plane(p0, p1, p2, rgba[v0][0], rgba[v1][0], rgba[v2][0], rPlane);
|
---|
136 | compute_plane(p0, p1, p2, rgba[v0][1], rgba[v1][1], rgba[v2][1], gPlane);
|
---|
137 | compute_plane(p0, p1, p2, rgba[v0][2], rgba[v1][2], rgba[v2][2], bPlane);
|
---|
138 | compute_plane(p0, p1, p2, rgba[v0][3], rgba[v1][3], rgba[v2][3], aPlane);
|
---|
139 | }
|
---|
140 | else {
|
---|
141 | constant_plane(VB->ColorPtr->data[pv][RCOMP], rPlane);
|
---|
142 | constant_plane(VB->ColorPtr->data[pv][GCOMP], gPlane);
|
---|
143 | constant_plane(VB->ColorPtr->data[pv][BCOMP], bPlane);
|
---|
144 | constant_plane(VB->ColorPtr->data[pv][ACOMP], aPlane);
|
---|
145 | }
|
---|
146 | #endif
|
---|
147 | #ifdef DO_INDEX
|
---|
148 | if (ctx->Light.ShadeModel == GL_SMOOTH) {
|
---|
149 | compute_plane(p0, p1, p2, VB->IndexPtr->data[v0],
|
---|
150 | VB->IndexPtr->data[v1], VB->IndexPtr->data[v2], iPlane);
|
---|
151 | }
|
---|
152 | else {
|
---|
153 | constant_plane(VB->IndexPtr->data[pv], iPlane);
|
---|
154 | }
|
---|
155 | #endif
|
---|
156 | #ifdef DO_SPEC
|
---|
157 | {
|
---|
158 | GLubyte (*spec)[4] = VB->Specular;
|
---|
159 | compute_plane(p0, p1, p2, spec[v0][0], spec[v1][0], spec[v2][0],srPlane);
|
---|
160 | compute_plane(p0, p1, p2, spec[v0][1], spec[v1][1], spec[v2][1],sgPlane);
|
---|
161 | compute_plane(p0, p1, p2, spec[v0][2], spec[v1][2], spec[v2][2],sbPlane);
|
---|
162 | }
|
---|
163 | #endif
|
---|
164 | #ifdef DO_STUV0
|
---|
165 | {
|
---|
166 | const struct gl_texture_object *obj = ctx->Texture.Unit[0].Current;
|
---|
167 | const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel];
|
---|
168 | const GLint tSize = 3;
|
---|
169 | const GLfloat invW0 = VB->Win.data[v0][3];
|
---|
170 | const GLfloat invW1 = VB->Win.data[v1][3];
|
---|
171 | const GLfloat invW2 = VB->Win.data[v2][3];
|
---|
172 | GLfloat (*texCoord)[4] = VB->TexCoordPtr[0]->data;
|
---|
173 | const GLfloat s0 = texCoord[v0][0] * invW0;
|
---|
174 | const GLfloat s1 = texCoord[v1][0] * invW1;
|
---|
175 | const GLfloat s2 = texCoord[v2][0] * invW2;
|
---|
176 | const GLfloat t0 = (tSize > 1) ? texCoord[v0][1] * invW0 : 0.0F;
|
---|
177 | const GLfloat t1 = (tSize > 1) ? texCoord[v1][1] * invW1 : 0.0F;
|
---|
178 | const GLfloat t2 = (tSize > 1) ? texCoord[v2][1] * invW2 : 0.0F;
|
---|
179 | const GLfloat r0 = (tSize > 2) ? texCoord[v0][2] * invW0 : 0.0F;
|
---|
180 | const GLfloat r1 = (tSize > 2) ? texCoord[v1][2] * invW1 : 0.0F;
|
---|
181 | const GLfloat r2 = (tSize > 2) ? texCoord[v2][2] * invW2 : 0.0F;
|
---|
182 | const GLfloat q0 = (tSize > 3) ? texCoord[v0][3] * invW0 : invW0;
|
---|
183 | const GLfloat q1 = (tSize > 3) ? texCoord[v1][3] * invW1 : invW1;
|
---|
184 | const GLfloat q2 = (tSize > 3) ? texCoord[v2][3] * invW2 : invW2;
|
---|
185 | compute_plane(p0, p1, p2, s0, s1, s2, s0Plane);
|
---|
186 | compute_plane(p0, p1, p2, t0, t1, t2, t0Plane);
|
---|
187 | compute_plane(p0, p1, p2, r0, r1, r2, u0Plane);
|
---|
188 | compute_plane(p0, p1, p2, q0, q1, q2, v0Plane);
|
---|
189 | width0 = (GLfloat) texImage->Width;
|
---|
190 | height0 = (GLfloat) texImage->Height;
|
---|
191 | }
|
---|
192 | #endif
|
---|
193 | #ifdef DO_STUV1
|
---|
194 | {
|
---|
195 | const struct gl_texture_object *obj = ctx->Texture.Unit[1].Current;
|
---|
196 | const struct gl_texture_image *texImage = obj->Image[obj->BaseLevel];
|
---|
197 | const GLint tSize = VB->TexCoordPtr[1]->size;
|
---|
198 | const GLfloat invW0 = VB->Win.data[v0][3];
|
---|
199 | const GLfloat invW1 = VB->Win.data[v1][3];
|
---|
200 | const GLfloat invW2 = VB->Win.data[v2][3];
|
---|
201 | GLfloat (*texCoord)[4] = VB->TexCoordPtr[1]->data;
|
---|
202 | const GLfloat s0 = texCoord[v0][0] * invW0;
|
---|
203 | const GLfloat s1 = texCoord[v1][0] * invW1;
|
---|
204 | const GLfloat s2 = texCoord[v2][0] * invW2;
|
---|
205 | const GLfloat t0 = (tSize > 1) ? texCoord[v0][1] * invW0 : 0.0F;
|
---|
206 | const GLfloat t1 = (tSize > 1) ? texCoord[v1][1] * invW1 : 0.0F;
|
---|
207 | const GLfloat t2 = (tSize > 1) ? texCoord[v2][1] * invW2 : 0.0F;
|
---|
208 | const GLfloat r0 = (tSize > 2) ? texCoord[v0][2] * invW0 : 0.0F;
|
---|
209 | const GLfloat r1 = (tSize > 2) ? texCoord[v1][2] * invW1 : 0.0F;
|
---|
210 | const GLfloat r2 = (tSize > 2) ? texCoord[v2][2] * invW2 : 0.0F;
|
---|
211 | const GLfloat q0 = (tSize > 3) ? texCoord[v0][3] * invW0 : invW0;
|
---|
212 | const GLfloat q1 = (tSize > 3) ? texCoord[v1][3] * invW1 : invW1;
|
---|
213 | const GLfloat q2 = (tSize > 3) ? texCoord[v2][3] * invW2 : invW2;
|
---|
214 | compute_plane(p0, p1, p2, s0, s1, s2, s1Plane);
|
---|
215 | compute_plane(p0, p1, p2, t0, t1, t2, t1Plane);
|
---|
216 | compute_plane(p0, p1, p2, r0, r1, r2, u1Plane);
|
---|
217 | compute_plane(p0, p1, p2, q0, q1, q2, v1Plane);
|
---|
218 | width1 = (GLfloat) texImage->Width;
|
---|
219 | height1 = (GLfloat) texImage->Height;
|
---|
220 | }
|
---|
221 | #endif
|
---|
222 |
|
---|
223 | yMin = VB->Win.data[vMin][1];
|
---|
224 | yMax = VB->Win.data[vMax][1];
|
---|
225 | iyMin = (int) yMin;
|
---|
226 | iyMax = (int) yMax + 1;
|
---|
227 |
|
---|
228 | if (ltor) {
|
---|
229 | /* scan left to right */
|
---|
230 | const float *pMin = VB->Win.data[vMin];
|
---|
231 | const float *pMid = VB->Win.data[vMid];
|
---|
232 | const float *pMax = VB->Win.data[vMax];
|
---|
233 | const float dxdy = majDx / majDy;
|
---|
234 | const float xAdj = dxdy < 0.0F ? -dxdy : 0.0F;
|
---|
235 | float x = VB->Win.data[vMin][0] - (yMin - iyMin) * dxdy;
|
---|
236 | int iy;
|
---|
237 | for (iy = iyMin; iy < iyMax; iy++, x += dxdy) {
|
---|
238 | GLint ix, startX = (GLint) (x - xAdj);
|
---|
239 | GLuint count, n;
|
---|
240 | GLfloat coverage;
|
---|
241 | /* skip over fragments with zero coverage */
|
---|
242 | while (startX < MAX_WIDTH) {
|
---|
243 | coverage = compute_coveragef(pMin, pMid, pMax, startX, iy);
|
---|
244 | if (coverage > 0.0F)
|
---|
245 | break;
|
---|
246 | startX++;
|
---|
247 | }
|
---|
248 |
|
---|
249 | /* enter interior of triangle */
|
---|
250 | ix = startX;
|
---|
251 | count = 0;
|
---|
252 | while (coverage > 0.0F) {
|
---|
253 | #ifdef DO_Z
|
---|
254 | z[count] = (GLdepth) solve_plane(ix, iy, zPlane);
|
---|
255 | #endif
|
---|
256 | #ifdef DO_RGBA
|
---|
257 | rgba[count][RCOMP] = solve_plane_0_255(ix, iy, rPlane);
|
---|
258 | rgba[count][GCOMP] = solve_plane_0_255(ix, iy, gPlane);
|
---|
259 | rgba[count][BCOMP] = solve_plane_0_255(ix, iy, bPlane);
|
---|
260 | rgba[count][ACOMP] = (GLubyte) (solve_plane_0_255(ix, iy, aPlane) * coverage);
|
---|
261 | #endif
|
---|
262 | #ifdef DO_INDEX
|
---|
263 | {
|
---|
264 | GLint frac = compute_coveragei(pMin, pMid, pMax, ix, iy);
|
---|
265 | GLint indx = (GLint) solve_plane(ix, iy, iPlane);
|
---|
266 | index[count] = (indx & ~0xf) | frac;
|
---|
267 | }
|
---|
268 | #endif
|
---|
269 | #ifdef DO_SPEC
|
---|
270 | spec[count][RCOMP] = solve_plane_0_255(ix, iy, srPlane);
|
---|
271 | spec[count][GCOMP] = solve_plane_0_255(ix, iy, sgPlane);
|
---|
272 | spec[count][BCOMP] = solve_plane_0_255(ix, iy, sbPlane);
|
---|
273 | #endif
|
---|
274 | #ifdef DO_STUV0
|
---|
275 | {
|
---|
276 | GLfloat invQ = solve_plane_recip(ix, iy, v0Plane);
|
---|
277 | s[0][count] = solve_plane(ix, iy, s0Plane) * invQ;
|
---|
278 | t[0][count] = solve_plane(ix, iy, t0Plane) * invQ;
|
---|
279 | u[0][count] = solve_plane(ix, iy, u0Plane) * invQ;
|
---|
280 | lambda[0][count] = compute_lambda(s0Plane, t0Plane, invQ,
|
---|
281 | width0, height0);
|
---|
282 | }
|
---|
283 | #endif
|
---|
284 | #ifdef DO_STUV1
|
---|
285 | {
|
---|
286 | GLfloat invQ = solve_plane_recip(ix, iy, v1Plane);
|
---|
287 | s[1][count] = solve_plane(ix, iy, s1Plane) * invQ;
|
---|
288 | t[1][count] = solve_plane(ix, iy, t1Plane) * invQ;
|
---|
289 | u[1][count] = solve_plane(ix, iy, u1Plane) * invQ;
|
---|
290 | lambda[1][count] = compute_lambda(s1Plane, t1Plane, invQ,
|
---|
291 | width1, height1);
|
---|
292 | }
|
---|
293 | #endif
|
---|
294 | ix++;
|
---|
295 | count++;
|
---|
296 | coverage = compute_coveragef(pMin, pMid, pMax, ix, iy);
|
---|
297 | }
|
---|
298 |
|
---|
299 | n = (GLuint) ix - (GLuint) startX;
|
---|
300 | #ifdef DO_STUV1
|
---|
301 | # ifdef DO_SPEC
|
---|
302 | gl_write_multitexture_span(ctx, 2, n, startX, iy, z,
|
---|
303 | (const GLfloat (*)[MAX_WIDTH]) s,
|
---|
304 | (const GLfloat (*)[MAX_WIDTH]) t,
|
---|
305 | (const GLfloat (*)[MAX_WIDTH]) u,
|
---|
306 | (GLfloat (*)[MAX_WIDTH]) lambda,
|
---|
307 | rgba, (const GLubyte (*)[4]) spec,
|
---|
308 | GL_POLYGON);
|
---|
309 | # else
|
---|
310 | gl_write_multitexture_span(ctx, 2, n, startX, iy, z,
|
---|
311 | (const GLfloat (*)[MAX_WIDTH]) s,
|
---|
312 | (const GLfloat (*)[MAX_WIDTH]) t,
|
---|
313 | (const GLfloat (*)[MAX_WIDTH]) u,
|
---|
314 | lambda, rgba, NULL, GL_POLYGON);
|
---|
315 | # endif
|
---|
316 | #elif defined(DO_STUV0)
|
---|
317 | # ifdef DO_SPEC
|
---|
318 | gl_write_texture_span(ctx, n, startX, iy, z,
|
---|
319 | s[0], t[0], u[0], lambda[0], rgba,
|
---|
320 | (const GLubyte (*)[4]) spec, GL_POLYGON);
|
---|
321 | # else
|
---|
322 | gl_write_texture_span(ctx, n, startX, iy, z,
|
---|
323 | s[0], t[0], u[0], lambda[0],
|
---|
324 | rgba, NULL, GL_POLYGON);
|
---|
325 | # endif
|
---|
326 | #elif defined(DO_RGBA)
|
---|
327 | gl_write_rgba_span(ctx, n, startX, iy, z, rgba, GL_POLYGON);
|
---|
328 | #elif defined(DO_INDEX)
|
---|
329 | gl_write_index_span(ctx, n, startX, iy, z, index, GL_POLYGON);
|
---|
330 | #endif
|
---|
331 | }
|
---|
332 | }
|
---|
333 | else {
|
---|
334 | /* scan right to left */
|
---|
335 | const GLfloat *pMin = VB->Win.data[vMin];
|
---|
336 | const GLfloat *pMid = VB->Win.data[vMid];
|
---|
337 | const GLfloat *pMax = VB->Win.data[vMax];
|
---|
338 | const GLfloat dxdy = majDx / majDy;
|
---|
339 | const GLfloat xAdj = dxdy > 0 ? dxdy : 0.0F;
|
---|
340 | GLfloat x = VB->Win.data[vMin][0] - (yMin - iyMin) * dxdy;
|
---|
341 | GLint iy;
|
---|
342 | for (iy = iyMin; iy < iyMax; iy++, x += dxdy) {
|
---|
343 | GLint ix, left, startX = (GLint) (x + xAdj);
|
---|
344 | GLuint count, n;
|
---|
345 | GLfloat coverage;
|
---|
346 | /* skip fragments with zero coverage */
|
---|
347 | while (startX >= 0) {
|
---|
348 | coverage = compute_coveragef(pMin, pMax, pMid, startX, iy);
|
---|
349 | if (coverage > 0.0F)
|
---|
350 | break;
|
---|
351 | startX--;
|
---|
352 | }
|
---|
353 |
|
---|
354 | /* enter interior of triangle */
|
---|
355 | ix = startX;
|
---|
356 | count = 0;
|
---|
357 | while (coverage > 0.0F) {
|
---|
358 | #ifdef DO_Z
|
---|
359 | z[ix] = (GLdepth) solve_plane(ix, iy, zPlane);
|
---|
360 | #endif
|
---|
361 | #ifdef DO_RGBA
|
---|
362 | rgba[ix][RCOMP] = solve_plane_0_255(ix, iy, rPlane);
|
---|
363 | rgba[ix][GCOMP] = solve_plane_0_255(ix, iy, gPlane);
|
---|
364 | rgba[ix][BCOMP] = solve_plane_0_255(ix, iy, bPlane);
|
---|
365 | rgba[ix][ACOMP] = (GLubyte) (solve_plane_0_255(ix, iy, aPlane) * coverage);
|
---|
366 | #endif
|
---|
367 | #ifdef DO_INDEX
|
---|
368 | {
|
---|
369 | GLint frac = compute_coveragei(pMin, pMax, pMid, ix, iy);
|
---|
370 | GLint indx = (GLint) solve_plane(ix, iy, iPlane);
|
---|
371 | index[ix] = (indx & ~0xf) | frac;
|
---|
372 | }
|
---|
373 | #endif
|
---|
374 | #ifdef DO_SPEC
|
---|
375 | spec[ix][RCOMP] = solve_plane_0_255(ix, iy, srPlane);
|
---|
376 | spec[ix][GCOMP] = solve_plane_0_255(ix, iy, sgPlane);
|
---|
377 | spec[ix][BCOMP] = solve_plane_0_255(ix, iy, sbPlane);
|
---|
378 | #endif
|
---|
379 | #ifdef DO_STUV0
|
---|
380 | {
|
---|
381 | GLfloat invQ = solve_plane_recip(ix, iy, v0Plane);
|
---|
382 | s[0][ix] = solve_plane(ix, iy, s0Plane) * invQ;
|
---|
383 | t[0][ix] = solve_plane(ix, iy, t0Plane) * invQ;
|
---|
384 | u[0][ix] = solve_plane(ix, iy, u0Plane) * invQ;
|
---|
385 | lambda[0][ix] = compute_lambda(s0Plane, t0Plane, invQ,
|
---|
386 | width0, height0);
|
---|
387 | }
|
---|
388 | #endif
|
---|
389 | #ifdef DO_STUV1
|
---|
390 | {
|
---|
391 | GLfloat invQ = solve_plane_recip(ix, iy, v1Plane);
|
---|
392 | s[1][ix] = solve_plane(ix, iy, s1Plane) * invQ;
|
---|
393 | t[1][ix] = solve_plane(ix, iy, t1Plane) * invQ;
|
---|
394 | u[1][ix] = solve_plane(ix, iy, u1Plane) * invQ;
|
---|
395 | lambda[1][ix] = compute_lambda(s1Plane, t1Plane, invQ,
|
---|
396 | width1, height1);
|
---|
397 | }
|
---|
398 | #endif
|
---|
399 | ix--;
|
---|
400 | count++;
|
---|
401 | coverage = compute_coveragef(pMin, pMax, pMid, ix, iy);
|
---|
402 | }
|
---|
403 |
|
---|
404 | n = (GLuint) startX - (GLuint) ix;
|
---|
405 | left = ix + 1;
|
---|
406 | #ifdef DO_STUV1
|
---|
407 | {
|
---|
408 | int j;
|
---|
409 | for (j = 0; j < n; j++) {
|
---|
410 | s[0][j] = s[0][j + left];
|
---|
411 | t[0][j] = t[0][j + left];
|
---|
412 | u[0][j] = u[0][j + left];
|
---|
413 | s[1][j] = s[1][j + left];
|
---|
414 | t[1][j] = t[1][j + left];
|
---|
415 | u[1][j] = u[1][j + left];
|
---|
416 | lambda[0][j] = lambda[0][j + left];
|
---|
417 | lambda[1][j] = lambda[1][j + left];
|
---|
418 | }
|
---|
419 | }
|
---|
420 | # ifdef DO_SPEC
|
---|
421 | gl_write_multitexture_span(ctx, 2, n, left, iy, z + left,
|
---|
422 | (const GLfloat (*)[MAX_WIDTH]) s,
|
---|
423 | (const GLfloat (*)[MAX_WIDTH]) t,
|
---|
424 | (const GLfloat (*)[MAX_WIDTH]) u,
|
---|
425 | lambda, rgba + left,
|
---|
426 | (const GLubyte (*)[4]) (spec + left),
|
---|
427 | GL_POLYGON);
|
---|
428 | # else
|
---|
429 | gl_write_multitexture_span(ctx, 2, n, left, iy, z + left,
|
---|
430 | (const GLfloat (*)[MAX_WIDTH]) s,
|
---|
431 | (const GLfloat (*)[MAX_WIDTH]) t,
|
---|
432 | (const GLfloat (*)[MAX_WIDTH]) u,
|
---|
433 | lambda,
|
---|
434 | rgba + left, NULL, GL_POLYGON);
|
---|
435 | # endif
|
---|
436 | #elif defined(DO_STUV0)
|
---|
437 | # ifdef DO_SPEC
|
---|
438 | gl_write_texture_span(ctx, n, left, iy, z + left,
|
---|
439 | s[0] + left, t[0] + left, u[0] + left,
|
---|
440 | lambda[0] + left, rgba + left,
|
---|
441 | (const GLubyte (*)[4]) (spec + left),
|
---|
442 | GL_POLYGON);
|
---|
443 | # else
|
---|
444 | gl_write_texture_span(ctx, n, left, iy, z + left,
|
---|
445 | s[0] + left, t[0] + left,
|
---|
446 | u[0] + left, lambda[0] + left,
|
---|
447 | rgba + left, NULL, GL_POLYGON);
|
---|
448 | # endif
|
---|
449 | #elif defined(DO_RGBA)
|
---|
450 | gl_write_rgba_span(ctx, n, left, iy, z + left,
|
---|
451 | rgba + left, GL_POLYGON);
|
---|
452 | #elif defined(DO_INDEX)
|
---|
453 | gl_write_index_span(ctx, n, left, iy, z + left,
|
---|
454 | index + left, GL_POLYGON);
|
---|
455 | #endif
|
---|
456 | }
|
---|
457 | }
|
---|
458 | }
|
---|
459 |
|
---|
460 |
|
---|
461 | #ifdef DO_Z
|
---|
462 | #undef DO_Z
|
---|
463 | #endif
|
---|
464 |
|
---|
465 | #ifdef DO_RGBA
|
---|
466 | #undef DO_RGBA
|
---|
467 | #endif
|
---|
468 |
|
---|
469 | #ifdef DO_INDEX
|
---|
470 | #undef DO_INDEX
|
---|
471 | #endif
|
---|
472 |
|
---|
473 | #ifdef DO_SPEC
|
---|
474 | #undef DO_SPEC
|
---|
475 | #endif
|
---|
476 |
|
---|
477 | #ifdef DO_STUV0
|
---|
478 | #undef DO_STUV0
|
---|
479 | #endif
|
---|
480 |
|
---|
481 | #ifdef DO_STUV1
|
---|
482 | #undef DO_STUV1
|
---|
483 | #endif
|
---|