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