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