1 | /* $Id: dlm_bbox.c 54905 2015-03-23 11:20:58Z vboxsync $ */
|
---|
2 | /**
|
---|
3 | * Code to compute the bounding box of a DLM display list.
|
---|
4 | * Matrix commands in the display list are observed to properly
|
---|
5 | * transform the vertices we find.
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include <float.h>
|
---|
9 | #include "cr_dlm.h"
|
---|
10 | #include "cr_mem.h"
|
---|
11 | #include "cr_spu.h"
|
---|
12 | #include "cr_glstate.h"
|
---|
13 | #include "dlm.h"
|
---|
14 |
|
---|
15 |
|
---|
16 | static CRMatrixStack ModelViewStack;
|
---|
17 | static CRMatrixStack DummyStack;
|
---|
18 | static CRMatrixStack *CurrentStack;
|
---|
19 |
|
---|
20 |
|
---|
21 | static GLfloat Xmin, Xmax, Ymin, Ymax, Zmin, Zmax;
|
---|
22 |
|
---|
23 |
|
---|
24 | static void
|
---|
25 | MatrixMode(GLenum matrix)
|
---|
26 | {
|
---|
27 | switch (matrix) {
|
---|
28 | case GL_MODELVIEW:
|
---|
29 | CurrentStack = &ModelViewStack;
|
---|
30 | break;
|
---|
31 | default:
|
---|
32 | CurrentStack = &DummyStack;
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 |
|
---|
37 | static void
|
---|
38 | LoadMatrixf(const GLfloat m[16])
|
---|
39 | {
|
---|
40 | crMatrixInitFromFloats(CurrentStack->top, m);
|
---|
41 | }
|
---|
42 |
|
---|
43 |
|
---|
44 | static void
|
---|
45 | LoadMatrixd(const GLdouble m[16])
|
---|
46 | {
|
---|
47 | crMatrixInitFromDoubles(CurrentStack->top, m);
|
---|
48 | }
|
---|
49 |
|
---|
50 |
|
---|
51 | static void
|
---|
52 | LoadIdentity(void)
|
---|
53 | {
|
---|
54 | crMatrixInit(CurrentStack->top);
|
---|
55 | }
|
---|
56 |
|
---|
57 |
|
---|
58 | static void
|
---|
59 | PushMatrix(void)
|
---|
60 | {
|
---|
61 | if (CurrentStack->depth < CurrentStack->maxDepth) {
|
---|
62 | /* copy matrix */
|
---|
63 | *(CurrentStack->top + 1) = *(CurrentStack->top);
|
---|
64 | /* Move the stack pointer */
|
---|
65 | CurrentStack->depth++;
|
---|
66 | CurrentStack->top = CurrentStack->stack + CurrentStack->depth;
|
---|
67 | }
|
---|
68 | else {
|
---|
69 | crWarning("Stack overflow in dlm_bbox.c");
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | static void
|
---|
75 | PopMatrix(void)
|
---|
76 | {
|
---|
77 | if (CurrentStack->depth > 0) {
|
---|
78 | CurrentStack->depth--;
|
---|
79 | CurrentStack->top = CurrentStack->stack + CurrentStack->depth;
|
---|
80 | }
|
---|
81 | else {
|
---|
82 | crWarning("Stack underflow in dlm_bbox.c");
|
---|
83 | }
|
---|
84 | }
|
---|
85 |
|
---|
86 |
|
---|
87 | static void
|
---|
88 | MultMatrixf(const GLfloat m1[16])
|
---|
89 | {
|
---|
90 | CRmatrix *m = CurrentStack->top;
|
---|
91 | const GLdefault lm00 = m->m00;
|
---|
92 | const GLdefault lm01 = m->m01;
|
---|
93 | const GLdefault lm02 = m->m02;
|
---|
94 | const GLdefault lm03 = m->m03;
|
---|
95 | const GLdefault lm10 = m->m10;
|
---|
96 | const GLdefault lm11 = m->m11;
|
---|
97 | const GLdefault lm12 = m->m12;
|
---|
98 | const GLdefault lm13 = m->m13;
|
---|
99 | const GLdefault lm20 = m->m20;
|
---|
100 | const GLdefault lm21 = m->m21;
|
---|
101 | const GLdefault lm22 = m->m22;
|
---|
102 | const GLdefault lm23 = m->m23;
|
---|
103 | const GLdefault lm30 = m->m30;
|
---|
104 | const GLdefault lm31 = m->m31;
|
---|
105 | const GLdefault lm32 = m->m32;
|
---|
106 | const GLdefault lm33 = m->m33;
|
---|
107 | const GLdefault rm00 = (GLdefault) m1[0];
|
---|
108 | const GLdefault rm01 = (GLdefault) m1[1];
|
---|
109 | const GLdefault rm02 = (GLdefault) m1[2];
|
---|
110 | const GLdefault rm03 = (GLdefault) m1[3];
|
---|
111 | const GLdefault rm10 = (GLdefault) m1[4];
|
---|
112 | const GLdefault rm11 = (GLdefault) m1[5];
|
---|
113 | const GLdefault rm12 = (GLdefault) m1[6];
|
---|
114 | const GLdefault rm13 = (GLdefault) m1[7];
|
---|
115 | const GLdefault rm20 = (GLdefault) m1[8];
|
---|
116 | const GLdefault rm21 = (GLdefault) m1[9];
|
---|
117 | const GLdefault rm22 = (GLdefault) m1[10];
|
---|
118 | const GLdefault rm23 = (GLdefault) m1[11];
|
---|
119 | const GLdefault rm30 = (GLdefault) m1[12];
|
---|
120 | const GLdefault rm31 = (GLdefault) m1[13];
|
---|
121 | const GLdefault rm32 = (GLdefault) m1[14];
|
---|
122 | const GLdefault rm33 = (GLdefault) m1[15];
|
---|
123 |
|
---|
124 | m->m00 = lm00*rm00 + lm10*rm01 + lm20*rm02 + lm30*rm03;
|
---|
125 | m->m01 = lm01*rm00 + lm11*rm01 + lm21*rm02 + lm31*rm03;
|
---|
126 | m->m02 = lm02*rm00 + lm12*rm01 + lm22*rm02 + lm32*rm03;
|
---|
127 | m->m03 = lm03*rm00 + lm13*rm01 + lm23*rm02 + lm33*rm03;
|
---|
128 | m->m10 = lm00*rm10 + lm10*rm11 + lm20*rm12 + lm30*rm13;
|
---|
129 | m->m11 = lm01*rm10 + lm11*rm11 + lm21*rm12 + lm31*rm13;
|
---|
130 | m->m12 = lm02*rm10 + lm12*rm11 + lm22*rm12 + lm32*rm13;
|
---|
131 | m->m13 = lm03*rm10 + lm13*rm11 + lm23*rm12 + lm33*rm13;
|
---|
132 | m->m20 = lm00*rm20 + lm10*rm21 + lm20*rm22 + lm30*rm23;
|
---|
133 | m->m21 = lm01*rm20 + lm11*rm21 + lm21*rm22 + lm31*rm23;
|
---|
134 | m->m22 = lm02*rm20 + lm12*rm21 + lm22*rm22 + lm32*rm23;
|
---|
135 | m->m23 = lm03*rm20 + lm13*rm21 + lm23*rm22 + lm33*rm23;
|
---|
136 | m->m30 = lm00*rm30 + lm10*rm31 + lm20*rm32 + lm30*rm33;
|
---|
137 | m->m31 = lm01*rm30 + lm11*rm31 + lm21*rm32 + lm31*rm33;
|
---|
138 | m->m32 = lm02*rm30 + lm12*rm31 + lm22*rm32 + lm32*rm33;
|
---|
139 | m->m33 = lm03*rm30 + lm13*rm31 + lm23*rm32 + lm33*rm33;
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | static void
|
---|
144 | MultMatrixd(const GLdouble m1[16])
|
---|
145 | {
|
---|
146 | GLfloat m2[16];
|
---|
147 | int i;
|
---|
148 | for (i = 0; i < 16; i++)
|
---|
149 | m2[i] = (GLfloat) m1[i];
|
---|
150 | MultMatrixf(m2);
|
---|
151 | }
|
---|
152 |
|
---|
153 |
|
---|
154 | static void
|
---|
155 | Rotatef(GLfloat ang, GLfloat x, GLfloat y, GLfloat z)
|
---|
156 | {
|
---|
157 | crMatrixRotate(CurrentStack->top, ang, x, y, z);
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 | static void
|
---|
162 | Rotated(GLdouble ang, GLdouble x, GLdouble y, GLdouble z)
|
---|
163 | {
|
---|
164 | crMatrixRotate(CurrentStack->top, (GLfloat) ang,
|
---|
165 | (GLfloat) x, (GLfloat) y, (GLfloat) z);
|
---|
166 | }
|
---|
167 |
|
---|
168 |
|
---|
169 | static void
|
---|
170 | Translatef(GLfloat x, GLfloat y, GLfloat z)
|
---|
171 | {
|
---|
172 | crMatrixTranslate(CurrentStack->top, x, y, z);
|
---|
173 | }
|
---|
174 |
|
---|
175 |
|
---|
176 | static void
|
---|
177 | Translated(GLdouble x, GLdouble y, GLdouble z)
|
---|
178 | {
|
---|
179 | crMatrixTranslate(CurrentStack->top, (GLfloat) x, (GLfloat) y, (GLfloat) z);
|
---|
180 | }
|
---|
181 |
|
---|
182 |
|
---|
183 | static void
|
---|
184 | Scalef(GLfloat x, GLfloat y, GLfloat z)
|
---|
185 | {
|
---|
186 | crMatrixScale(CurrentStack->top, x, y, z);
|
---|
187 | }
|
---|
188 |
|
---|
189 |
|
---|
190 | static void
|
---|
191 | Scaled(GLdouble x, GLdouble y, GLdouble z)
|
---|
192 | {
|
---|
193 | crMatrixScale(CurrentStack->top, (GLfloat) x, (GLfloat) y, (GLfloat) z);
|
---|
194 | }
|
---|
195 |
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * Transform given (x,y,z,w) by current matrix and update the bounding box.
|
---|
199 | */
|
---|
200 | static void
|
---|
201 | DoVertex(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
|
---|
202 | {
|
---|
203 | const CRmatrix *m = CurrentStack->top;
|
---|
204 | const GLfloat x2 = m->m00 * x + m->m10 * y + m->m20 * z + m->m30 * w;
|
---|
205 | const GLfloat y2 = m->m01 * x + m->m11 * y + m->m21 * z + m->m31 * w;
|
---|
206 | const GLfloat z2 = m->m02 * x + m->m12 * y + m->m22 * z + m->m32 * w;
|
---|
207 | /*const GLfloat w2 = m->m03 * x + m->m13 * y + m->m23 * z + m->m33 * w;*/
|
---|
208 |
|
---|
209 | if (x2 < Xmin) Xmin = x2;
|
---|
210 | if (x2 > Xmax) Xmax = x2;
|
---|
211 | if (y2 < Ymin) Ymin = y2;
|
---|
212 | if (y2 > Ymax) Ymax = y2;
|
---|
213 | if (z2 < Zmin) Zmin = z2;
|
---|
214 | if (z2 > Zmax) Zmax = z2;
|
---|
215 | }
|
---|
216 |
|
---|
217 |
|
---|
218 | static void
|
---|
219 | Vertex2f(GLfloat x, GLfloat y)
|
---|
220 | {
|
---|
221 | DoVertex(x, y, 0.0f, 1.0f);
|
---|
222 | }
|
---|
223 |
|
---|
224 | static void
|
---|
225 | Vertex2fv(const GLfloat *v)
|
---|
226 | {
|
---|
227 | DoVertex(v[0], v[1], 0.0f, 1.0f);
|
---|
228 | }
|
---|
229 |
|
---|
230 | static void
|
---|
231 | Vertex3f(GLfloat x, GLfloat y, GLfloat z)
|
---|
232 | {
|
---|
233 | DoVertex(x, y, z, 1.0f);
|
---|
234 | }
|
---|
235 |
|
---|
236 | static void
|
---|
237 | Vertex3fv(const GLfloat *v)
|
---|
238 | {
|
---|
239 | DoVertex(v[0], v[1], v[2], 1.0f);
|
---|
240 | }
|
---|
241 |
|
---|
242 | static void
|
---|
243 | Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
|
---|
244 | {
|
---|
245 | DoVertex(x, y, z, w);
|
---|
246 | }
|
---|
247 |
|
---|
248 | static void
|
---|
249 | Vertex4fv(const GLfloat *v)
|
---|
250 | {
|
---|
251 | DoVertex(v[0], v[1], v[2], v[3]);
|
---|
252 | }
|
---|
253 |
|
---|
254 |
|
---|
255 | /**
|
---|
256 | ** XXX TO DO:
|
---|
257 | **
|
---|
258 | glVertex2d( GLdouble x, GLdouble y );
|
---|
259 | glVertex2f( GLfloat x, GLfloat y );
|
---|
260 | glVertex2i( GLint x, GLint y );
|
---|
261 | glVertex2s( GLshort x, GLshort y );
|
---|
262 | glVertex3d( GLdouble x, GLdouble y, GLdouble z );
|
---|
263 | glVertex3f( GLfloat x, GLfloat y, GLfloat z );
|
---|
264 | glVertex3i( GLint x, GLint y, GLint z );
|
---|
265 | glVertex3s( GLshort x, GLshort y, GLshort z );
|
---|
266 | glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w );
|
---|
267 | glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
|
---|
268 | glVertex4i( GLint x, GLint y, GLint z, GLint w );
|
---|
269 | glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w );
|
---|
270 | glVertex2dv( const GLdouble *v );
|
---|
271 | glVertex2fv( const GLfloat *v );
|
---|
272 | glVertex2iv( const GLint *v );
|
---|
273 | glVertex2sv( const GLshort *v );
|
---|
274 | glVertex3dv( const GLdouble *v );
|
---|
275 | glVertex3fv( const GLfloat *v );
|
---|
276 | glVertex3iv( const GLint *v );
|
---|
277 | glVertex3sv( const GLshort *v );
|
---|
278 | glVertex4dv( const GLdouble *v );
|
---|
279 | glVertex4fv( const GLfloat *v );
|
---|
280 | glVertex4iv( const GLint *v );
|
---|
281 | glVertex4sv( const GLshort *v );
|
---|
282 |
|
---|
283 | glVertexAttrib1dARB(GLuint, GLdouble);
|
---|
284 | glVertexAttrib1dvARB(GLuint, const GLdouble *);
|
---|
285 | glVertexAttrib1fARB(GLuint, GLfloat);
|
---|
286 | glVertexAttrib1fvARB(GLuint, const GLfloat *);
|
---|
287 | glVertexAttrib1sARB(GLuint, GLshort);
|
---|
288 | glVertexAttrib1svARB(GLuint, const GLshort *);
|
---|
289 | glVertexAttrib2dARB(GLuint, GLdouble, GLdouble);
|
---|
290 | glVertexAttrib2dvARB(GLuint, const GLdouble *);
|
---|
291 | glVertexAttrib2fARB(GLuint, GLfloat, GLfloat);
|
---|
292 | glVertexAttrib2fvARB(GLuint, const GLfloat *);
|
---|
293 | glVertexAttrib2sARB(GLuint, GLshort, GLshort);
|
---|
294 | glVertexAttrib2svARB(GLuint, const GLshort *);
|
---|
295 | glVertexAttrib3dARB(GLuint, GLdouble, GLdouble, GLdouble);
|
---|
296 | glVertexAttrib3dvARB(GLuint, const GLdouble *);
|
---|
297 | **/
|
---|
298 |
|
---|
299 | static void
|
---|
300 | VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z)
|
---|
301 | {
|
---|
302 | if (index == 0)
|
---|
303 | DoVertex(x, y, z, 1.0f);
|
---|
304 | }
|
---|
305 |
|
---|
306 | /**
|
---|
307 | glVertexAttrib3fvARB(GLuint, const GLfloat *);
|
---|
308 | glVertexAttrib3sARB(GLuint, GLshort, GLshort, GLshort);
|
---|
309 | glVertexAttrib3svARB(GLuint, const GLshort *);
|
---|
310 | glVertexAttrib4NbvARB(GLuint, const GLbyte *);
|
---|
311 | glVertexAttrib4NivARB(GLuint, const GLint *);
|
---|
312 | glVertexAttrib4NsvARB(GLuint, const GLshort *);
|
---|
313 | glVertexAttrib4NubARB(GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
|
---|
314 | glVertexAttrib4NubvARB(GLuint, const GLubyte *);
|
---|
315 | glVertexAttrib4NuivARB(GLuint, const GLuint *);
|
---|
316 | glVertexAttrib4NusvARB(GLuint, const GLushort *);
|
---|
317 | glVertexAttrib4bvARB(GLuint, const GLbyte *);
|
---|
318 | glVertexAttrib4dARB(GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
|
---|
319 | glVertexAttrib4dvARB(GLuint, const GLdouble *);
|
---|
320 | glVertexAttrib4fARB(GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
|
---|
321 | glVertexAttrib4fvARB(GLuint, const GLfloat *);
|
---|
322 | glVertexAttrib4ivARB(GLuint, const GLint *);
|
---|
323 | glVertexAttrib4sARB(GLuint, GLshort, GLshort, GLshort, GLshort);
|
---|
324 | glVertexAttrib4svARB(GLuint, const GLshort *);
|
---|
325 | glVertexAttrib4ubvARB(GLuint, const GLubyte *);
|
---|
326 | glVertexAttrib4uivARB(GLuint, const GLuint *);
|
---|
327 | glVertexAttrib4usvARB(GLuint, const GLushort *);
|
---|
328 |
|
---|
329 | glVertexAttrib1dNV(GLuint, GLdouble);
|
---|
330 | glVertexAttrib1dvNV(GLuint, const GLdouble *);
|
---|
331 | glVertexAttrib1fNV(GLuint, GLfloat);
|
---|
332 | glVertexAttrib1fvNV(GLuint, const GLfloat *);
|
---|
333 | glVertexAttrib1sNV(GLuint, GLshort);
|
---|
334 | glVertexAttrib1svNV(GLuint, const GLshort *);
|
---|
335 | glVertexAttrib2dNV(GLuint, GLdouble, GLdouble);
|
---|
336 | glVertexAttrib2dvNV(GLuint, const GLdouble *);
|
---|
337 | glVertexAttrib2fNV(GLuint, GLfloat, GLfloat);
|
---|
338 | glVertexAttrib2fvNV(GLuint, const GLfloat *);
|
---|
339 | glVertexAttrib2sNV(GLuint, GLshort, GLshort);
|
---|
340 | glVertexAttrib2svNV(GLuint, const GLshort *);
|
---|
341 | glVertexAttrib3dNV(GLuint, GLdouble, GLdouble, GLdouble);
|
---|
342 | glVertexAttrib3dvNV(GLuint, const GLdouble *);
|
---|
343 | glVertexAttrib3fNV(GLuint, GLfloat, GLfloat, GLfloat);
|
---|
344 | glVertexAttrib3fvNV(GLuint, const GLfloat *);
|
---|
345 | glVertexAttrib3sNV(GLuint, GLshort, GLshort, GLshort);
|
---|
346 | glVertexAttrib3svNV(GLuint, const GLshort *);
|
---|
347 | glVertexAttrib4dNV(GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
|
---|
348 | glVertexAttrib4dvNV(GLuint, const GLdouble *);
|
---|
349 | glVertexAttrib4fNV(GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
|
---|
350 | glVertexAttrib4fvNV(GLuint, const GLfloat *);
|
---|
351 | glVertexAttrib4sNV(GLuint, GLshort, GLshort, GLshort, GLshort);
|
---|
352 | glVertexAttrib4svNV(GLuint, const GLshort *);
|
---|
353 | glVertexAttrib4ubNV(GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
|
---|
354 | glVertexAttrib4ubvNV(GLuint, const GLubyte *);
|
---|
355 |
|
---|
356 | glVertexAttribs1dvNV(GLuint, GLsizei, const GLdouble *);
|
---|
357 | glVertexAttribs1fvNV(GLuint, GLsizei, const GLfloat *);
|
---|
358 | glVertexAttribs1svNV(GLuint, GLsizei, const GLshort *);
|
---|
359 | glVertexAttribs2dvNV(GLuint, GLsizei, const GLdouble *);
|
---|
360 | glVertexAttribs2fvNV(GLuint, GLsizei, const GLfloat *);
|
---|
361 | glVertexAttribs2svNV(GLuint, GLsizei, const GLshort *);
|
---|
362 | glVertexAttribs3dvNV(GLuint, GLsizei, const GLdouble *);
|
---|
363 | glVertexAttribs3fvNV(GLuint, GLsizei, const GLfloat *);
|
---|
364 | glVertexAttribs3svNV(GLuint, GLsizei, const GLshort *);
|
---|
365 | glVertexAttribs4dvNV(GLuint, GLsizei, const GLdouble *);
|
---|
366 | glVertexAttribs4fvNV(GLuint, GLsizei, const GLfloat *);
|
---|
367 | glVertexAttribs4svNV(GLuint, GLsizei, const GLshort *);
|
---|
368 | glVertexAttribs4ubvNV(GLuint, GLsizei, const GLubyte *);
|
---|
369 | **/
|
---|
370 |
|
---|
371 |
|
---|
372 | /**
|
---|
373 | ** XXX also need to track evaluator coordinates (glutTeapot)
|
---|
374 | **/
|
---|
375 |
|
---|
376 |
|
---|
377 | static void
|
---|
378 | InitDispatchTable(SPUDispatchTable *t)
|
---|
379 | {
|
---|
380 | crMemZero(t, sizeof(*t));
|
---|
381 | crSPUInitDispatchNops(t);
|
---|
382 | /* drm1 */
|
---|
383 | t->MatrixMode = (MatrixModeFunc_t)MatrixMode;
|
---|
384 | t->LoadIdentity = (LoadIdentityFunc_t)LoadIdentity;
|
---|
385 | t->LoadMatrixf = (LoadMatrixfFunc_t)LoadMatrixf;
|
---|
386 | t->LoadMatrixd = (LoadMatrixdFunc_t)LoadMatrixd;
|
---|
387 | t->PushMatrix = (PushMatrixFunc_t)PushMatrix;
|
---|
388 | t->PopMatrix = (PopMatrixFunc_t)PopMatrix;
|
---|
389 | t->MultMatrixf = (MultMatrixfFunc_t)MultMatrixf;
|
---|
390 | t->MultMatrixd = (MultMatrixdFunc_t)MultMatrixd;
|
---|
391 | t->Rotatef = (RotatefFunc_t)Rotatef;
|
---|
392 | t->Rotated = (RotatedFunc_t)Rotated;
|
---|
393 | t->Translatef = (TranslatefFunc_t)Translatef;
|
---|
394 | t->Translated = (TranslatedFunc_t)Translated;
|
---|
395 | t->Scalef = (ScalefFunc_t)Scalef;
|
---|
396 | t->Scaled = (ScaledFunc_t)Scaled;
|
---|
397 | t->Vertex2f = (Vertex2fFunc_t)Vertex2f;
|
---|
398 | t->Vertex2fv = (Vertex2fvFunc_t)Vertex2fv;
|
---|
399 | t->Vertex3f = (Vertex3fFunc_t)Vertex3f;
|
---|
400 | t->Vertex3fv = (Vertex3fvFunc_t)Vertex3fv;
|
---|
401 | t->Vertex4f = (Vertex4fFunc_t)Vertex4f;
|
---|
402 | t->Vertex4fv = (Vertex4fvFunc_t)Vertex4fv;
|
---|
403 | t->VertexAttrib3fARB = (VertexAttrib3fARBFunc_t)VertexAttrib3fARB;
|
---|
404 | }
|
---|
405 |
|
---|
406 |
|
---|
407 | void
|
---|
408 | crDLMComputeBoundingBox(unsigned long listId)
|
---|
409 | {
|
---|
410 | static GLboolean tableInitialized = GL_FALSE;
|
---|
411 | static SPUDispatchTable t;
|
---|
412 | CRDLMContextState *listState = CURRENT_STATE();
|
---|
413 | CRDLM *dlm = listState->dlm;
|
---|
414 | DLMListInfo *listInfo
|
---|
415 | = (DLMListInfo *) crHashtableSearch(dlm->displayLists, listId);
|
---|
416 |
|
---|
417 | if (!tableInitialized) {
|
---|
418 | InitDispatchTable(&t);
|
---|
419 | crStateInitMatrixStack(&ModelViewStack, CR_MAX_MODELVIEW_STACK_DEPTH);
|
---|
420 | crStateInitMatrixStack(&DummyStack, CR_MAX_MODELVIEW_STACK_DEPTH);
|
---|
421 | tableInitialized = GL_TRUE;
|
---|
422 | }
|
---|
423 |
|
---|
424 | CurrentStack = &ModelViewStack;
|
---|
425 |
|
---|
426 | Xmin = Ymin = Zmin = FLT_MAX;
|
---|
427 | Xmax = Ymax = Zmax = -FLT_MAX;
|
---|
428 |
|
---|
429 | crDLMReplayDLMList(listState->dlm, listId, &t);
|
---|
430 |
|
---|
431 | if (Xmin == FLT_MAX) {
|
---|
432 | /* XXX review this choice of default bounds */
|
---|
433 | /*
|
---|
434 | crDebug("Warning: no bounding box!");
|
---|
435 | */
|
---|
436 | Xmin = -100;
|
---|
437 | Xmax = 100;
|
---|
438 | Ymin = -100;
|
---|
439 | Ymax = 100;
|
---|
440 | Zmin = -100;
|
---|
441 | Zmax = 100;
|
---|
442 | }
|
---|
443 | /*
|
---|
444 | crDebug("List %d bbox: %f, %f, %f .. %f, %f, %f", (int) listId,
|
---|
445 | Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
|
---|
446 | */
|
---|
447 |
|
---|
448 | listInfo->bbox.xmin = Xmin;
|
---|
449 | listInfo->bbox.ymin = Ymin;
|
---|
450 | listInfo->bbox.zmin = Zmin;
|
---|
451 | listInfo->bbox.xmax = Xmax;
|
---|
452 | listInfo->bbox.ymax = Ymax;
|
---|
453 | listInfo->bbox.zmax = Zmax;
|
---|
454 | }
|
---|