fixed pointer arithmetic error in glCopyPixels
[mesa.git] / src / mesa / main / buffers.c
index 82afb401a82b1cae77a9bf0fac57e9147681a7ed..b4feb219fbff64f3834042cad4c752cf001284a3 100644 (file)
@@ -1,10 +1,10 @@
-/* $Id: buffers.c,v 1.29 2001/05/29 15:23:48 brianp Exp $ */
+/* $Id: buffers.c,v 1.32 2002/02/15 16:25:16 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
- * Version:  3.5
+ * Version:  4.1
  *
- * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
+ * Copyright (C) 1999-2002  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"),
@@ -36,7 +36,6 @@
 #include "depth.h"
 #include "enums.h"
 #include "macros.h"
-#include "masking.h"
 #include "mem.h"
 #include "stencil.h"
 #include "state.h"
@@ -100,6 +99,15 @@ _mesa_Clear( GLbitfield mask )
    if (MESA_VERBOSE & VERBOSE_API)
       fprintf(stderr, "glClear 0x%x\n", mask);
 
+   if (mask & ~(GL_COLOR_BUFFER_BIT |
+                GL_DEPTH_BUFFER_BIT |
+                GL_STENCIL_BUFFER_BIT |
+                GL_ACCUM_BUFFER_BIT)) {
+      /* invalid bit set */
+      _mesa_error( ctx, GL_INVALID_VALUE, "glClear(mask)");
+      return;
+   }
+
    if (ctx->NewState) {
       _mesa_update_state( ctx );       /* update _Xmin, etc */
    }
@@ -124,7 +132,7 @@ _mesa_Clear( GLbitfield mask )
       }
 
       ASSERT(ctx->Driver.Clear);
-      ctx->Driver.Clear( ctx, ddMask, !ctx->Scissor.Enabled,
+      ctx->Driver.Clear( ctx, ddMask, (GLboolean) !ctx->Scissor.Enabled,
                         x, y, width, height );
    }
 }
@@ -372,6 +380,37 @@ _mesa_ResizeBuffersMESA( void )
 }
 
 
+void
+_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
+{
+   GET_CURRENT_CONTEXT(ctx);
+   ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+   if (width < 0 || height < 0) {
+      _mesa_error( ctx, GL_INVALID_VALUE, "glScissor" );
+      return;
+   }
+
+   if (MESA_VERBOSE & VERBOSE_API)
+      fprintf(stderr, "glScissor %d %d %d %d\n", x, y, width, height);
+
+   if (x == ctx->Scissor.X &&
+       y == ctx->Scissor.Y &&
+       width == ctx->Scissor.Width &&
+       height == ctx->Scissor.Height)
+      return;
+
+   FLUSH_VERTICES(ctx, _NEW_SCISSOR);
+   ctx->Scissor.X = x;
+   ctx->Scissor.Y = y;
+   ctx->Scissor.Width = width;
+   ctx->Scissor.Height = height;
+
+   if (ctx->Driver.Scissor)
+      ctx->Driver.Scissor( ctx, x, y, width, height );
+}
+
+
 /*
  * XXX move somewhere else someday?
  */
@@ -386,7 +425,7 @@ _mesa_SampleCoverageARB(GLclampf value, GLboolean invert)
    }
 
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
-   ctx->Multisample.SampleCoverageValue = CLAMP(value, 0.0, 1.0);
+   ctx->Multisample.SampleCoverageValue = (GLfloat) CLAMP(value, 0.0, 1.0);
    ctx->Multisample.SampleCoverageInvert = invert;
    ctx->NewState |= _NEW_MULTISAMPLE;
 }