summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/scissor.c
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2016-06-09 22:50:43 -0400
committerIlia Mirkin <[email protected]>2016-06-18 12:51:55 -0400
commitd68c1e2ac28bbf0ac6259e9619fb73958fc598b8 (patch)
treea2bc494b87e8fc08ad777551231a73d9e11b42e4 /src/mesa/main/scissor.c
parent78506ad2466563d9ec3f8d09a746a069e6cab6b5 (diff)
mesa: add GL_EXT_window_rectangles state storage/retrieval functionality
Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/scissor.c')
-rw-r--r--src/mesa/main/scissor.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/mesa/main/scissor.c b/src/mesa/main/scissor.c
index 2b568e4926b..631ea4d3205 100644
--- a/src/mesa/main/scissor.c
+++ b/src/mesa/main/scissor.c
@@ -25,6 +25,7 @@
#include "main/glheader.h"
#include "main/context.h"
+#include "main/enums.h"
#include "main/mtypes.h"
#include "main/scissor.h"
@@ -213,7 +214,53 @@ _mesa_ScissorIndexedv(GLuint index, const GLint *v)
void GLAPIENTRY
_mesa_WindowRectanglesEXT(GLenum mode, GLsizei count, const GLint *box)
{
+ int i;
+ struct gl_scissor_rect newval[MAX_WINDOW_RECTANGLES];
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glWindowRectanglesEXT(%s, %d, %p)\n",
+ _mesa_enum_to_string(mode), count, box);
+
+ if (mode != GL_INCLUSIVE_EXT && mode != GL_EXCLUSIVE_EXT) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glWindowRectanglesEXT(invalid mode 0x%x)", mode);
+ return;
+ }
+
+ if (count < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glWindowRectanglesEXT(count < 0)");
+ return;
+ }
+
+ if (count > ctx->Const.MaxWindowRectangles) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glWindowRectanglesEXT(count >= MaxWindowRectangles (%d)",
+ ctx->Const.MaxWindowRectangles);
+ return;
+ }
+
+ for (i = 0; i < count; i++) {
+ if (box[2] < 0 || box[3] < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glWindowRectanglesEXT(box %d: w < 0 || h < 0)", i);
+ return;
+ }
+ newval[i].X = box[0];
+ newval[i].Y = box[1];
+ newval[i].Width = box[2];
+ newval[i].Height = box[3];
+ box += 4;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_SCISSOR);
+ memcpy(ctx->Scissor.WindowRects, newval,
+ sizeof(struct gl_scissor_rect) * count);
+ ctx->Scissor.NumWindowRects = count;
+ ctx->Scissor.WindowRectMode = mode;
+ if (ctx->Driver.Scissor)
+ ctx->Driver.Scissor(ctx);
}
@@ -228,6 +275,7 @@ _mesa_init_scissor(struct gl_context *ctx)
/* Scissor group */
ctx->Scissor.EnableFlags = 0;
+ ctx->Scissor.WindowRectMode = GL_EXCLUSIVE_EXT;
/* Note: ctx->Const.MaxViewports may not have been set by the driver yet,
* so just initialize all of them.