diff options
author | Brian Paul <[email protected]> | 2000-05-30 02:28:03 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2000-05-30 02:28:03 +0000 |
commit | ad68f17a06cc07520e1462a7261a9d1c51a136a9 (patch) | |
tree | f0933aa0a6e09afe8567b42bd54414a700d65581 /src/mesa/main/blend.c | |
parent | aea03c424d4223aee334a66a5702d37e1e1a08cc (diff) |
initial work for GL_NV_blend_square extension
Diffstat (limited to 'src/mesa/main/blend.c')
-rw-r--r-- | src/mesa/main/blend.c | 83 |
1 files changed, 78 insertions, 5 deletions
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index 7bbffcb8dfa..ddfe6447dee 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -1,4 +1,4 @@ -/* $Id: blend.c,v 1.14 2000/04/11 21:38:08 brianp Exp $ */ +/* $Id: blend.c,v 1.15 2000/05/30 02:28:03 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -53,6 +53,13 @@ _mesa_BlendFunc( GLenum sfactor, GLenum dfactor ) gl_lookup_enum_by_nr(dfactor)); switch (sfactor) { + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + if (!ctx->Extensions.HaveBlendSquare) { + gl_error( ctx, GL_INVALID_ENUM, "glBlendFunc(sfactor)" ); + return; + } + /* fall-through */ case GL_ZERO: case GL_ONE: case GL_DST_COLOR: @@ -74,6 +81,13 @@ _mesa_BlendFunc( GLenum sfactor, GLenum dfactor ) } switch (dfactor) { + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + if (!ctx->Extensions.HaveBlendSquare) { + gl_error( ctx, GL_INVALID_ENUM, "glBlendFunc(dfactor)" ); + return; + } + /* fall-through */ case GL_ZERO: case GL_ONE: case GL_SRC_COLOR: @@ -118,6 +132,13 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, gl_lookup_enum_by_nr(dfactorA)); switch (sfactorRGB) { + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + if (!ctx->Extensions.HaveBlendSquare) { + gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorRGB)"); + return; + } + /* fall-through */ case GL_ZERO: case GL_ONE: case GL_DST_COLOR: @@ -134,11 +155,18 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, ctx->Color.BlendSrcRGB = sfactorRGB; break; default: - gl_error( ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorRGB)" ); + gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorRGB)"); return; } switch (dfactorRGB) { + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + if (!ctx->Extensions.HaveBlendSquare) { + gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorRGB)"); + return; + } + /* fall-through */ case GL_ZERO: case GL_ONE: case GL_SRC_COLOR: @@ -154,11 +182,18 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, ctx->Color.BlendDstRGB = dfactorRGB; break; default: - gl_error( ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorRGB)" ); + gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorRGB)"); return; } switch (sfactorA) { + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + if (!ctx->Extensions.HaveBlendSquare) { + gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorA)"); + return; + } + /* fall-through */ case GL_ZERO: case GL_ONE: case GL_DST_COLOR: @@ -175,11 +210,18 @@ _mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, ctx->Color.BlendSrcA = sfactorA; break; default: - gl_error( ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorA)" ); + gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorA)"); return; } switch (dfactorA) { + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + if (!ctx->Extensions.HaveBlendSquare) { + gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorA)"); + return; + } + /* fall-through */ case GL_ZERO: case GL_ONE: case GL_SRC_COLOR: @@ -221,7 +263,6 @@ _mesa_BlendEquation( GLenum mode ) fprintf(stderr, "glBlendEquation %s\n", gl_lookup_enum_by_nr(mode)); - switch (mode) { case GL_MIN_EXT: case GL_MAX_EXT: @@ -510,6 +551,16 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], case GL_ONE_MINUS_CONSTANT_ALPHA: sR = sG = sB = 1.0F - ctx->Color.BlendColor[3]; break; + case GL_SRC_COLOR: /* GL_NV_blend_square */ + sR = (GLfloat) Rs * rscale; + sG = (GLfloat) Gs * gscale; + sB = (GLfloat) Bs * bscale; + break; + case GL_ONE_MINUS_SRC_COLOR: /* GL_NV_blend_square */ + sR = 1.0F - (GLfloat) Rs * rscale; + sG = 1.0F - (GLfloat) Gs * gscale; + sB = 1.0F - (GLfloat) Bs * bscale; + break; default: /* this should never happen */ gl_problem(ctx, "Bad blend source RGB factor in do_blend"); @@ -557,6 +608,12 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], case GL_ONE_MINUS_CONSTANT_ALPHA: sA = 1.0F - ctx->Color.BlendColor[3]; break; + case GL_SRC_COLOR: /* GL_NV_blend_square */ + sA = (GLfloat) As * ascale; + break; + case GL_ONE_MINUS_SRC_COLOR: /* GL_NV_blend_square */ + sA = 1.0F - (GLfloat) As * ascale; + break; default: /* this should never happen */ sA = 0.0F; @@ -609,6 +666,16 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], case GL_ONE_MINUS_CONSTANT_ALPHA: dR = dG = dB = 1.0F - ctx->Color.BlendColor[3] * ascale; break; + case GL_DST_COLOR: /* GL_NV_blend_square */ + dR = (GLfloat) Rd * rscale; + dG = (GLfloat) Gd * gscale; + dB = (GLfloat) Bd * bscale; + break; + case GL_ONE_MINUS_DST_COLOR: /* GL_NV_blend_square */ + dR = 1.0F - (GLfloat) Rd * rscale; + dG = 1.0F - (GLfloat) Gd * gscale; + dB = 1.0F - (GLfloat) Bd * bscale; + break; default: /* this should never happen */ dR = dG = dB = 0.0F; @@ -653,6 +720,12 @@ blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[], case GL_ONE_MINUS_CONSTANT_ALPHA: dA = 1.0F - ctx->Color.BlendColor[3] * ascale; break; + case GL_DST_COLOR: /* GL_NV_blend_square */ + dA = (GLfloat) Ad * ascale; + break; + case GL_ONE_MINUS_DST_COLOR: /* GL_NV_blend_square */ + dA = 1.0F - (GLfloat) Ad * ascale; + break; default: /* this should never happen */ dA = 0.0F; |