1 /* $Id: m_xform_tmp.h,v 1.1 2000/11/16 21:05:41 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
28 * New (3.1) transformation code written by Keith Whitwell.
32 /*----------------------------------------------------------------------
33 * Begin Keith's new code
35 *----------------------------------------------------------------------
38 /* KW: Fixed stride, now measured in bytes as is the OpenGL array stride.
41 /* KW: These are now parameterized to produce two versions, one
42 * which transforms all incoming points, and a second which
43 * takes notice of a cullmask array, and only transforms
47 /* KW: 1-vectors can sneak into the texture pipeline via the array
48 * interface. These functions are here because I want consistant
49 * treatment of the vertex sizes and a lazy strategy for
50 * cleaning unused parts of the vector, and so as not to exclude
51 * them from the vertex array interface.
53 * Under our current analysis of matrices, there is no way that
54 * the product of a matrix and a 1-vector can remain a 1-vector,
55 * with the exception of the identity transform.
58 /* KW: No longer zero-pad outgoing vectors. Now that external
59 * vectors can get into the pipeline we cannot ever assume
60 * that there is more to a vector than indicated by its
64 /* KW: Now uses clipmask and a flag to allow us to skip both/either
65 * cliped and/or culled vertices.
69 TAG(transform_points1_general
)( GLvector4f
*to_vec
,
71 const GLvector4f
*from_vec
,
75 const GLuint stride
= from_vec
->stride
;
76 GLfloat
*from
= from_vec
->start
;
77 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
78 GLuint count
= from_vec
->count
;
79 const GLfloat m0
= m
[0], m12
= m
[12];
80 const GLfloat m1
= m
[1], m13
= m
[13];
81 const GLfloat m2
= m
[2], m14
= m
[14];
82 const GLfloat m3
= m
[3], m15
= m
[15];
88 const GLfloat ox
= from
[0];
89 to
[i
][0] = m0
* ox
+ m12
;
90 to
[i
][1] = m1
* ox
+ m13
;
91 to
[i
][2] = m2
* ox
+ m14
;
92 to
[i
][3] = m3
* ox
+ m15
;
97 to_vec
->flags
|= VEC_SIZE_4
;
98 to_vec
->count
= from_vec
->count
;
101 static void _XFORMAPI
102 TAG(transform_points1_identity
)( GLvector4f
*to_vec
,
104 const GLvector4f
*from_vec
,
108 const GLuint stride
= from_vec
->stride
;
109 GLfloat
*from
= from_vec
->start
;
110 GLuint count
= from_vec
->count
;
111 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
115 if (to_vec
== from_vec
) return;
123 to_vec
->flags
|= VEC_SIZE_1
;
124 to_vec
->count
= from_vec
->count
;
127 static void _XFORMAPI
128 TAG(transform_points1_2d
)( GLvector4f
*to_vec
,
130 const GLvector4f
*from_vec
,
134 const GLuint stride
= from_vec
->stride
;
135 GLfloat
*from
= from_vec
->start
;
136 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
137 GLuint count
= from_vec
->count
;
138 const GLfloat m0
= m
[0], m1
= m
[1];
139 const GLfloat m12
= m
[12], m13
= m
[13];
145 const GLfloat ox
= from
[0];
146 to
[i
][0] = m0
* ox
+ m12
;
147 to
[i
][1] = m1
* ox
+ m13
;
151 to_vec
->flags
|= VEC_SIZE_2
;
152 to_vec
->count
= from_vec
->count
;
155 static void _XFORMAPI
156 TAG(transform_points1_2d_no_rot
)( GLvector4f
*to_vec
,
158 const GLvector4f
*from_vec
,
162 const GLuint stride
= from_vec
->stride
;
163 GLfloat
*from
= from_vec
->start
;
164 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
165 GLuint count
= from_vec
->count
;
166 const GLfloat m0
= m
[0], m12
= m
[12], m13
= m
[13];
172 const GLfloat ox
= from
[0];
173 to
[i
][0] = m0
* ox
+ m12
;
179 to_vec
->flags
|= VEC_SIZE_2
;
180 to_vec
->count
= from_vec
->count
;
183 static void _XFORMAPI
184 TAG(transform_points1_3d
)( GLvector4f
*to_vec
,
186 const GLvector4f
*from_vec
,
190 const GLuint stride
= from_vec
->stride
;
191 GLfloat
*from
= from_vec
->start
;
192 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
193 GLuint count
= from_vec
->count
;
194 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2];
195 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
201 const GLfloat ox
= from
[0];
202 to
[i
][0] = m0
* ox
+ m12
;
203 to
[i
][1] = m1
* ox
+ m13
;
204 to
[i
][2] = m2
* ox
+ m14
;
208 to_vec
->flags
|= VEC_SIZE_3
;
209 to_vec
->count
= from_vec
->count
;
213 static void _XFORMAPI
214 TAG(transform_points1_3d_no_rot
)( GLvector4f
*to_vec
,
216 const GLvector4f
*from_vec
,
220 const GLuint stride
= from_vec
->stride
;
221 GLfloat
*from
= from_vec
->start
;
222 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
223 GLuint count
= from_vec
->count
;
224 const GLfloat m0
= m
[0];
225 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
231 const GLfloat ox
= from
[0];
232 to
[i
][0] = m0
* ox
+ m12
;
238 to_vec
->flags
|= VEC_SIZE_3
;
239 to_vec
->count
= from_vec
->count
;
242 static void _XFORMAPI
243 TAG(transform_points1_perspective
)( GLvector4f
*to_vec
,
245 const GLvector4f
*from_vec
,
249 const GLuint stride
= from_vec
->stride
;
250 GLfloat
*from
= from_vec
->start
;
251 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
252 GLuint count
= from_vec
->count
;
253 const GLfloat m0
= m
[0], m14
= m
[14];
259 const GLfloat ox
= from
[0];
267 to_vec
->flags
|= VEC_SIZE_4
;
268 to_vec
->count
= from_vec
->count
;
274 /* 2-vectors, which are a lot more relevant than 1-vectors, are
275 * present early in the geometry pipeline and throughout the
278 static void _XFORMAPI
279 TAG(transform_points2_general
)( GLvector4f
*to_vec
,
281 const GLvector4f
*from_vec
,
285 const GLuint stride
= from_vec
->stride
;
286 GLfloat
*from
= from_vec
->start
;
287 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
288 GLuint count
= from_vec
->count
;
289 const GLfloat m0
= m
[0], m4
= m
[4], m12
= m
[12];
290 const GLfloat m1
= m
[1], m5
= m
[5], m13
= m
[13];
291 const GLfloat m2
= m
[2], m6
= m
[6], m14
= m
[14];
292 const GLfloat m3
= m
[3], m7
= m
[7], m15
= m
[15];
298 const GLfloat ox
= from
[0], oy
= from
[1];
299 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
300 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
301 to
[i
][2] = m2
* ox
+ m6
* oy
+ m14
;
302 to
[i
][3] = m3
* ox
+ m7
* oy
+ m15
;
306 to_vec
->flags
|= VEC_SIZE_4
;
307 to_vec
->count
= from_vec
->count
;
310 static void _XFORMAPI
311 TAG(transform_points2_identity
)( GLvector4f
*to_vec
,
313 const GLvector4f
*from_vec
,
317 const GLuint stride
= from_vec
->stride
;
318 GLfloat
*from
= from_vec
->start
;
319 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
320 GLuint count
= from_vec
->count
;
324 if (to_vec
== from_vec
) return;
332 to_vec
->flags
|= VEC_SIZE_2
;
333 to_vec
->count
= from_vec
->count
;
336 static void _XFORMAPI
337 TAG(transform_points2_2d
)( GLvector4f
*to_vec
,
339 const GLvector4f
*from_vec
,
343 const GLuint stride
= from_vec
->stride
;
344 GLfloat
*from
= from_vec
->start
;
345 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
346 GLuint count
= from_vec
->count
;
347 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
348 const GLfloat m12
= m
[12], m13
= m
[13];
354 const GLfloat ox
= from
[0], oy
= from
[1];
355 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
356 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
361 to_vec
->flags
|= VEC_SIZE_2
;
362 to_vec
->count
= from_vec
->count
;
365 static void _XFORMAPI
366 TAG(transform_points2_2d_no_rot
)( GLvector4f
*to_vec
,
368 const GLvector4f
*from_vec
,
372 const GLuint stride
= from_vec
->stride
;
373 GLfloat
*from
= from_vec
->start
;
374 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
375 GLuint count
= from_vec
->count
;
376 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
382 const GLfloat ox
= from
[0], oy
= from
[1];
383 to
[i
][0] = m0
* ox
+ m12
;
384 to
[i
][1] = m5
* oy
+ m13
;
389 to_vec
->flags
|= VEC_SIZE_2
;
390 to_vec
->count
= from_vec
->count
;
393 static void _XFORMAPI
394 TAG(transform_points2_3d
)( GLvector4f
*to_vec
,
396 const GLvector4f
*from_vec
,
400 const GLuint stride
= from_vec
->stride
;
401 GLfloat
*from
= from_vec
->start
;
402 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
403 GLuint count
= from_vec
->count
;
404 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
405 const GLfloat m6
= m
[6], m12
= m
[12], m13
= m
[13], m14
= m
[14];
411 const GLfloat ox
= from
[0], oy
= from
[1];
412 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
413 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
414 to
[i
][2] = m2
* ox
+ m6
* oy
+ m14
;
418 to_vec
->flags
|= VEC_SIZE_3
;
419 to_vec
->count
= from_vec
->count
;
423 /* I would actually say this was a fairly important function, from
424 * a texture transformation point of view.
426 static void _XFORMAPI
427 TAG(transform_points2_3d_no_rot
)( GLvector4f
*to_vec
,
429 const GLvector4f
*from_vec
,
433 const GLuint stride
= from_vec
->stride
;
434 GLfloat
*from
= from_vec
->start
;
435 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
436 GLuint count
= from_vec
->count
;
437 const GLfloat m0
= m
[0], m5
= m
[5];
438 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
444 const GLfloat ox
= from
[0], oy
= from
[1];
445 to
[i
][0] = m0
* ox
+ m12
;
446 to
[i
][1] = m5
* oy
+ m13
;
452 to_vec
->flags
|= VEC_SIZE_2
;
455 to_vec
->flags
|= VEC_SIZE_3
;
457 to_vec
->count
= from_vec
->count
;
460 /* This may not be called too often, but I wouldn't say it was dead
461 * code. It's also hard to remove any of these functions if you are
462 * attached to the assertions that have appeared in them.
464 static void _XFORMAPI
465 TAG(transform_points2_perspective
)( GLvector4f
*to_vec
,
467 const GLvector4f
*from_vec
,
471 const GLuint stride
= from_vec
->stride
;
472 GLfloat
*from
= from_vec
->start
;
473 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
474 GLuint count
= from_vec
->count
;
475 const GLfloat m0
= m
[0], m5
= m
[5], m14
= m
[14];
481 const GLfloat ox
= from
[0], oy
= from
[1];
489 to_vec
->flags
|= VEC_SIZE_4
;
490 to_vec
->count
= from_vec
->count
;
495 static void _XFORMAPI
496 TAG(transform_points3_general
)( GLvector4f
*to_vec
,
498 const GLvector4f
*from_vec
,
502 const GLuint stride
= from_vec
->stride
;
503 GLfloat
*from
= from_vec
->start
;
504 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
505 GLuint count
= from_vec
->count
;
506 const GLfloat m0
= m
[0], m4
= m
[4], m8
= m
[8], m12
= m
[12];
507 const GLfloat m1
= m
[1], m5
= m
[5], m9
= m
[9], m13
= m
[13];
508 const GLfloat m2
= m
[2], m6
= m
[6], m10
= m
[10], m14
= m
[14];
509 const GLfloat m3
= m
[3], m7
= m
[7], m11
= m
[11], m15
= m
[15];
515 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
516 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
;
517 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
;
518 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
;
519 to
[i
][3] = m3
* ox
+ m7
* oy
+ m11
* oz
+ m15
;
523 to_vec
->flags
|= VEC_SIZE_4
;
524 to_vec
->count
= from_vec
->count
;
527 static void _XFORMAPI
528 TAG(transform_points3_identity
)( GLvector4f
*to_vec
,
530 const GLvector4f
*from_vec
,
534 const GLuint stride
= from_vec
->stride
;
535 GLfloat
*from
= from_vec
->start
;
536 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
537 GLuint count
= from_vec
->count
;
541 if (to_vec
== from_vec
) return;
550 to_vec
->flags
|= VEC_SIZE_3
;
551 to_vec
->count
= from_vec
->count
;
554 static void _XFORMAPI
555 TAG(transform_points3_2d
)( GLvector4f
*to_vec
,
557 const GLvector4f
*from_vec
,
561 const GLuint stride
= from_vec
->stride
;
562 GLfloat
*from
= from_vec
->start
;
563 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
564 GLuint count
= from_vec
->count
;
565 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
566 const GLfloat m12
= m
[12], m13
= m
[13];
572 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
573 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
574 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
579 to_vec
->flags
|= VEC_SIZE_3
;
580 to_vec
->count
= from_vec
->count
;
583 static void _XFORMAPI
584 TAG(transform_points3_2d_no_rot
)( GLvector4f
*to_vec
,
586 const GLvector4f
*from_vec
,
590 const GLuint stride
= from_vec
->stride
;
591 GLfloat
*from
= from_vec
->start
;
592 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
593 GLuint count
= from_vec
->count
;
594 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
600 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
601 to
[i
][0] = m0
* ox
+ m12
;
602 to
[i
][1] = m5
* oy
+ m13
;
607 to_vec
->flags
|= VEC_SIZE_3
;
608 to_vec
->count
= from_vec
->count
;
611 static void _XFORMAPI
612 TAG(transform_points3_3d
)( GLvector4f
*to_vec
,
614 const GLvector4f
*from_vec
,
618 const GLuint stride
= from_vec
->stride
;
619 GLfloat
*from
= from_vec
->start
;
620 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
621 GLuint count
= from_vec
->count
;
622 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
623 const GLfloat m6
= m
[6], m8
= m
[8], m9
= m
[9], m10
= m
[10];
624 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
630 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
631 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
;
632 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
;
633 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
;
637 to_vec
->flags
|= VEC_SIZE_3
;
638 to_vec
->count
= from_vec
->count
;
641 /* previously known as ortho...
643 static void _XFORMAPI
644 TAG(transform_points3_3d_no_rot
)( GLvector4f
*to_vec
,
646 const GLvector4f
*from_vec
,
650 const GLuint stride
= from_vec
->stride
;
651 GLfloat
*from
= from_vec
->start
;
652 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
653 GLuint count
= from_vec
->count
;
654 const GLfloat m0
= m
[0], m5
= m
[5];
655 const GLfloat m10
= m
[10], m12
= m
[12], m13
= m
[13], m14
= m
[14];
661 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
662 to
[i
][0] = m0
* ox
+ m12
;
663 to
[i
][1] = m5
* oy
+ m13
;
664 to
[i
][2] = m10
* oz
+ m14
;
668 to_vec
->flags
|= VEC_SIZE_3
;
669 to_vec
->count
= from_vec
->count
;
672 static void _XFORMAPI
673 TAG(transform_points3_perspective
)( GLvector4f
*to_vec
,
675 const GLvector4f
*from_vec
,
679 const GLuint stride
= from_vec
->stride
;
680 GLfloat
*from
= from_vec
->start
;
681 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
682 GLuint count
= from_vec
->count
;
683 const GLfloat m0
= m
[0], m5
= m
[5], m8
= m
[8], m9
= m
[9];
684 const GLfloat m10
= m
[10], m14
= m
[14];
690 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
691 to
[i
][0] = m0
* ox
+ m8
* oz
;
692 to
[i
][1] = m5
* oy
+ m9
* oz
;
693 to
[i
][2] = m10
* oz
+ m14
;
698 to_vec
->flags
|= VEC_SIZE_4
;
699 to_vec
->count
= from_vec
->count
;
704 static void _XFORMAPI
705 TAG(transform_points4_general
)( GLvector4f
*to_vec
,
707 const GLvector4f
*from_vec
,
711 const GLuint stride
= from_vec
->stride
;
712 GLfloat
*from
= from_vec
->start
;
713 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
714 GLuint count
= from_vec
->count
;
715 const GLfloat m0
= m
[0], m4
= m
[4], m8
= m
[8], m12
= m
[12];
716 const GLfloat m1
= m
[1], m5
= m
[5], m9
= m
[9], m13
= m
[13];
717 const GLfloat m2
= m
[2], m6
= m
[6], m10
= m
[10], m14
= m
[14];
718 const GLfloat m3
= m
[3], m7
= m
[7], m11
= m
[11], m15
= m
[15];
724 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
725 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
* ow
;
726 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
* ow
;
727 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
* ow
;
728 to
[i
][3] = m3
* ox
+ m7
* oy
+ m11
* oz
+ m15
* ow
;
732 to_vec
->flags
|= VEC_SIZE_4
;
733 to_vec
->count
= from_vec
->count
;
736 static void _XFORMAPI
737 TAG(transform_points4_identity
)( GLvector4f
*to_vec
,
739 const GLvector4f
*from_vec
,
743 const GLuint stride
= from_vec
->stride
;
744 GLfloat
*from
= from_vec
->start
;
745 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
746 GLuint count
= from_vec
->count
;
750 if (to_vec
== from_vec
) return;
760 to_vec
->flags
|= VEC_SIZE_4
;
761 to_vec
->count
= from_vec
->count
;
764 static void _XFORMAPI
765 TAG(transform_points4_2d
)( GLvector4f
*to_vec
,
767 const GLvector4f
*from_vec
,
771 const GLuint stride
= from_vec
->stride
;
772 GLfloat
*from
= from_vec
->start
;
773 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
774 GLuint count
= from_vec
->count
;
775 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
776 const GLfloat m12
= m
[12], m13
= m
[13];
782 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
783 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
* ow
;
784 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
* ow
;
790 to_vec
->flags
|= VEC_SIZE_4
;
791 to_vec
->count
= from_vec
->count
;
794 static void _XFORMAPI
795 TAG(transform_points4_2d_no_rot
)( GLvector4f
*to_vec
,
797 const GLvector4f
*from_vec
,
801 const GLuint stride
= from_vec
->stride
;
802 GLfloat
*from
= from_vec
->start
;
803 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
804 GLuint count
= from_vec
->count
;
805 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
811 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
812 to
[i
][0] = m0
* ox
+ m12
* ow
;
813 to
[i
][1] = m5
* oy
+ m13
* ow
;
819 to_vec
->flags
|= VEC_SIZE_4
;
820 to_vec
->count
= from_vec
->count
;
823 static void _XFORMAPI
824 TAG(transform_points4_3d
)( GLvector4f
*to_vec
,
826 const GLvector4f
*from_vec
,
830 const GLuint stride
= from_vec
->stride
;
831 GLfloat
*from
= from_vec
->start
;
832 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
833 GLuint count
= from_vec
->count
;
834 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
835 const GLfloat m6
= m
[6], m8
= m
[8], m9
= m
[9], m10
= m
[10];
836 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
842 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
843 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
* ow
;
844 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
* ow
;
845 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
* ow
;
850 to_vec
->flags
|= VEC_SIZE_4
;
851 to_vec
->count
= from_vec
->count
;
854 static void _XFORMAPI
855 TAG(transform_points4_3d_no_rot
)( GLvector4f
*to_vec
,
857 const GLvector4f
*from_vec
,
861 const GLuint stride
= from_vec
->stride
;
862 GLfloat
*from
= from_vec
->start
;
863 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
864 GLuint count
= from_vec
->count
;
865 const GLfloat m0
= m
[0], m5
= m
[5];
866 const GLfloat m10
= m
[10], m12
= m
[12], m13
= m
[13], m14
= m
[14];
872 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
873 to
[i
][0] = m0
* ox
+ m12
* ow
;
874 to
[i
][1] = m5
* oy
+ m13
* ow
;
875 to
[i
][2] = m10
* oz
+ m14
* ow
;
880 to_vec
->flags
|= VEC_SIZE_4
;
881 to_vec
->count
= from_vec
->count
;
884 static void _XFORMAPI
885 TAG(transform_points4_perspective
)( GLvector4f
*to_vec
,
887 const GLvector4f
*from_vec
,
891 const GLuint stride
= from_vec
->stride
;
892 GLfloat
*from
= from_vec
->start
;
893 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
894 GLuint count
= from_vec
->count
;
895 const GLfloat m0
= m
[0], m5
= m
[5], m8
= m
[8], m9
= m
[9];
896 const GLfloat m10
= m
[10], m14
= m
[14];
902 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
903 to
[i
][0] = m0
* ox
+ m8
* oz
;
904 to
[i
][1] = m5
* oy
+ m9
* oz
;
905 to
[i
][2] = m10
* oz
+ m14
* ow
;
911 to_vec
->flags
|= VEC_SIZE_4
;
912 to_vec
->count
= from_vec
->count
;
915 static transform_func _XFORMAPI
TAG(transform_tab_1
)[7];
916 static transform_func _XFORMAPI
TAG(transform_tab_2
)[7];
917 static transform_func _XFORMAPI
TAG(transform_tab_3
)[7];
918 static transform_func _XFORMAPI
TAG(transform_tab_4
)[7];
920 /* Similar functions could be called several times, with more highly
921 * optimized routines overwriting the arrays. This only occurs during
924 static void _XFORMAPI
TAG(init_c_transformations
)( void )
926 #define TAG_TAB gl_transform_tab[IDX]
927 #define TAG_TAB_1 TAG(transform_tab_1)
928 #define TAG_TAB_2 TAG(transform_tab_2)
929 #define TAG_TAB_3 TAG(transform_tab_3)
930 #define TAG_TAB_4 TAG(transform_tab_4)
932 TAG_TAB
[1] = TAG_TAB_1
;
933 TAG_TAB
[2] = TAG_TAB_2
;
934 TAG_TAB
[3] = TAG_TAB_3
;
935 TAG_TAB
[4] = TAG_TAB_4
;
937 /* 1-D points (ie texcoords) */
938 TAG_TAB_1
[MATRIX_GENERAL
] = TAG(transform_points1_general
);
939 TAG_TAB_1
[MATRIX_IDENTITY
] = TAG(transform_points1_identity
);
940 TAG_TAB_1
[MATRIX_3D_NO_ROT
] = TAG(transform_points1_3d_no_rot
);
941 TAG_TAB_1
[MATRIX_PERSPECTIVE
] = TAG(transform_points1_perspective
) ;
942 TAG_TAB_1
[MATRIX_2D
] = TAG(transform_points1_2d
);
943 TAG_TAB_1
[MATRIX_2D_NO_ROT
] = TAG(transform_points1_2d_no_rot
);
944 TAG_TAB_1
[MATRIX_3D
] = TAG(transform_points1_3d
);
947 TAG_TAB_2
[MATRIX_GENERAL
] = TAG(transform_points2_general
);
948 TAG_TAB_2
[MATRIX_IDENTITY
] = TAG(transform_points2_identity
);
949 TAG_TAB_2
[MATRIX_3D_NO_ROT
] = TAG(transform_points2_3d_no_rot
);
950 TAG_TAB_2
[MATRIX_PERSPECTIVE
] = TAG(transform_points2_perspective
) ;
951 TAG_TAB_2
[MATRIX_2D
] = TAG(transform_points2_2d
);
952 TAG_TAB_2
[MATRIX_2D_NO_ROT
] = TAG(transform_points2_2d_no_rot
);
953 TAG_TAB_2
[MATRIX_3D
] = TAG(transform_points2_3d
);
956 TAG_TAB_3
[MATRIX_GENERAL
] = TAG(transform_points3_general
);
957 TAG_TAB_3
[MATRIX_IDENTITY
] = TAG(transform_points3_identity
);
958 TAG_TAB_3
[MATRIX_3D_NO_ROT
] = TAG(transform_points3_3d_no_rot
);
959 TAG_TAB_3
[MATRIX_PERSPECTIVE
] = TAG(transform_points3_perspective
);
960 TAG_TAB_3
[MATRIX_2D
] = TAG(transform_points3_2d
);
961 TAG_TAB_3
[MATRIX_2D_NO_ROT
] = TAG(transform_points3_2d_no_rot
);
962 TAG_TAB_3
[MATRIX_3D
] = TAG(transform_points3_3d
);
965 TAG_TAB_4
[MATRIX_GENERAL
] = TAG(transform_points4_general
);
966 TAG_TAB_4
[MATRIX_IDENTITY
] = TAG(transform_points4_identity
);
967 TAG_TAB_4
[MATRIX_3D_NO_ROT
] = TAG(transform_points4_3d_no_rot
);
968 TAG_TAB_4
[MATRIX_PERSPECTIVE
] = TAG(transform_points4_perspective
);
969 TAG_TAB_4
[MATRIX_2D
] = TAG(transform_points4_2d
);
970 TAG_TAB_4
[MATRIX_2D_NO_ROT
] = TAG(transform_points4_2d_no_rot
);
971 TAG_TAB_4
[MATRIX_3D
] = TAG(transform_points4_3d
);