136static void print_matrix(
const GLfloat m[16] )
159#define A(row,col) a[(col<<2)+row]
160#define B(row,col) b[(col<<2)+row]
161#define P(row,col) product[(col<<2)+row]
164 for (
i = 0;
i < 4;
i++) {
166 P(
i,0) = ai0 *
B(0,0) + ai1 *
B(1,0) + ai2 *
B(2,0) + ai3 *
B(3,0);
167 P(
i,1) = ai0 *
B(0,1) + ai1 *
B(1,1) + ai2 *
B(2,1) + ai3 *
B(3,1);
168 P(
i,2) = ai0 *
B(0,2) + ai1 *
B(1,2) + ai2 *
B(2,2) + ai3 *
B(3,2);
169 P(
i,3) = ai0 *
B(0,3) + ai1 *
B(1,3) + ai2 *
B(2,3) + ai3 *
B(3,3);
218 r1[0][0] = one_over_det *
A[
M11];
219 r1[0][1] = one_over_det * -
A[
M01];
220 r1[1][0] = one_over_det * -
A[
M10];
221 r1[1][1] = one_over_det *
A[
M00];
242 r5[0][0] = r4[0][0] -
A[
M22];
243 r5[0][1] = r4[0][1] -
A[
M23];
244 r5[1][0] = r4[1][0] -
A[
M32];
245 r5[1][1] = r4[1][1] -
A[
M33];
248 one_over_det = 1.0f / ( ( r5[0][0] * r5[1][1] ) - ( r5[1][0] * r5[0][1] ) );
249 r6[0][0] = one_over_det * r5[1][1];
250 r6[0][1] = one_over_det * -r5[0][1];
251 r6[1][0] = one_over_det * -r5[1][0];
252 r6[1][1] = one_over_det * r5[0][0];
255 C[
M02] =
r3[0][0] * r6[0][0] +
r3[0][1] * r6[1][0];
256 C[
M03] =
r3[0][0] * r6[0][1] +
r3[0][1] * r6[1][1];
257 C[
M12] =
r3[1][0] * r6[0][0] +
r3[1][1] * r6[1][0];
258 C[
M13] =
r3[1][0] * r6[0][1] +
r3[1][1] * r6[1][1];
261 C[
M20] = r6[0][0] *
r2[0][0] + r6[0][1] *
r2[1][0];
262 C[
M21] = r6[0][0] *
r2[0][1] + r6[0][1] *
r2[1][1];
263 C[
M30] = r6[1][0] *
r2[0][0] + r6[1][1] *
r2[1][0];
264 C[
M31] = r6[1][0] *
r2[0][1] + r6[1][1] *
r2[1][1];
273 C[
M00] =
r1[0][0] - r7[0][0];
274 C[
M01] =
r1[0][1] - r7[0][1];
275 C[
M10] =
r1[1][0] - r7[1][0];
276 C[
M11] =
r1[1][1] - r7[1][1];
293#define MAT(m,r,c) (m)[(c)*4+(r)]
296#define m11 MAT(m,0,0)
297#define m12 MAT(m,0,1)
298#define m13 MAT(m,0,2)
299#define m14 MAT(m,0,3)
300#define m21 MAT(m,1,0)
301#define m22 MAT(m,1,1)
302#define m23 MAT(m,1,2)
303#define m24 MAT(m,1,3)
304#define m31 MAT(m,2,0)
305#define m32 MAT(m,2,1)
306#define m33 MAT(m,2,2)
307#define m34 MAT(m,2,3)
308#define m41 MAT(m,3,0)
309#define m42 MAT(m,3,1)
310#define m43 MAT(m,3,2)
311#define m44 MAT(m,3,3)
316 if(
m41 != 0. ||
m42 != 0. ||
m43 != 0. ||
m44 != 1. ) {
328 det=
m11 * tmp[0] +
m12 * tmp[1] +
m13 * tmp[2];
336 GLfloat d12, d13, d23, d24, d34, d41;
337 register GLfloat im11, im12, im13, im14;
351 tmp[4] = im13 *
m32 - im12 *
m33;
352 tmp[5] = im11 *
m33 - im13 *
m31;
353 tmp[6] = im12 *
m31 - im11 *
m32;
358 d12 = im11*
m22 -
m21*im12;
359 d13 = im11*
m23 -
m21*im13;
360 d23 = im12*
m23 -
m22*im13;
361 d24 = im12*
m24 -
m22*im14;
362 d34 = im13*
m24 -
m23*im14;
363 d41 = im14*
m21 -
m24*im11;
370 tmp[12] = -(
m32 * d34 -
m33 * d24 +
m34 * d23);
371 tmp[13] = (
m31 * d34 +
m33 * d41 +
m34 * d13);
372 tmp[14] = -(
m31 * d24 +
m32 * d41 +
m34 * d12);
404 if (
m[0]==1.0F &&
m[4]==0.0F &&
m[ 8]==0.0F &&
m[12]==0.0F
405 &&
m[1]==0.0F &&
m[5]==1.0F &&
m[ 9]==0.0F &&
m[13]==0.0F
406 &&
m[2]==0.0F &&
m[6]==0.0F &&
m[10]==1.0F &&
m[14]==0.0F
407 &&
m[3]==0.0F &&
m[7]==0.0F &&
m[11]==0.0F &&
m[15]==1.0F) {
426 else if (
m[4]==0.0F &&
m[ 8]==0.0F
427 &&
m[1]==0.0F &&
m[ 9]==0.0F
428 &&
m[2]==0.0F &&
m[6]==0.0F &&
m[10]==1.0F &&
m[14]==0.0F
429 &&
m[3]==0.0F &&
m[7]==0.0F &&
m[11]==0.0F &&
m[15]==1.0F) {
432 else if (
m[ 8]==0.0F
434 &&
m[2]==0.0F &&
m[6]==0.0F &&
m[10]==1.0F &&
m[14]==0.0F
435 &&
m[3]==0.0F &&
m[7]==0.0F &&
m[11]==0.0F &&
m[15]==1.0F) {
438 else if (
m[3]==0.0F &&
m[7]==0.0F &&
m[11]==0.0F &&
m[15]==1.0F) {
462 else if (
m[4]==0.0F &&
m[8] ==0.0F
463 &&
m[1]==0.0F &&
m[9] ==0.0F
464 &&
m[2]==0.0F &&
m[6]==0.0F
465 &&
m[3]==0.0F &&
m[7]==0.0F &&
m[11]==0.0F &&
m[15]==1.0F) {
468 else if (
m[4]==0.0F &&
m[12]==0.0F
469 &&
m[1]==0.0F &&
m[13]==0.0F
470 &&
m[2]==0.0F &&
m[6]==0.0F
471 &&
m[3]==0.0F &&
m[7]==0.0F &&
m[11]==-1.0F &&
m[15]==0.0F) {
493 else if (
m[ 8]==0.0F
495 &&
m[2]==0.0F &&
m[6]==0.0F &&
m[10]==1.0F &&
m[14]==0.0F
496 &&
m[3]==0.0F &&
m[7]==0.0F &&
m[11]==0.0F &&
m[15]==1.0F) {
499 else if (
m[3]==0.0F &&
m[7]==0.0F &&
m[11]==0.0F &&
m[15]==1.0F) {
519 if (nearval<=0.0 || farval<=0.0) {
527 c = -(farval+nearval) / ( farval-nearval);
528 d = -(2.0*farval*nearval) / (farval-nearval);
530#define M(row,col) m[col*4+row]
531 M(0,0) =
x;
M(0,1) = 0.0F;
M(0,2) =
a;
M(0,3) = 0.0F;
532 M(1,0) = 0.0F;
M(1,1) =
y;
M(1,2) =
b;
M(1,3) = 0.0F;
533 M(2,0) = 0.0F;
M(2,1) = 0.0F;
M(2,2) =
c;
M(2,3) =
d;
534 M(3,0) = 0.0F;
M(3,1) = 0.0F;
M(3,2) = -1.0F;
M(3,3) = 0.0F;
544 ctx->NearFarStack[
ctx->ProjectionStackDepth][0] = nearval;
545 ctx->NearFarStack[
ctx->ProjectionStackDepth][1] = farval;
547 if (
ctx->Driver.NearFar) {
548 (*
ctx->Driver.NearFar)(
ctx, nearval, farval );
564 z = -2.0 / (farval-nearval);
567 tz = -(farval+nearval) / (farval-nearval);
569#define M(row,col) m[col*4+row]
570 M(0,0) =
x;
M(0,1) = 0.0F;
M(0,2) = 0.0F;
M(0,3) = tx;
571 M(1,0) = 0.0F;
M(1,1) =
y;
M(1,2) = 0.0F;
M(1,3) =
ty;
572 M(2,0) = 0.0F;
M(2,1) = 0.0F;
M(2,2) =
z;
M(2,3) =
tz;
573 M(3,0) = 0.0F;
M(3,1) = 0.0F;
M(3,2) = 0.0F;
M(3,3) = 1.0F;
578 if (
ctx->Driver.NearFar) {
579 (*
ctx->Driver.NearFar)(
ctx, nearval, farval );
594 ctx->Transform.MatrixMode =
mode;
609 switch (
ctx->Transform.MatrixMode) {
616 ctx->ModelViewMatrix,
618 ctx->ModelViewStackDepth++;
625 MEMCPY(
ctx->ProjectionStack[
ctx->ProjectionStackDepth],
626 ctx->ProjectionMatrix,
628 ctx->ProjectionStackDepth++;
631 ctx->NearFarStack[
ctx->ProjectionStackDepth][0]
632 =
ctx->NearFarStack[
ctx->ProjectionStackDepth-1][0];
633 ctx->NearFarStack[
ctx->ProjectionStackDepth][1]
634 =
ctx->NearFarStack[
ctx->ProjectionStackDepth-1][1];
644 ctx->TextureStackDepth++;
659 switch (
ctx->Transform.MatrixMode) {
661 if (
ctx->ModelViewStackDepth==0) {
665 ctx->ModelViewStackDepth--;
667 ctx->ModelViewStack[
ctx->ModelViewStackDepth],
672 if (
ctx->ProjectionStackDepth==0) {
676 ctx->ProjectionStackDepth--;
678 ctx->ProjectionStack[
ctx->ProjectionStackDepth],
684 GLfloat nearVal =
ctx->NearFarStack[
ctx->ProjectionStackDepth][0];
685 GLfloat farVal =
ctx->NearFarStack[
ctx->ProjectionStackDepth][1];
686 if (
ctx->Driver.NearFar) {
687 (*
ctx->Driver.NearFar)(
ctx, nearVal, farVal );
692 if (
ctx->TextureStackDepth==0) {
696 ctx->TextureStackDepth--;
698 ctx->TextureStack[
ctx->TextureStackDepth],
715 switch (
ctx->Transform.MatrixMode) {
744 switch (
ctx->Transform.MatrixMode) {
755#define M(row,col) m[col*4+row]
766 ctx->NearFarStack[
ctx->ProjectionStackDepth][0] =
n;
767 ctx->NearFarStack[
ctx->ProjectionStackDepth][1] =
f;
769 if (
ctx->Driver.NearFar) {
770 (*
ctx->Driver.NearFar)(
ctx,
n,
f );
791 switch (
ctx->Transform.MatrixMode) {
819 GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c;
836#define M(row,col) m[col*4+row]
902 M(0,0) = (one_c *
xx) +
c;
903 M(0,1) = (one_c * xy) - zs;
904 M(0,2) = (one_c * zx) + ys;
907 M(1,0) = (one_c * xy) + zs;
908 M(1,1) = (one_c * yy) +
c;
909 M(1,2) = (one_c * yz) - xs;
912 M(2,0) = (one_c * zx) - ys;
913 M(2,1) = (one_c * yz) + xs;
914 M(2,2) = (one_c * zz) +
c;
948 switch (
ctx->Transform.MatrixMode) {
950 m =
ctx->ModelViewMatrix;
954 m =
ctx->ProjectionMatrix;
958 m =
ctx->TextureMatrix;
965 m[0] *=
x;
m[4] *=
y;
m[8] *=
z;
966 m[1] *=
x;
m[5] *=
y;
m[9] *=
z;
967 m[2] *=
x;
m[6] *=
y;
m[10] *=
z;
968 m[3] *=
x;
m[7] *=
y;
m[11] *=
z;
983 switch (
ctx->Transform.MatrixMode) {
985 m =
ctx->ModelViewMatrix;
989 m =
ctx->ProjectionMatrix;
993 m =
ctx->TextureMatrix;
1001 m[12] =
m[0] *
x +
m[4] *
y +
m[8] *
z +
m[12];
1002 m[13] =
m[1] *
x +
m[5] *
y +
m[9] *
z +
m[13];
1003 m[14] =
m[2] *
x +
m[6] *
y +
m[10] *
z +
m[14];
1004 m[15] =
m[3] *
x +
m[7] *
y +
m[11] *
z +
m[15];
1031 ctx->Viewport.X =
x;
1033 ctx->Viewport.Y =
y;
1038 ctx->Viewport.Tx =
ctx->Viewport.Sx +
x;
1040 ctx->Viewport.Ty =
ctx->Viewport.Sy +
y;
_STLP_DECLSPEC complex< float > _STLP_CALL cos(const complex< float > &)
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
#define MAX_MODELVIEW_STACK_DEPTH
#define MAX_TEXTURE_STACK_DEPTH
#define MAX_PROJECTION_STACK_DEPTH
void gl_ResizeBuffersMESA(GLcontext *ctx)
void gl_problem(const GLcontext *ctx, const char *s)
void gl_error(GLcontext *ctx, GLenum error, const char *s)
static void invert_matrix_general(const GLfloat *m, GLfloat *out)
void gl_Scalef(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z)
void gl_analyze_texture_matrix(GLcontext *ctx)
void gl_rotation_matrix(GLfloat angle, GLfloat x, GLfloat y, GLfloat z, GLfloat m[])
void gl_LoadIdentity(GLcontext *ctx)
static void matmul(GLfloat *product, const GLfloat *a, const GLfloat *b)
void gl_Rotatef(GLcontext *ctx, GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
static void invert_matrix(const GLfloat *m, GLfloat *out)
void gl_Viewport(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height)
void gl_analyze_modelview_matrix(GLcontext *ctx)
void gl_Translatef(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z)
void gl_PopMatrix(GLcontext *ctx)
void gl_analyze_projection_matrix(GLcontext *ctx)
void gl_MultMatrixf(GLcontext *ctx, const GLfloat *m)
void gl_PushMatrix(GLcontext *ctx)
void gl_Ortho(GLcontext *ctx, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
static GLboolean is_identity(const GLfloat m[16])
static GLfloat Identity[16]
void gl_Frustum(GLcontext *ctx, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearval, GLdouble farval)
void gl_LoadMatrixf(GLcontext *ctx, const GLfloat *m)
void gl_MatrixMode(GLcontext *ctx, GLenum mode)
#define MATRIX_PERSPECTIVE
GLint GLint GLint GLint GLint x
#define GL_INVALID_OPERATION
#define GL_STACK_OVERFLOW
GLint GLint GLint GLint GLint GLint y
GLint GLint GLsizei GLsizei height
GLint GLint GLsizei width
#define GL_STACK_UNDERFLOW
GLdouble GLdouble GLdouble GLdouble top
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
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
#define MEMCPY(DST, SRC, BYTES)
#define INSIDE_BEGIN_END(CTX)
#define CLAMP(f, min, max)