Container class for an acquired complete GPU sampler state.
MSamplerState wraps an acquired composite GPU sampler state. This sampler state can be used to set the current GPU sampler state using MStateManager::setSamplerState(myShader, 0, mySamplerState).
Instances of MSamplerState cannot be created or modified by users. You can read the descriptor for an MSamplerState using MSamplerState::desc(), but you cannot set or alter the descriptor directly.
MSamplerState can only be obtained via MStateManager::acquireSamplerState(). To use MStateManager::acquireSamplerState(), create and fill an MSamplerStateDesc instance with the requested state and pass it to MStateManager::acquireSamplerState() which will return the cached unique sampler state of that description. If the unique sampler state did not previously exist in the cache, it is created.
The information included in the sampler state includes texture filter selection, texture address mode selection, mip LOD controls, anisotropy control, and the border color.
Any single given sampler state can be bound to as many GPU sampler stages as needed.
The advantages of using this class rather than setting sampler 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.
#include <MStateManager.h>
Public Types |
|
enum |
TextureFilter { kMinMagMipPoint = 0, kMinMagPoint_MipLinear = 1, kMinPoint_MagLinear_MipPoint = 0x4, kMinPoint_MagMipLinear = 0x5, kMinLinear_MagMipPoint = 0x10, kMinLinear_MagPoint_MipLinear = 0x11, kMinMagLinear_MipPoint = 0x14, kMinMagMipLinear = 0x15, kAnisotropic = 0x55 } |
Indicates how to filter a texture sample. More... |
|
enum | TextureAddress { kTexWrap = 1, kTexMirror = 2, kTexClamp = 3, kTexBorder = 4 } |
Indicates how to handle texture addresses beyond the canonical (0..1, 0..1) range. More... |
|
Public Member Functions |
|
~MSamplerState () | |
Destructor. |
|
const MSamplerStateDesc & | desc (MStatus *ReturnStatus=NULL) const |
Get the sampler state descriptor that was
used to create the state object. |
|
Static Public Member Functions |
|
static const char * | className () |
Returns the name of this class. |
enum TextureFilter |
Indicates how to filter a texture sample.
enum TextureAddress |
Indicates how to handle texture addresses beyond the canonical (0..1, 0..1) range.
const MSamplerStateDesc & desc | ( | MStatus * | ReturnStatus =
NULL |
) | const |
Get the sampler state descriptor that was used to create the state object.
[out] | ReturnStatus | return status |
const char * className | ( | ) | [static] |