Table of Contents

Class SamplerState

Namespace
Microsoft.Xna.Framework.Graphics
Assembly
MonoGame.Framework.dll

Contains sampler state, which determines how to sample texture data.

public class SamplerState : GraphicsResource, IDisposable
Inheritance
SamplerState
Implements
Inherited Members

Constructors

SamplerState()

Creates a new instance of the SamplerState class with default values equivalent to LinearWrap.

public SamplerState()

Fields

AnisotropicClamp

Contains default state for anisotropic filtering and texture coordinate clamping.

public static readonly SamplerState AnisotropicClamp

Field Value

SamplerState

Remarks

This built-in state object has the following settings:

Filter = TextureFilter.Anisotropic,
AddressU = TextureAddressMode.Clamp,
AddressV = TextureAddressMode.Clamp,
AddressW = TextureAddressMode.Clamp,

AnisotropicWrap

Contains default state for anisotropic filtering and texture coordinate wrapping.

public static readonly SamplerState AnisotropicWrap

Field Value

SamplerState

Remarks

This built-in state object has the following settings:

Filter = TextureFilter.Anisotropic,
AddressU = TextureAddressMode.Wrap,
AddressV = TextureAddressMode.Wrap,
AddressW = TextureAddressMode.Wrap,

LinearClamp

Contains default state for linear filtering and texture coordinate clamping.

public static readonly SamplerState LinearClamp

Field Value

SamplerState

Remarks

This built-in state object has the following settings:

Filter = TextureFilter.Linear,
AddressU = TextureAddressMode.Clamp,
AddressV = TextureAddressMode.Clamp,
AddressW = TextureAddressMode.Clamp,

LinearWrap

Contains default state for linear filtering and texture coordinate wrapping.

public static readonly SamplerState LinearWrap

Field Value

SamplerState

Remarks

This built-in state object has the following settings:

Filter = TextureFilter.Linear,
AddressU = TextureAddressMode.Wrap,
AddressV = TextureAddressMode.Wrap,
AddressW = TextureAddressMode.Wrap,

PointClamp

Contains default state for point filtering and texture coordinate clamping.

public static readonly SamplerState PointClamp

Field Value

SamplerState

Remarks

This built-in state object has the following settings:

Filter = TextureFilter.Point,
AddressU = TextureAddressMode.Clamp,
AddressV = TextureAddressMode.Clamp,
AddressW = TextureAddressMode.Clamp,

PointWrap

Contains default state for point filtering and texture coordinate wrapping.

public static readonly SamplerState PointWrap

Field Value

SamplerState

Remarks

This built-in state object has the following settings:

Filter = TextureFilter.Point,
AddressU = TextureAddressMode.Wrap,
AddressV = TextureAddressMode.Wrap,
AddressW = TextureAddressMode.Wrap,

Properties

AddressU

Gets or sets the texture-address mode for the u-coordinate.

public TextureAddressMode AddressU { get; set; }

Property Value

TextureAddressMode

AddressV

Gets or sets the texture-address mode for the v-coordinate.

public TextureAddressMode AddressV { get; set; }

Property Value

TextureAddressMode

AddressW

Gets or sets the texture-address mode for the w-coordinate.

public TextureAddressMode AddressW { get; set; }

Property Value

TextureAddressMode

BorderColor

Gets or sets the color to use for texels outside of range, when Border is used.

public Color BorderColor { get; set; }

Property Value

Color

ComparisonFunction

When using comparison sampling, also set FilterMode to Comparison.

public CompareFunction ComparisonFunction { get; set; }

Property Value

CompareFunction

Filter

Gets or sets the type of filtering during sampling.

public TextureFilter Filter { get; set; }

Property Value

TextureFilter

FilterMode

Gets or sets filtering mode for texture samplers.

public TextureFilterMode FilterMode { get; set; }

Property Value

TextureFilterMode

MaxAnisotropy

Gets or sets the maximum anisotropy. The default value is 4.

public int MaxAnisotropy { get; set; }

Property Value

int

Remarks

Use anisotropic filtering to reduce blur and aliasing effects when texturing a surface that will be viewed at an extreme viewing angle.

MaxMipLevel

Gets or sets the level of detail (LOD) index of the largest map to use.

public int MaxMipLevel { get; set; }

Property Value

int

The maximum LOD, which ranges from 0 to n-1, where n is the index of the largest map.

MipMapLevelOfDetailBias

Gets or sets the mipmap LOD bias. The default value is 0.

A negative value indicates a larger mipmap level; a positive value indicates a smaller mipmap level.
public float MipMapLevelOfDetailBias { get; set; }

Property Value

float

Remarks

Mipmap LOD bias offsets the mipmap level from which a texture is sampled (the result is computed using trilinear texturing between the nearest two levels).

Methods

Dispose(bool)

protected override void Dispose(bool disposing)

Parameters

disposing bool