From fd5511d27fc44096117c47ab503fb5b47f993061 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 29 Dec 2009 16:17:14 -0700 Subject: mesa: implement per-buffer color masking This is part of the GL_EXT_draw_buffers2 extension and part of GL 3.0. The ctx->Color.ColorMask field is now a 2-D array. Until drivers are modified to support per-buffer color masking, they can just look at the 0th color mask. The new _mesa_ColorMaskIndexed() function will be called by glColorMaskIndexedEXT() or glColorMaski(). --- src/mesa/main/get.c | 65 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 19 deletions(-) (limited to 'src/mesa/main/get.c') diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index aff67466bcb..44396a0491c 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -210,10 +210,10 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = ENUM_TO_BOOLEAN(ctx->Light.ColorMaterialMode); break; case GL_COLOR_WRITEMASK: - params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[RCOMP] ? 1 : 0); - params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[GCOMP] ? 1 : 0); - params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[BCOMP] ? 1 : 0); - params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[ACOMP] ? 1 : 0); + params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0); + params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0); + params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0); + params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0); break; case GL_CULL_FACE: params[0] = ctx->Polygon.CullFlag; @@ -2045,10 +2045,10 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = ENUM_TO_FLOAT(ctx->Light.ColorMaterialMode); break; case GL_COLOR_WRITEMASK: - params[0] = (GLfloat)(ctx->Color.ColorMask[RCOMP] ? 1 : 0); - params[1] = (GLfloat)(ctx->Color.ColorMask[GCOMP] ? 1 : 0); - params[2] = (GLfloat)(ctx->Color.ColorMask[BCOMP] ? 1 : 0); - params[3] = (GLfloat)(ctx->Color.ColorMask[ACOMP] ? 1 : 0); + params[0] = (GLfloat)(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0); + params[1] = (GLfloat)(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0); + params[2] = (GLfloat)(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0); + params[3] = (GLfloat)(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0); break; case GL_CULL_FACE: params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.CullFlag); @@ -3880,10 +3880,10 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = ENUM_TO_INT(ctx->Light.ColorMaterialMode); break; case GL_COLOR_WRITEMASK: - params[0] = ctx->Color.ColorMask[RCOMP] ? 1 : 0; - params[1] = ctx->Color.ColorMask[GCOMP] ? 1 : 0; - params[2] = ctx->Color.ColorMask[BCOMP] ? 1 : 0; - params[3] = ctx->Color.ColorMask[ACOMP] ? 1 : 0; + params[0] = ctx->Color.ColorMask[0][RCOMP] ? 1 : 0; + params[1] = ctx->Color.ColorMask[0][GCOMP] ? 1 : 0; + params[2] = ctx->Color.ColorMask[0][BCOMP] ? 1 : 0; + params[3] = ctx->Color.ColorMask[0][ACOMP] ? 1 : 0; break; case GL_CULL_FACE: params[0] = BOOLEAN_TO_INT(ctx->Polygon.CullFlag); @@ -5716,10 +5716,10 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params ) params[0] = ENUM_TO_INT64(ctx->Light.ColorMaterialMode); break; case GL_COLOR_WRITEMASK: - params[0] = (GLint64)(ctx->Color.ColorMask[RCOMP] ? 1 : 0); - params[1] = (GLint64)(ctx->Color.ColorMask[GCOMP] ? 1 : 0); - params[2] = (GLint64)(ctx->Color.ColorMask[BCOMP] ? 1 : 0); - params[3] = (GLint64)(ctx->Color.ColorMask[ACOMP] ? 1 : 0); + params[0] = (GLint64)(ctx->Color.ColorMask[0][RCOMP] ? 1 : 0); + params[1] = (GLint64)(ctx->Color.ColorMask[0][GCOMP] ? 1 : 0); + params[2] = (GLint64)(ctx->Color.ColorMask[0][BCOMP] ? 1 : 0); + params[3] = (GLint64)(ctx->Color.ColorMask[0][ACOMP] ? 1 : 0); break; case GL_CULL_FACE: params[0] = BOOLEAN_TO_INT64(ctx->Polygon.CullFlag); @@ -7448,11 +7448,20 @@ _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params ) switch (pname) { case GL_BLEND: - if (index >= MAX_DRAW_BUFFERS) { + if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); } params[0] = INT_TO_BOOLEAN(((ctx->Color.BlendEnabled >> index) & 1)); break; + case GL_COLOR_WRITEMASK: + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname); + } + params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0); + params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0); + params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0); + params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanIndexedv(pname=0x%x)", pname); } @@ -7472,11 +7481,20 @@ _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params ) switch (pname) { case GL_BLEND: - if (index >= MAX_DRAW_BUFFERS) { + if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); } params[0] = ((ctx->Color.BlendEnabled >> index) & 1); break; + case GL_COLOR_WRITEMASK: + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname); + } + params[0] = ctx->Color.ColorMask[index][RCOMP] ? 1 : 0; + params[1] = ctx->Color.ColorMask[index][GCOMP] ? 1 : 0; + params[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0; + params[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0; + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerIndexedv(pname=0x%x)", pname); } @@ -7497,11 +7515,20 @@ _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params ) switch (pname) { case GL_BLEND: - if (index >= MAX_DRAW_BUFFERS) { + if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); } params[0] = (GLint64)(((ctx->Color.BlendEnabled >> index) & 1)); break; + case GL_COLOR_WRITEMASK: + if (index >= ctx->Const.MaxDrawBuffers) { + _mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname); + } + params[0] = (GLint64)(ctx->Color.ColorMask[index][RCOMP] ? 1 : 0); + params[1] = (GLint64)(ctx->Color.ColorMask[index][GCOMP] ? 1 : 0); + params[2] = (GLint64)(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0); + params[3] = (GLint64)(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0); + break; default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64Indexedv(pname=0x%x)", pname); } -- cgit v1.2.3