ReactOS 0.4.15-dev-5667-ged97270
xform.c File Reference
#include <math.h>
#include "mmath.h"
#include "types.h"
#include "xform.h"
Include dependency graph for xform.c:

Go to the source code of this file.

Macros

#define M(row, col)   m[col*4+row]
 

Functions

void gl_xform_points_4fv (GLuint n, GLfloat q[][4], const GLfloat m[16], GLfloat p[][4])
 
void gl_xform_points_3fv (GLuint n, GLfloat q[][4], const GLfloat m[16], GLfloat p[][3])
 
void gl_xform_normals_3fv (GLuint n, GLfloat v[][3], const GLfloat m[16], GLfloat u[][3], GLboolean normalize)
 
void gl_transform_vector (GLfloat u[4], const GLfloat v[4], const GLfloat m[16])
 

Macro Definition Documentation

◆ M

#define M (   row,
  col 
)    m[col*4+row]

Function Documentation

◆ gl_transform_vector()

void gl_transform_vector ( GLfloat  u[4],
const GLfloat  v[4],
const GLfloat  m[16] 
)

Definition at line 248 of file xform.c.

249{
250 GLfloat v0=v[0], v1=v[1], v2=v[2], v3=v[3];
251#define M(row,col) m[col*4+row]
252 u[0] = v0 * M(0,0) + v1 * M(1,0) + v2 * M(2,0) + v3 * M(3,0);
253 u[1] = v0 * M(0,1) + v1 * M(1,1) + v2 * M(2,1) + v3 * M(3,1);
254 u[2] = v0 * M(0,2) + v1 * M(1,2) + v2 * M(2,2) + v3 * M(3,2);
255 u[3] = v0 * M(0,3) + v1 * M(1,3) + v2 * M(2,3) + v3 * M(3,3);
256#undef M
257}
float GLfloat
Definition: gl.h:161
const GLdouble * v
Definition: gl.h:2040
GLfloat v0
Definition: glext.h:6061
GLfloat GLfloat GLfloat GLfloat v3
Definition: glext.h:6064
GLfloat GLfloat v1
Definition: glext.h:6062
GLfloat GLfloat GLfloat v2
Definition: glext.h:6063
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
#define M(row, col)

Referenced by gl_ClipPlane(), gl_Lightfv(), and gl_TexGenfv().

◆ gl_xform_normals_3fv()

void gl_xform_normals_3fv ( GLuint  n,
GLfloat  v[][3],
const GLfloat  m[16],
GLfloat  u[][3],
GLboolean  normalize 
)

Definition at line 195 of file xform.c.

197{
198 if (normalize) {
199 /* Transform normals and scale to unit length */
200 GLuint i;
201 GLfloat m0 = m[0], m4 = m[4], m8 = m[8];
202 GLfloat m1 = m[1], m5 = m[5], m9 = m[9];
203 GLfloat m2 = m[2], m6 = m[6], m10 = m[10];
204 for (i=0;i<n;i++) {
205 GLdouble tx, ty, tz;
206 {
207 GLfloat ux = u[i][0], uy = u[i][1], uz = u[i][2];
208 tx = ux * m0 + uy * m1 + uz * m2;
209 ty = ux * m4 + uy * m5 + uz * m6;
210 tz = ux * m8 + uy * m9 + uz * m10;
211 }
212 {
214 len = GL_SQRT( tx*tx + ty*ty + tz*tz );
215 scale = (len>1E-30) ? (1.0 / len) : 1.0;
216 v[i][0] = tx * scale;
217 v[i][1] = ty * scale;
218 v[i][2] = tz * scale;
219 }
220 }
221 }
222 else {
223 /* Just transform normals, don't scale */
224 GLuint i;
225 GLfloat m0 = m[0], m4 = m[4], m8 = m[8];
226 GLfloat m1 = m[1], m5 = m[5], m9 = m[9];
227 GLfloat m2 = m[2], m6 = m[6], m10 = m[10];
228 for (i=0;i<n;i++) {
229 GLfloat ux = u[i][0], uy = u[i][1], uz = u[i][2];
230 v[i][0] = ux * m0 + uy * m1 + uz * m2;
231 v[i][1] = ux * m4 + uy * m5 + uz * m6;
232 v[i][2] = ux * m8 + uy * m9 + uz * m10;
233 }
234 }
235}
static void normalize(float vec[3])
Definition: bezierEval.cc:234
static const WCHAR E[]
Definition: oid.c:1253
double GLdouble
Definition: gl.h:163
unsigned int GLuint
Definition: gl.h:159
GLbyte GLbyte tz
Definition: glext.h:8756
GLdouble n
Definition: glext.h:7729
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLenum GLsizei len
Definition: glext.h:6722
GLbyte ty
Definition: glext.h:8756
const GLfloat * m
Definition: glext.h:10848
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GL_SQRT(X)
Definition: mmath.h:63

