Test for NULL pointer for LoadMatrix(), MultMatrix() and
[mesa.git] / src / mesa / main / matrix.c
index 6dbb4144fd9b3adaf95ed796a173c505b671809a..bef520a467932fe420bf09af277dad316fdf3959 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: matrix.c,v 1.38 2001/12/18 04:06:45 brianp Exp $ */
+/* $Id: matrix.c,v 1.40 2002/04/22 20:00:16 alanh Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -108,7 +108,7 @@ _mesa_MatrixMode( GLenum mode )
    GET_CURRENT_CONTEXT(ctx);
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
-   if (ctx->Transform.MatrixMode == mode)
+   if (ctx->Transform.MatrixMode == mode && mode != GL_TEXTURE)
       return;
    FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
 
@@ -209,6 +209,7 @@ void
 _mesa_LoadMatrixf( const GLfloat *m )
 {
    GET_CURRENT_CONTEXT(ctx);
+   if (!m) return;
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
    _math_matrix_loadf( ctx->CurrentStack->Top, m );
    ctx->NewState |= ctx->CurrentStack->DirtyFlag;
@@ -220,6 +221,7 @@ _mesa_LoadMatrixd( const GLdouble *m )
 {
    GLint i;
    GLfloat f[16];
+   if (!m) return;
    for (i = 0; i < 16; i++)
       f[i] = (GLfloat) m[i];
    _mesa_LoadMatrixf(f);
@@ -234,6 +236,7 @@ void
 _mesa_MultMatrixf( const GLfloat *m )
 {
    GET_CURRENT_CONTEXT(ctx);
+   if (!m) return;
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
    _math_matrix_mul_floats( ctx->CurrentStack->Top, m );
    ctx->NewState |= ctx->CurrentStack->DirtyFlag;
@@ -248,6 +251,7 @@ _mesa_MultMatrixd( const GLdouble *m )
 {
    GLint i;
    GLfloat f[16];
+   if (!m) return;
    for (i = 0; i < 16; i++)
       f[i] = (GLfloat) m[i];
    _mesa_MultMatrixf( f );
@@ -321,6 +325,7 @@ void
 _mesa_LoadTransposeMatrixfARB( const GLfloat *m )
 {
    GLfloat tm[16];
+   if (!m) return;
    _math_transposef(tm, m);
    _mesa_LoadMatrixf(tm);
 }
@@ -330,6 +335,7 @@ void
 _mesa_LoadTransposeMatrixdARB( const GLdouble *m )
 {
    GLfloat tm[16];
+   if (!m) return;
    _math_transposefd(tm, m);
    _mesa_LoadMatrixf(tm);
 }
@@ -339,6 +345,7 @@ void
 _mesa_MultTransposeMatrixfARB( const GLfloat *m )
 {
    GLfloat tm[16];
+   if (!m) return;
    _math_transposef(tm, m);
    _mesa_MultMatrixf(tm);
 }
@@ -348,6 +355,7 @@ void
 _mesa_MultTransposeMatrixdARB( const GLdouble *m )
 {
    GLfloat tm[16];
+   if (!m) return;
    _math_transposefd(tm, m);
    _mesa_MultMatrixf(tm);
 }