summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/attrib.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-12-29 15:04:03 -0700
committerBrian Paul <[email protected]>2009-12-29 15:04:03 -0700
commit3728673bd1b974e54858fbab6ff62d3607b0d3f0 (patch)
tree3c66688732a9aa9133f72e79bb43ec1cda1cb66c /src/mesa/main/attrib.c
parent561a107df71aace22a15003cc77dd504ab8b06a0 (diff)
mesa: per-buffer blend enabled flags
ctx->Color.BlendEnabled is now a GLbitfield instead of a GLboolean to indicate blend on/off status for each color/draw buffer. This is infrastructure for GL_EXT_draw_buffers2 and OpenGL 3.x New functions include _mesa_EnableIndexed(), _mesa_DisableIndexed(), and _mesa_IsEnabledIndexed(). The enable function corresponds to glEnableIndexedEXT() for GL_EXT_draw_buffers2 or glEnablei() for GL3. Note that there's quite a few tests for ctx->Color.BlendEnabled != 0 in drivers, etc. Those tests can remain as-is since the mask will be 0 or ~0 unless GL_EXT_draw_buffers2 is enabled.
Diffstat (limited to 'src/mesa/main/attrib.c')
-rw-r--r--src/mesa/main/attrib.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 246c5521b7d..88ce0a4281b 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -499,7 +499,12 @@ pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
}
TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST);
- TEST_AND_UPDATE(ctx->Color.BlendEnabled, enable->Blend, GL_BLEND);
+ if (ctx->Color.BlendEnabled != enable->Blend) {
+ GLuint i;
+ for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+ _mesa_set_enablei(ctx, GL_BLEND, i, (enable->Blend >> i) & 1);
+ }
+ }
for (i=0;i<MAX_CLIP_PLANES;i++) {
const GLuint mask = 1 << i;
@@ -906,6 +911,7 @@ _mesa_PopAttrib(void)
case GL_COLOR_BUFFER_BIT:
{
const struct gl_colorbuffer_attrib *color;
+
color = (const struct gl_colorbuffer_attrib *) attr->data;
_mesa_ClearIndex((GLfloat) color->ClearIndex);
_mesa_ClearColor(color->ClearColor[0],
@@ -948,7 +954,13 @@ _mesa_PopAttrib(void)
}
_mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);
_mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef);
- _mesa_set_enable(ctx, GL_BLEND, color->BlendEnabled);
+ if (ctx->Color.BlendEnabled != color->BlendEnabled) {
+ GLuint i;
+ for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+ _mesa_set_enablei(ctx, GL_BLEND, i,
+ (color->BlendEnabled >> i) & 1);
+ }
+ }
_mesa_BlendFuncSeparateEXT(color->BlendSrcRGB,
color->BlendDstRGB,
color->BlendSrcA,