Referenced by gl_DrawArrays(), and gl_transform_vb_part1().

◆ gl_xform_points_3fv()

void gl_xform_points_3fv ( GLuint  n,
GLfloat  q[][4],
const GLfloat  m[16],
GLfloat  p[][3] 
)

Definition at line 145 of file xform.c.

147{
148 /* This function has been carefully crafted to maximize register usage
149 * and use loop unrolling with IRIX 5.3's cc. Hopefully other compilers
150 * will like this code too.
151 */
152 {
153 GLuint i;
154 GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12];
155 GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13];
156 for (i=0;i<n;i++) {
157 GLfloat p0 = p[i][0], p1 = p[i][1], p2 = p[i][2];
158 q[i][0] = m0 * p0 + m4 * p1 + m8 * p2 + m12;
159 q[i][1] = m1 * p0 + m5 * p1 + m9 * p2 + m13;
160 }
161 }
162 {
163 GLuint i;
164 GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14];
165 GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15];
166 if (m3==0.0F && m7==0.0F && m11==0.0F && m15==1.0F) {
167 /* common case */
168 for (i=0;i<n;i++) {
169 GLfloat p0 = p[i][0], p1 = p[i][1], p2 = p[i][2];
170 q[i][2] = m2 * p0 + m6 * p1 + m10 * p2 + m14;
171 q[i][3] = 1.0F;
172 }
173 }
174 else {
175 /* general case */
176 for (i=0;i<n;i++) {
177 GLfloat p0 = p[i][0], p1 = p[i][1], p2 = p[i][2];
178 q[i][2] = m2 * p0 + m6 * p1 + m10 * p2 + m14;
179 q[i][3] = m3 * p0 + m7 * p1 + m11 * p2 + m15;
180 }
181 }
182 }
183}
#define m14
#define m11
#define m13
#define m12
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by gl_DrawArrays().

◆ gl_xform_points_4fv()

void gl_xform_points_4fv ( GLuint  n,
GLfloat  q[][4],
const GLfloat  m[16],
GLfloat  p[][4] 
)

Definition at line 88 of file xform.c.

90{
91 /* This function has been carefully crafted to maximize register usage
92 * and use loop unrolling with IRIX 5.3's cc. Hopefully other compilers
93 * will like this code too.
94 */
95 {
96 GLuint i;
97 GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12];
98 GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13];
99 if (m12==0.0F && m13==0.0F) {
100 /* common case */
101 for (i=0;i<n;i++) {
102 GLfloat p0 = p[i][0], p1 = p[i][1], p2 = p[i][2];
103 q[i][0] = m0 * p0 + m4 * p1 + m8 * p2;
104 q[i][1] = m1 * p0 + m5 * p1 + m9 * p2;
105 }
106 }
107 else {
108 /* general case */
109 for (i=0;i<n;i++) {
110 GLfloat p0 = p[i][0], p1 = p[i][1], p2 = p[i][2], p3 = p[i][3];
111 q[i][0] = m0 * p0 + m4 * p1 + m8 * p2 + m12 * p3;
112 q[i][1] = m1 * p0 + m5 * p1 + m9 * p2 + m13 * p3;
113 }
114 }
115 }
116 {
117 GLuint i;
118 GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14];
119 GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15];
120 if (m3==0.0F && m7==0.0F && m11==0.0F && m15==1.0F) {
121 /* common case */
122 for (i=0;i<n;i++) {
123 GLfloat p0 = p[i][0], p1 = p[i][1], p2 = p[i][2], p3 = p[i][3];
124 q[i][2] = m2 * p0 + m6 * p1 + m10 * p2 + m14 * p3;
125 q[i][3] = p3;
126 }
127 }
128 else {
129 /* general case */
130 for (i=0;i<n;i++) {
131 GLfloat p0 = p[i][0], p1 = p[i][1], p2 = p[i][2], p3 = p[i][3];
132 q[i][2] = m2 * p0 + m6 * p1 + m10 * p2 + m14 * p3;
133 q[i][3] = m3 * p0 + m7 * p1 + m11 * p2 + m15 * p3;
134 }
135 }
136 }
137}

Referenced by gl_DrawArrays().