Make the transition to script-genereated GLX code easier.
[profile/ivi/mesa.git] / src / glx / x11 / indirect_transpose_matrix.c
1 /*
2  * (C) Copyright IBM Corporation 2004
3  * All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * on the rights to use, copy, modify, merge, publish, distribute, sub
9  * license, and/or sell copies of the Software, and to permit persons to whom
10  * the Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
19  * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22  * USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24
25 #include <GL/gl.h>
26 #include "indirect.h"
27
28 static void TransposeMatrixf(const GLfloat s[16], GLfloat d[16])
29 {
30     int i, j;
31     for (i = 0; i < 4; i++) {
32         for (j = 0; j < i; j++) {
33             d[i*4+j] = s[j*4+i];
34         }
35     }
36 }
37
38 static void TransposeMatrixd(const GLdouble s[16], GLdouble d[16])
39 {
40     int i, j;
41     for (i = 0; i < 4; i++) {
42         for (j = 0; j < i; j++) {
43             d[i*4+j] = s[j*4+i];
44         }
45     }
46 }
47
48
49 void
50 __indirect_glLoadTransposeMatrixdARB( const GLdouble * m )
51 {
52    GLdouble mt[16];
53    
54    TransposeMatrixd( m, mt );
55    __indirect_glLoadMatrixd( mt );
56 }
57
58 void
59 __indirect_glLoadTransposeMatrixfARB( const GLfloat * m )
60 {
61    GLfloat mt[16];
62
63    TransposeMatrixf( m, mt );
64    __indirect_glLoadMatrixf( mt );
65 }
66
67 void
68 __indirect_glMultTransposeMatrixdARB( const GLdouble * m )
69 {
70    GLdouble mt[16];
71    
72    TransposeMatrixd( m, mt );
73    __indirect_glMultMatrixd( mt );
74 }
75
76 void
77 __indirect_glMultTransposeMatrixfARB( const GLfloat * m )
78 {
79    GLfloat mt[16];
80
81    TransposeMatrixf( m, mt );
82    __indirect_glMultMatrixf( mt );
83 }