⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blend.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
/** * \file blend.c * Blending operations. *//* * Mesa 3-D graphics library * Version:  6.5.1 * * Copyright (C) 1999-2006  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"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */#include "glheader.h"#include "blend.h"#include "colormac.h"#include "context.h"#include "enums.h"#include "macros.h"#include "mtypes.h"/** * Specify the blending operation. * * \param sfactor source factor operator. * \param dfactor destination factor operator. * * \sa glBlendFunc, glBlendFuncSeparateEXT * * Swizzles the inputs and calls \c glBlendFuncSeparateEXT.  This is done * using the \c CurrentDispatch table in the context, so this same function * can be used while compiling display lists.  Therefore, there is no need * for the display list code to save and restore this function. */void GLAPIENTRY_mesa_BlendFunc( GLenum sfactor, GLenum dfactor ){   GET_CURRENT_CONTEXT(ctx);   (*ctx->CurrentDispatch->BlendFuncSeparateEXT)( sfactor, dfactor,						  sfactor, dfactor );}/** * Process GL_EXT_blend_func_separate(). * * \param sfactorRGB RGB source factor operator. * \param dfactorRGB RGB destination factor operator. * \param sfactorA alpha source factor operator. * \param dfactorA alpha destination factor operator. * * Verifies the parameters and updates gl_colorbuffer_attrib. * On a change, flush the vertices and notify the driver via * dd_function_table::BlendFuncSeparate. */void GLAPIENTRY_mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,                            GLenum sfactorA, GLenum dfactorA ){   GET_CURRENT_CONTEXT(ctx);   ASSERT_OUTSIDE_BEGIN_END(ctx);   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))      _mesa_debug(ctx, "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) {            _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorRGB)");            return;         }         /* fall-through */      case GL_ZERO:      case GL_ONE:      case GL_DST_COLOR:      case GL_ONE_MINUS_DST_COLOR:      case GL_SRC_ALPHA:      case GL_ONE_MINUS_SRC_ALPHA:      case GL_DST_ALPHA:      case GL_ONE_MINUS_DST_ALPHA:      case GL_SRC_ALPHA_SATURATE:      case GL_CONSTANT_COLOR:      case GL_ONE_MINUS_CONSTANT_COLOR:      case GL_CONSTANT_ALPHA:      case GL_ONE_MINUS_CONSTANT_ALPHA:         break;      default:         _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorRGB)");         return;   }   switch (dfactorRGB) {      case GL_DST_COLOR:      case GL_ONE_MINUS_DST_COLOR:         if (!ctx->Extensions.NV_blend_square) {            _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorRGB)");            return;         }         /* fall-through */      case GL_ZERO:      case GL_ONE:      case GL_SRC_COLOR:      case GL_ONE_MINUS_SRC_COLOR:      case GL_SRC_ALPHA:      case GL_ONE_MINUS_SRC_ALPHA:      case GL_DST_ALPHA:      case GL_ONE_MINUS_DST_ALPHA:      case GL_CONSTANT_COLOR:      case GL_ONE_MINUS_CONSTANT_COLOR:      case GL_CONSTANT_ALPHA:      case GL_ONE_MINUS_CONSTANT_ALPHA:         break;      default:         _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorRGB)");         return;   }   switch (sfactorA) {      case GL_SRC_COLOR:      case GL_ONE_MINUS_SRC_COLOR:         if (!ctx->Extensions.NV_blend_square) {            _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorA)");            return;         }         /* fall-through */      case GL_ZERO:      case GL_ONE:      case GL_DST_COLOR:      case GL_ONE_MINUS_DST_COLOR:      case GL_SRC_ALPHA:      case GL_ONE_MINUS_SRC_ALPHA:      case GL_DST_ALPHA:      case GL_ONE_MINUS_DST_ALPHA:      case GL_SRC_ALPHA_SATURATE:      case GL_CONSTANT_COLOR:      case GL_ONE_MINUS_CONSTANT_COLOR:      case GL_CONSTANT_ALPHA:      case GL_ONE_MINUS_CONSTANT_ALPHA:         break;      default:         _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorA)");         return;   }   switch (dfactorA) {      case GL_DST_COLOR:      case GL_ONE_MINUS_DST_COLOR:         if (!ctx->Extensions.NV_blend_square) {            _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorA)");            return;         }         /* fall-through */      case GL_ZERO:      case GL_ONE:      case GL_SRC_COLOR:      case GL_ONE_MINUS_SRC_COLOR:      case GL_SRC_ALPHA:      case GL_ONE_MINUS_SRC_ALPHA:      case GL_DST_ALPHA:      case GL_ONE_MINUS_DST_ALPHA:      case GL_CONSTANT_COLOR:      case GL_ONE_MINUS_CONSTANT_COLOR:      case GL_CONSTANT_ALPHA:      case GL_ONE_MINUS_CONSTANT_ALPHA:         break;      default:         _mesa_error( ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorA)" );         return;   }   if (ctx->Color.BlendSrcRGB == sfactorRGB &&       ctx->Color.BlendDstRGB == dfactorRGB &&       ctx->Color.BlendSrcA == sfactorA &&       ctx->Color.BlendDstA == dfactorA)      return;   FLUSH_VERTICES(ctx, _NEW_COLOR);   ctx->Color.BlendSrcRGB = sfactorRGB;   ctx->Color.BlendDstRGB = dfactorRGB;   ctx->Color.BlendSrcA = sfactorA;   ctx->Color.BlendDstA = dfactorA;   if (ctx->Driver.BlendFuncSeparate) {      (*ctx->Driver.BlendFuncSeparate)( ctx, sfactorRGB, dfactorRGB,					sfactorA, dfactorA );   }}#if _HAVE_FULL_GLstatic GLboolean_mesa_validate_blend_equation( GLcontext *ctx,			       GLenum mode, GLboolean is_separate ){   switch (mode) {      case GL_FUNC_ADD:         break;      case GL_MIN:      case GL_MAX:         if (!ctx->Extensions.EXT_blend_minmax &&             !ctx->Extensions.ARB_imaging) {            return GL_FALSE;         }         break;      /* glBlendEquationSeparate cannot take GL_LOGIC_OP as a parameter.       */      case GL_LOGIC_OP:         if (!ctx->Extensions.EXT_blend_logic_op || is_separate) {            return GL_FALSE;         }         break;      case GL_FUNC_SUBTRACT:      case GL_FUNC_REVERSE_SUBTRACT:         if (!ctx->Extensions.EXT_blend_subtract &&             !ctx->Extensions.ARB_imaging) {            return GL_FALSE;         }         break;      default:         return GL_FALSE;   }   return GL_TRUE;}/* This is really an extension function! */void GLAPIENTRY_mesa_BlendEquation( GLenum mode ){   GET_CURRENT_CONTEXT(ctx);   ASSERT_OUTSIDE_BEGIN_END(ctx);   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))      _mesa_debug(ctx, "glBlendEquation %s\n",                  _mesa_lookup_enum_by_nr(mode));   if ( ! _mesa_validate_blend_equation( ctx, mode, GL_FALSE ) ) {      _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation");      return;   }   if ( (ctx->Color.BlendEquationRGB == mode) &&	(ctx->Color.BlendEquationA == mode) )      return;   FLUSH_VERTICES(ctx, _NEW_COLOR);   ctx->Color.BlendEquationRGB = mode;   ctx->Color.BlendEquationA = mode;   if (ctx->Driver.BlendEquationSeparate)      (*ctx->Driver.BlendEquationSeparate)( ctx, mode, mode );}void GLAPIENTRY_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA ){   GET_CURRENT_CONTEXT(ctx);   ASSERT_OUTSIDE_BEGIN_END(ctx);   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))      _mesa_debug(ctx, "glBlendEquationSeparateEXT %s %s\n",                  _mesa_lookup_enum_by_nr(modeRGB),                  _mesa_lookup_enum_by_nr(modeA));   if ( (modeRGB != modeA) && !ctx->Extensions.EXT_blend_equation_separate ) {      _mesa_error(ctx, GL_INVALID_OPERATION,		  "glBlendEquationSeparateEXT not supported by driver");      return;   }   if ( ! _mesa_validate_blend_equation( ctx, modeRGB, GL_TRUE ) ) {      _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeRGB)");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -