mesa: don't include m_xform.h where not needed
[mesa.git] / src / mesa / main / matrix.c
index 069c5c9738968664acd2a2f80d5c6c13106891bb..90d142278d183f85c1c006a23ea3b09b87ac0615 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.3
+ * Version:  6.5.3
  *
- * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -42,7 +42,6 @@
 #include "matrix.h"
 #include "mtypes.h"
 #include "math/m_matrix.h"
-#include "math/m_xform.h"
 
 
 /**
@@ -160,6 +159,10 @@ _mesa_MatrixMode( GLenum mode )
       ctx->CurrentStack = &ctx->ProjectionMatrixStack;
       break;
    case GL_TEXTURE:
+      if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
+         _mesa_error(ctx, GL_INVALID_OPERATION, "glMatrixMode(texcoord unit)");
+         return;
+      }
       ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit];
       break;
    case GL_COLOR:
@@ -226,7 +229,7 @@ void GLAPIENTRY
 _mesa_PushMatrix( void )
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct matrix_stack *stack = ctx->CurrentStack;
+   struct gl_matrix_stack *stack = ctx->CurrentStack;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    if (MESA_VERBOSE&VERBOSE_API)
@@ -266,7 +269,7 @@ void GLAPIENTRY
 _mesa_PopMatrix( void )
 {
    GET_CURRENT_CONTEXT(ctx);
-   struct matrix_stack *stack = ctx->CurrentStack;
+   struct gl_matrix_stack *stack = ctx->CurrentStack;
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
 
    if (MESA_VERBOSE&VERBOSE_API)
@@ -423,7 +426,7 @@ _mesa_Scalef( GLfloat x, GLfloat y, GLfloat z )
 
 
 /**
- * Multiply the current matrix with a general scaling matrix.
+ * Multiply the current matrix with a translation matrix.
  *
  * \param x translation vector x coordinate.
  * \param y translation vector y coordinate.
@@ -575,18 +578,28 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y,
       return;
    }
 
-   /* clamp width, and height to implementation dependent range */
-   width  = CLAMP( width,  1, ctx->Const.MaxViewportWidth );
-   height = CLAMP( height, 1, ctx->Const.MaxViewportHeight );
+   /* clamp width and height to the implementation dependent range */
+   width  = CLAMP(width,  1, (GLsizei) ctx->Const.MaxViewportWidth);
+   height = CLAMP(height, 1, (GLsizei) ctx->Const.MaxViewportHeight);
 
-   /* Save viewport */
    ctx->Viewport.X = x;
    ctx->Viewport.Width = width;
    ctx->Viewport.Y = y;
    ctx->Viewport.Height = height;
-
    ctx->NewState |= _NEW_VIEWPORT;
 
+#if 1
+   /* XXX remove this someday.  Currently the DRI drivers rely on
+    * the WindowMap matrix being up to date in the driver's Viewport
+    * and DepthRange functions.
+    */
+   _math_matrix_viewport(&ctx->Viewport._WindowMap,
+                         ctx->Viewport.X, ctx->Viewport.Y,
+                         ctx->Viewport.Width, ctx->Viewport.Height,
+                         ctx->Viewport.Near, ctx->Viewport.Far,
+                         ctx->DrawBuffer->_DepthMaxF);
+#endif
+
    if (ctx->Driver.Viewport) {
       /* Many drivers will use this call to check for window size changes
        * and reallocate the z/stencil/accum/etc buffers if needed.
@@ -597,7 +610,6 @@ _mesa_set_viewport( GLcontext *ctx, GLint x, GLint y,
 
 
 #if _HAVE_FULL_GL
-void GLAPIENTRY
 /**
  * Called by glDepthRange
  *
@@ -606,6 +618,7 @@ void GLAPIENTRY
  * \param farval  specifies the Z buffer value which should correspond to
  *                the far clip plane
  */
+void GLAPIENTRY
 _mesa_DepthRange( GLclampd nearval, GLclampd farval )
 {
    GET_CURRENT_CONTEXT(ctx);
@@ -618,6 +631,18 @@ _mesa_DepthRange( GLclampd nearval, GLclampd farval )
    ctx->Viewport.Far = (GLfloat) CLAMP( farval, 0.0, 1.0 );
    ctx->NewState |= _NEW_VIEWPORT;
 
+#if 1
+   /* XXX remove this someday.  Currently the DRI drivers rely on
+    * the WindowMap matrix being up to date in the driver's Viewport
+    * and DepthRange functions.
+    */
+   _math_matrix_viewport(&ctx->Viewport._WindowMap,
+                         ctx->Viewport.X, ctx->Viewport.Y,
+                         ctx->Viewport.Width, ctx->Viewport.Height,
+                         ctx->Viewport.Near, ctx->Viewport.Far,
+                         ctx->DrawBuffer->_DepthMaxF);
+#endif
+
    if (ctx->Driver.DepthRange) {
       (*ctx->Driver.DepthRange)( ctx, nearval, farval );
    }
@@ -740,7 +765,7 @@ void _mesa_update_modelview_project( GLcontext *ctx, GLuint new_state )
  * initialize it.
  */
 static void
-init_matrix_stack( struct matrix_stack *stack,
+init_matrix_stack( struct gl_matrix_stack *stack,
                    GLuint maxDepth, GLuint dirtyFlag )
 {
    GLuint i;
@@ -766,7 +791,7 @@ init_matrix_stack( struct matrix_stack *stack,
  * frees the array.
  */
 static void
-free_matrix_stack( struct matrix_stack *stack )
+free_matrix_stack( struct gl_matrix_stack *stack )
 {
    GLuint i;
    for (i = 0; i < stack->MaxDepth; i++) {