This reference page is linked to from the following overview topics: 2.6 State and State Manager.
Container class for an acquired GPU blend state.
MBlendState wraps an acquired composite GPU blend state. This blend state can be used to set the current GPU blend state using MStateManager::setBlendState(myBlendState).
Instances of MBlendState cannot be created or modified by users. You can read the descriptor for an MBlendState using MBlendState::desc(), but you cannot set or alter the descriptor directly.
MBlendState can only be obtained via MStateManager::acquireBlendState(). To use MStateManager::acquireBlendState(), create and fill an MBlendStateDesc instance with the requested state and pass it to MStateManager::acquireBlendState() which will return the cached unique blend state of that description. If the unique blend state did not previously exist in the cache, it is created.
The information included in the blend state includes alpha to coverage enable, independent blend enable, a global float4 blend factor, and an array of blending descriptors, one for each target.
The advantages of using this class rather than setting blend states explicitly are:
1. Since the states are cached internally, state setting is much faster than setting individual states. 2. Since state is set through the Maya viewport API, Maya can maintain accurate knowledge of the current GPU state, even in the presence of arbitrary plug-ins. This also speeds state setup by reducing redundant state setting and OGL queries. 3. The information is device aware, meaning that it will return the correct results based on the current active device. For example it will return the appropriate values for DirectX versus an OpenGL device.
cgfxShaderNode.h, footPrintNode.cpp, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.
#include <MStateManager.h>
Public Types | |
enum | BlendOperation { kAdd = 0x1, kSubtract = 0x2, kReverseSubtract = 0x3, kMin = 0x4, kMax = 0x5 } |
Blend operations for hardware target blending. More... | |
enum | BlendOption { kZero = 1, kOne = 2, kSourceColor = 3, kInvSourceColor = 4, kSourceAlpha = 5, kInvSourceAlpha = 6, kSourceAlphaSat = 11, kDestinationColor = 9, kInvDestinationColor = 10, kDestinationAlpha = 7, kInvDestinationAlpha = 8, kBothSourceAlpha = 12, kBothInvSourceAlpha = 13, kBlendFactor = 14, kInvBlendFactor = 15 } |
Specifies what value to use as blend factor with an optional pre-operation. More... | |
enum | ChannelMask { kNoChannels = 0, kRedChannel = 0x1, kGreenChannel = 0x2, kBlueChannel = 0x4, kAlphaChannel = 0x8, kRGBChannels = 0x7, kRGBAChannels = 0xf } |
A bitfield that indicates which color components(red, green, blue, alpha) are writable. More... | |
Public Member Functions | |
const MBlendStateDesc & | desc (MStatus *ReturnStatus=NULL) const |
Get the blend state descriptor that was used to create the state object. | |
void * | resourceHandle () const |
This method allows access to the draw API dependent handle for a blend state. | |
Static Public Member Functions | |
static const char * | className () |
Returns the name of this class. | |
Static Public Attributes | |
static const int | kMaxTargets = 8 |
Maximum number of simulatanious render targets. |
enum BlendOperation |
Blend operations for hardware target blending.
enum BlendOption |
Specifies what value to use as blend factor with an optional pre-operation.
enum ChannelMask |
A bitfield that indicates which color components(red, green, blue, alpha) are writable.
const MBlendStateDesc & desc | ( | MStatus * | ReturnStatus = NULL | ) | const |
Get the blend state descriptor that was used to create the state object.
[out] | ReturnStatus | return status |
const char * className | ( | ) | [static] |
void * resourceHandle | ( | ) | const |
This method allows access to the draw API dependent handle for a blend state.
This handle is owned by the MBlendState and is provided to allow access to use as a read-only object.
Modifications should never be performed on this handle.
Any modifications may result in unpredictable stability as the MBlendState no longer has knowledge of it's contents.
For OpenGL, such a handle does not exist and a NULL pointer will be returned.
For DirectX 10 and higher, a pointer to a Direct3D state will be returned.