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

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions

# MSamplerState Class Reference
OpenMayaRender - API module for rendering

Search for all occurrences

## Detailed Description

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.

`#include <MStateManager.h>`

List of all members.

## 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.
void * | resourceHandle () const
| This method allows access to the draw API dependent handle for a sampler state.
## Static Public Member Functions
static const char * | className ()
| Returns the name of this class.

## Member Enumeration Documentation

enum TextureFilter

Search for all occurrences

Indicates how to filter a texture sample.

Enumerator:

  kMinMagMipPoint | Use point sampling for minification, magnification, and mip-level sampling. Search for all occurrences
  kMinMagPoint_MipLinear | Use point sampling for minification and magnification; use linear interpolation for mip-level sampling. Search for all occurrences
  kMinPoint_MagLinear_MipPoint | Use point sampling for minification; use linear interpolation for magnification; use point sampling for mip-level sampling. Search for all occurrences
  kMinPoint_MagMipLinear | Use point sampling for minification; use linear interpolation for magnification and mip-level sampling. Search for all occurrences
  kMinLinear_MagMipPoint | Use linear interpolation for minification; use point sampling for magnification and mip-level sampling. Search for all occurrences
  kMinLinear_MagPoint_MipLinear | Use linear interpolation for minification; use point sampling for magnification; use linear interpolation for mip-level sampling. Search for all occurrences
  kMinMagLinear_MipPoint | Use linear interpolation for minification and magnification; use point sampling for mip-level sampling. Search for all occurrences
  kMinMagMipLinear | Use linear interpolation for minification, magnification, and mip-level sampling. Search for all occurrences
  kAnisotropic | Use anisotropic filtering for minification, magnification, and mip-level sampling. Search for all occurrences

enum TextureAddress

Search for all occurrences

Indicates how to handle texture addresses beyond the canonical (0..1, 0..1) range.

Enumerator:

  kTexWrap | Wrap addresses beyond the [0,1] tile back into the [0.1] range, repeating the texture over the surface. Search for all occurrences
  kTexMirror | Similar to wrap, but with odd tiles mirrored in u and v. Search for all occurrences
  kTexClamp | Clamp address in the [0, 1] range. Extends edge pixels beyond range. Search for all occurrences
  kTexBorder | Clamp samples out of [0, 1] range to border color. Search for all occurrences

## Member Function Documentation

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

Search for all occurrences

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

Parameters:

  [out] | ReturnStatus | return status

Returns:
  A reference to the sampler 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 sampler state.

This handle is owned by the MSamplerState 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 MSamplerState 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.

MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState
MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState MSamplerState