-/* $Id: blend.c,v 1.27 2000/12/26 05:09:27 keithw Exp $ */
+/* $Id: blend.c,v 1.32 2001/03/29 16:50:31 brianp Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
*
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2001 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"),
*/
-
#ifdef PC_HEADER
#include "all.h"
#else
void
_mesa_BlendFunc( GLenum sfactor, GLenum dfactor )
{
-
+
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
fprintf(stderr, "glBlendFunc %s %s\n",
- gl_lookup_enum_by_nr(sfactor),
- gl_lookup_enum_by_nr(dfactor));
+ _mesa_lookup_enum_by_nr(sfactor),
+ _mesa_lookup_enum_by_nr(dfactor));
switch (sfactor) {
case GL_SRC_COLOR:
case GL_ONE_MINUS_SRC_COLOR:
if (!ctx->Extensions.NV_blend_square) {
- gl_error( ctx, GL_INVALID_ENUM, "glBlendFunc(sfactor)" );
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBlendFunc(sfactor)" );
return;
}
/* fall-through */
case GL_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
- gl_error( ctx, GL_INVALID_ENUM, "glBlendFunc(sfactor)" );
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBlendFunc(sfactor)" );
return;
}
case GL_DST_COLOR:
case GL_ONE_MINUS_DST_COLOR:
if (!ctx->Extensions.NV_blend_square) {
- gl_error( ctx, GL_INVALID_ENUM, "glBlendFunc(dfactor)" );
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBlendFunc(dfactor)" );
return;
}
/* fall-through */
case GL_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
- gl_error( ctx, GL_INVALID_ENUM, "glBlendFunc(dfactor)" );
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBlendFunc(dfactor)" );
return;
}
ctx->Color.BlendDstRGB = ctx->Color.BlendDstA = dfactor;
ctx->Color.BlendSrcRGB = ctx->Color.BlendSrcA = sfactor;
- if (ctx->Driver.BlendFunc)
+ if (ctx->Driver.BlendFunc)
ctx->Driver.BlendFunc( ctx, sfactor, dfactor );
}
ASSERT_OUTSIDE_BEGIN_END(ctx);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
- fprintf(stderr, "glBlendFuncSeperate %s %s %s %s\n",
- gl_lookup_enum_by_nr(sfactorRGB),
- gl_lookup_enum_by_nr(dfactorRGB),
- gl_lookup_enum_by_nr(sfactorA),
- gl_lookup_enum_by_nr(dfactorA));
+ fprintf(stderr, "glBlendFuncSeparate %s %s %s %s\n",
+ _mesa_lookup_enum_by_nr(sfactorRGB),
+ _mesa_lookup_enum_by_nr(dfactorRGB),
+ _mesa_lookup_enum_by_nr(sfactorA),
+ _mesa_lookup_enum_by_nr(dfactorA));
switch (sfactorRGB) {
case GL_SRC_COLOR:
case GL_ONE_MINUS_SRC_COLOR:
if (!ctx->Extensions.NV_blend_square) {
- gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorRGB)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorRGB)");
return;
}
/* fall-through */
case GL_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
- gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorRGB)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorRGB)");
return;
}
case GL_DST_COLOR:
case GL_ONE_MINUS_DST_COLOR:
if (!ctx->Extensions.NV_blend_square) {
- gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorRGB)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorRGB)");
return;
}
/* fall-through */
case GL_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
- gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorRGB)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorRGB)");
return;
}
case GL_SRC_COLOR:
case GL_ONE_MINUS_SRC_COLOR:
if (!ctx->Extensions.NV_blend_square) {
- gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorA)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorA)");
return;
}
/* fall-through */
case GL_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
- gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorA)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(sfactorA)");
return;
}
case GL_DST_COLOR:
case GL_ONE_MINUS_DST_COLOR:
if (!ctx->Extensions.NV_blend_square) {
- gl_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorA)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorA)");
return;
}
/* fall-through */
case GL_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
- gl_error( ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorA)" );
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBlendFuncSeparate(dfactorA)" );
return;
}
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
fprintf(stderr, "glBlendEquation %s\n",
- gl_lookup_enum_by_nr(mode));
+ _mesa_lookup_enum_by_nr(mode));
switch (mode) {
+ case GL_FUNC_ADD_EXT:
+ break;
case GL_MIN_EXT:
case GL_MAX_EXT:
- case GL_FUNC_ADD_EXT:
- if (!ctx->Extensions.EXT_blend_minmax) {
- gl_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
+ if (!ctx->Extensions.EXT_blend_minmax &&
+ !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
return;
}
+ break;
case GL_LOGIC_OP:
+ if (!ctx->Extensions.EXT_blend_logic_op) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
+ return;
+ }
break;
case GL_FUNC_SUBTRACT_EXT:
case GL_FUNC_REVERSE_SUBTRACT_EXT:
- if (!ctx->Extensions.EXT_blend_subtract) {
- gl_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
+ if (!ctx->Extensions.EXT_blend_subtract &&
+ !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
return;
}
break;
default:
- gl_error( ctx, GL_INVALID_ENUM, "glBlendEquation" );
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBlendEquation" );
return;
}
if (ctx->Color.BlendEquation == mode)
return;
-
+
FLUSH_VERTICES(ctx, _NEW_COLOR);
ctx->Color.BlendEquation = mode;
/* This is needed to support 1.1's RGB logic ops AND
* 1.0's blending logicops.
*/
- ctx->Color.ColorLogicOpEnabled = (mode==GL_LOGIC_OP &&
+ ctx->Color.ColorLogicOpEnabled = (mode==GL_LOGIC_OP &&
ctx->Color.BlendEnabled);
if (ctx->Driver.BlendEquation)
- ctx->Driver.BlendEquation( ctx, mode );
+ (*ctx->Driver.BlendEquation)( ctx, mode );
}
FLUSH_VERTICES(ctx, _NEW_COLOR);
COPY_4FV( ctx->Color.BlendColor, tmp );
-}
+ if (ctx->Driver.BlendColor)
+ (*ctx->Driver.BlendColor)(ctx, tmp);
+}