mesa: Change "BRIAN PAUL" to "THE AUTHORS" in license text.
[mesa.git] / src / mesa / main / viewport.c
index ead856d32c3148f67a126dabd4fe83bc883e731b..4962c74f2dc7a2e515465801f33b08f3ad42222d 100644 (file)
@@ -17,7 +17,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
@@ -31,6 +31,7 @@
 
 #include "context.h"
 #include "macros.h"
+#include "mtypes.h"
 #include "viewport.h"
 
 
@@ -45,7 +46,7 @@ void GLAPIENTRY
 _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+   FLUSH_VERTICES(ctx, 0);
    _mesa_set_viewport(ctx, x, y, width, height);
 }
 
@@ -60,7 +61,7 @@ _mesa_Viewport(GLint x, GLint y, GLsizei width, GLsizei height)
  * \param height height of the viewport rectangle.
  */
 void
-_mesa_set_viewport(GLcontext *ctx, GLint x, GLint y,
+_mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y,
                     GLsizei width, GLsizei height)
 {
    if (MESA_VERBOSE & VERBOSE_API)
@@ -73,8 +74,8 @@ _mesa_set_viewport(GLcontext *ctx, GLint x, GLint y,
    }
 
    /* 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);
+   width  = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth);
+   height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight);
 
    ctx->Viewport.X = x;
    ctx->Viewport.Width = width;
@@ -115,11 +116,16 @@ void GLAPIENTRY
 _mesa_DepthRange(GLclampd nearval, GLclampd farval)
 {
    GET_CURRENT_CONTEXT(ctx);
-   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+   FLUSH_VERTICES(ctx, 0);
 
    if (MESA_VERBOSE&VERBOSE_API)
       _mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval);
 
+   if (ctx->Viewport.Near == nearval &&
+       ctx->Viewport.Far == farval)
+      return;
+
    ctx->Viewport.Near = (GLfloat) CLAMP(nearval, 0.0, 1.0);
    ctx->Viewport.Far = (GLfloat) CLAMP(farval, 0.0, 1.0);
    ctx->NewState |= _NEW_VIEWPORT;
@@ -141,13 +147,17 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval)
    }
 }
 
-
+void GLAPIENTRY
+_mesa_DepthRangef(GLclampf nearval, GLclampf farval)
+{
+   _mesa_DepthRange(nearval, farval);
+}
 
 /** 
  * Initialize the context viewport attribute group.
  * \param ctx  the GL context.
  */
-void _mesa_init_viewport(GLcontext *ctx)
+void _mesa_init_viewport(struct gl_context *ctx)
 {
    GLfloat depthMax = 65535.0F; /* sorf of arbitrary */
 
@@ -169,7 +179,7 @@ void _mesa_init_viewport(GLcontext *ctx)
  * Free the context viewport attribute group data.
  * \param ctx  the GL context.
  */
-void _mesa_free_viewport_data(GLcontext *ctx)
+void _mesa_free_viewport_data(struct gl_context *ctx)
 {
    _math_matrix_dtr(&ctx->Viewport._WindowMap);
 }