GA_blendFuncType
Declaration
typedef enum {
gaBlendNone,
gaBlendZero,
gaBlendOne,
gaBlendSrcColor,
gaBlendOneMinusSrcColor,
gaBlendSrcAlpha,
gaBlendOneMinusSrcAlpha,
gaBlendDstAlpha,
gaBlendOneMinusDstAlpha,
gaBlendDstColor,
gaBlendOneMinusDstColor,
gaBlendSrcAlphaSaturate,
gaBlendConstantColor,
gaBlendOneMinusConstantColor,
gaBlendConstantAlpha,
gaBlendOneMinusConstantAlpha,
gaBlendSrcAlphaFast,
gaBlendConstantAlphaFast
} GA_blendFuncType
Prototype In
snap/graphics.h
Description
Flags for 2D alpha blending functions supported by the SNAP Graphics drivers. The values in here define the the alpha blending functions passed to the srcBlendFunc and dstBlendFunc parameters ofo the SetBlendFunc function. Essentially the blend function defines how to combine the source and destination pixel color together to get the resulting destination color during rendering. The formula used for this is defined as:
DstColor = SrcColor * SrcFunc + DstColor * DstFunc;
If the source alpha blending function is set to gaBlendConstantAlpha, the SrcFunc above becomes:
SrcFunc = ConstAlpha
If the destination alpha blending function is set to gaBlendOneMinusDstAlpha then DstFunc above becomes:
DstFunc = (1-DstAlpha)
and the final equation becomes (note that each color channel is multiplied individually):
DstColor = SrcColor * ConstAlpha + DstColor * (1-DstAlpha)
Although the above is a completely contrived example, it does illustrate how the functions defined below combine to allow you to build complex and interesting blending functions. For simple source alpha transparency, the following formula would usually be used:
DstColor = SrcColor * SrcAlpha + DstColor * (1-SrcAlpha)
If you wish to use this type of blending and you do not care about the resulting alpha channel information, you can set the optimised gaBlendSrcAlphaFast blending mode. If you set both the source and destination blending modes to this value, the above formula will be used but an optimised fast path will be taken internally to make this run as fast as possible. For normal blending operations this will be much faster than setting the above formula manually. If however you need the destination alpha to be preserved, you will need to use the slower method instead.
For simple constant alpha transparency, the following formula would usually be used:
DstColor = SrcColor * ConstantAlpha + DstColor * (1-ConstantAlpha)
If you wish to use this type of blending and you do not care about the resulting alpha channel information, you can set the optimised gaBlendConstantAlphaFast blending mode. If you set both the source and destination blending modes to this value, the above formula will be used but an optimised fast path will be taken internally to make this run as fast as possible. For normal blending operations this will be much faster than setting the above formula manually. If however you need the destination alpha to be preserved, you will need to use the slower method instead.
Note: All the above equations assume the color values and alpha values are in the range of 0 through 1 in floating point. In reality all blending is done with integer color and alpha components in the range of 0 to 255, when a value of 255 corresponds to a value of 1.0 in the above equations.
Note: The constant color value set by a call to SetForeColor, and the constant alpha value set by a call to SetAlphaValue.
Note: Setting a blending function that uses the destination alpha components is only supported if the framebuffer currently supports destination alpha. Likewise setting a blending function that uses source alpha components is only supported if the framebuffer or incoming bitmap data contains an alpha channel. The results are undefined if these conditiions are not met.
Note: Enabling source or destination alpha blending overrides the setting of the current mix mode. Logical mix modes and blending cannot be used at the same time.
Members
gaBlendNone |
No alpha blending |
gaBlendZero |
Blend factor is always zero |
gaBlendOne |
Blend factor is always one |
gaBlendSrcColor |
Blend factor is source color |
gaBlendOneMinusSrcColor |
Blend factor is 1-source color |
gaBlendSrcAlpha |
Blend factor is source alpha |
gaBlendOneMinusSrcAlpha |
Blend factor is 1-source alpha |
gaBlendDstAlpha |
Blend factor is destination alpha |
gaBlendOneMinusDstAlpha |
Blend factor is 1-destination alpha |
gaBlendDstColor |
Blend factor is destination color |
gaBlendOneMinusDstColor |
Blend factor is 1-destination color |
gaBlendSrcAlphaSaturate |
Blend factor is src alpha saturation |
gaBlendConstantColor |
Blend factor is a constant color |
gaBlendOneMinusConstantColor |
Blend factor is 1-constant color |
gaBlendConstantAlpha |
Blend factor is constant alpha |
gaBlendOneMinusConstantAlpha |
Blend factor is 1-constant alpha |
gaBlendSrcAlphaFast |
Common case of optimised src alpha |
gaBlendConstantAlphaFast |
Common case of optimised constant alpha |
Copyright © 2002 SciTech Software, Inc. Visit our web site at http://www.scitechsoft.com