- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes

# MBlendState Class Reference

# OpenMayaRender - API module for rendering

Search for all occurrences

## Detailed Description

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.

Examples:

  cgfxShaderNode.h, hwColorPerVertexShader.cpp, and hwPhongShader.cpp.

`#include <MStateManager.h>`

List of all members.

## 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
| ~MBlendState ()
| Destructor.
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. Search for all occurrences

## Member Enumeration Documentation

enum BlendOperation

Search for all occurrences

Blend operations for hardware target blending.

Enumerator:

  kAdd | Add the source and destination together. Search for all occurrences
  kSubtract | Destination minus source. Search for all occurrences
  kReverseSubtract | Source minus destination. Search for all occurrences
  kMin | The minimum of the source and destination. Search for all occurrences
  kMax | The maximum of the source and destination. Search for all occurrences

enum BlendOption

Search for all occurrences

Specifies what value to use as blend factor with an optional pre-operation.

Enumerator:

  kZero | Blend factor is 0. Search for all occurrences
  kOne | Blend factor is 1. Search for all occurrences
  kSourceColor | Blend factor is source color, src.rgb. Search for all occurrences
  kInvSourceColor | Blend factor is the complement of the source color, (1 - src.rgb). Search for all occurrences
  kSourceAlpha | Blend factor is source alpha, src.a. Search for all occurrences
  kInvSourceAlpha | Blend factor is the complement of the source alpha, (1 - src.a). Search for all occurrences
  kSourceAlphaSat | Blend factor is (f, f, f, 1); where f = saturate(src.a) between 0 and 1. Search for all occurrences
  kDestinationColor | Blend factor is destination color, dst.rgb. Search for all occurrences
  kInvDestinationColor | Blend factor is the complement of the destination color, (1 - dst.rgb). Search for all occurrences
  kDestinationAlpha | Blend factor is destination alpha, dst.a. Search for all occurrences
  kInvDestinationAlpha | Blend factor is the complement of the destination alpha, (1 - dst.a). Search for all occurrences
  kBothSourceAlpha | Source blend factor is src.a, destination blend factor is (1- src.a). Search for all occurrences
  kBothInvSourceAlpha | Source blend factor is (1- src.a), destination blend factor is src.a. Search for all occurrences
  kBlendFactor | Blend factor is the global blend factor specified by users. Search for all occurrences
  kInvBlendFactor | Blend factor is the complement of the global blend factor, (1 - blendFactor.rgba). Search for all occurrences

enum ChannelMask

Search for all occurrences

A bitfield that indicates which color components(red, green, blue, alpha) are writable.

Enumerator:

  kNoChannels | Search for all occurrences
  kRedChannel | Search for all occurrences
  kGreenChannel | Search for all occurrences
  kBlueChannel | Search for all occurrences
  kAlphaChannel | Search for all occurrences
  kRGBChannels | Search for all occurrences
  kRGBAChannels | Search for all occurrences

## Member Function Documentation

const MBlendStateDesc & desc | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

Get the blend state descriptor that was used to create the state object.

Parameters:

  [out] | ReturnStatus | return status

Returns:
  A reference to the blend state descriptor

Status Codes:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

const char * className | ( |  | ) | `[static]`

Search for all occurrences

Returns the name of this class.

Returns:
  Name of this class.

void * resourceHandle | ( |  | ) | const

Search for all occurrences

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.

Returns:
  A pointer (handle) to the state if successful, otherwise NULL.

MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState
MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState MBlendState