ision 1.23  1997/12/29 23:48:53  brianp
 * call Driver.NearFar() in gl_LoadMatrixf() for projection matrix
 *
 * Revision 1.22  1997/10/16 23:37:23  brianp
 * fixed scotter's email address
 *
 * Revision 1.21  1997/08/13 01:54:34  brianp
 * new matrix invert code from Scott McCaskill
 *
 * Revision 1.20  1997/07/24 01:23:16  brianp
 * changed precompiled header symbol from PCH to PC_HEADER
 *
 * Revision 1.19  1997/05/30 02:21:43  brianp
 * gl_PopMatrix() set ctx->New*Matrix flag incorrectly
 *
 * Revision 1.18  1997/05/28 04:06:03  brianp
 * implemented projection near/far value stack for Driver.NearFar() function
 *
 * Revision 1.17  1997/05/28 03:25:43  brianp
 * added precompiled header (PCH) support
 *
 * Revision 1.16  1997/05/01 01:39:40  brianp
 * replace sqrt() with GL_SQRT()
 *
 * Revision 1.15  1997/04/21 01:20:41  brianp
 * added MATRIX_2D_NO_ROT
 *
 * Revision 1.14  1997/04/20 20:28:49  brianp
 * replaced abort() with gl_problem()
 *
 * Revision 1.13  1997/04/20 16:31:08  brianp
 * added NearFar device driver function
 *
 * Revision 1.12  1997/04/20 16:18:15  brianp
 * added glOrtho and glFrustum API pointers
 *
 * Revision 1.11  1997/04/01 04:23:53  brianp
 * added gl_analyze_*_matrix() functions
 *
 * Revision 1.10  1997/02/10 19:47:53  brianp
 * moved buffer resize code out of gl_Viewport() into gl_ResizeBuffersMESA()
 *
 * Revision 1.9  1997/01/31 23:32:40  brianp
 * now clear depth buffer after reallocation due to window resize
 *
 * Revision 1.8  1997/01/29 19:06:04  brianp
 * removed extra, local definition of Identity[] matrix
 *
 * Revision 1.7  1997/01/28 22:19:17  brianp
 * new matrix inversion code from Stephane Rehel
 *
 * Revision 1.6  1996/12/22 17:53:11  brianp
 * faster invert_matrix() function from scotter@iname.com
 *
 * Revision 1.5  1996/12/02 18:58:34  brianp
 * gl_rotation_matrix() now returns identity matrix if given a 0 rotation axis
 *
 * Revision 1.4  1996/09/27 01:29:05  brianp
 * added missing default cases to switches
 *
 * Revision 1.3  1996/09/15 14:18:37  brianp
 * now use GLframebuffer and GLvisual
 *
 * Revision 1.2  1996/09/14 06:46:04  brianp
 * better matmul() from Jacques Leroy
 *
 * Revision 1.1  1996/09/13 01:38:16  brianp
 * Initial revision
 *
 */


/*
 * Matrix operations
 *
 *
 * NOTES:
 * 1. 4x4 transformation matrices are stored in memory in column major order.
 * 2. Points/vertices are to be thought of as column vectors.
 * 3. Transformation of a point p by a matrix M is: p' = M * p
 *
 */


#ifdef PC_HEADER
#include "all.h"
#else
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "context.h"
#include "dlist.h"
#include "macros.h"
#include "matrix.h"
#include "mmath.h"
#include "types.h"
#endif



static GLfloat Identity[16] = {
   1.0, 0.0, 0.0, 0.0,
   0.0, 1.0, 0.0, 0.0,
   0.0, 0.0, 1.0, 0.0,
   0.0, 0.0, 0.0, 1.0
};




static void print_matrix( const GLfloat m[16] )
{
   int i;

   for (i=0;i<4;i++) {
      printf("%f %f %f %f\n", m[i], m[4+i], m[8+i], m[12+i] );
   }
}



/*
 * Perform a 4x4 matrix multiplication  (LAGS_STRICT	0x0000001f

#define BIT_IXC		0x00000010	/* inexact exception flag */
#define BIT_UFC		0x00000008	/* underflow exception flag */
#define BIT_OFC		0x00000004	/* overfloat exception flag */
#define BIT_DZC		0x00000002	/* divide by zero exception flag */
#define BIT_IOC		0x00000001	/* invalid operation exception flag */

/* Floating Point Control Register
----------------------------------*/

#define BIT_RU		0x80000000	/* rounded up bit */
#define BIT_IE		0x10000000	/* inexact bit */
#define BIT_MO		0x08000000	/* mantissa overflow bit */
#define BIT_EO		0x04000000	/* exponent overflow bit */
#define BIT_SB		0x00000800	/* store bounce */
#define BIT_AB		0x00000400	/* arithmetic bounce */
#define BIT_RE		0x00000200	/* rounding exception */
#define BIT_DA		0x00000100	/* disable FPA */

#define MASK_OP		0x00f08010	/* AU operation code */
#define MASK_PR		0x00080080	/* AU precision */
#define MASK_S1		0x00070000	/* AU source register 1 */
#define MASK_S2		0x00000007	/* AU source register 2 */
#define MASK_DS		0x00007000	/* AU destination register */
#define MASK_RM		0x00000060	/* AU rounding mode */
#define MASK_ALU	0x9cfff2ff	/* only ALU can write these bits */
#define MASK_RESET	0x00000d00	/* bits set on reset, all others cleared */
#define MASK_WFC	MASK_RESET
#define MASK_RFC	~MASK_RESET

#endif
@
