本文整理匯總了C#中Microsoft.Xna.Framework.Graphics.SamplerState.Dispose方法的典型用法代碼示例。如果您正苦於以下問題:C# SamplerState.Dispose方法的具體用法?C# SamplerState.Dispose怎麽用?C# SamplerState.Dispose使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Microsoft.Xna.Framework.Graphics.SamplerState
的用法示例。
在下文中一共展示了SamplerState.Dispose方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Draw
protected void Draw(Scene drawnScene, RenderTarget2D renderTarget)
{
Device.SetRenderTarget(renderTarget);
try
{
Device.Viewport = drawnScene.Viewport;
}
catch (ArgumentException)
{
UpdateSceneViewport(drawnScene);
Device.Viewport = drawnScene.Viewport;
}
annotationOverlayEffect.RenderTargetSize = drawnScene.Viewport;
#if DEBUG
if (renderTarget != null)
{
Debug.Assert(renderTarget.Bounds.Width >= drawnScene.Viewport.Width &&
renderTarget.Bounds.Height >= drawnScene.Viewport.Height);
}
#endif
if (DefaultDepthState == null || DefaultDepthState.IsDisposed)
{
DefaultDepthState = new DepthStencilState();
DefaultDepthState.DepthBufferEnable = true;
DefaultDepthState.DepthBufferFunction = CompareFunction.LessEqual;
DefaultDepthState.StencilEnable = false;
DefaultDepthState.DepthBufferWriteEnable = true;
}
Device.DepthStencilState = DefaultDepthState;
if (DefaultBlendState == null || DefaultBlendState.IsDisposed)
{
DefaultBlendState = new BlendState();
DefaultBlendState.AlphaSourceBlend = Blend.SourceAlpha;
DefaultBlendState.AlphaDestinationBlend = Blend.InverseSourceAlpha;
DefaultBlendState.ColorSourceBlend = Blend.SourceAlpha;
DefaultBlendState.ColorDestinationBlend = Blend.InverseSourceAlpha;
}
Device.BlendState = DefaultBlendState;
SamplerState sampleState = Device.SamplerStates[0];
if (sampleState == null || sampleState.IsDisposed ||
(sampleState.AddressU != TextureAddressMode.Clamp || sampleState.AddressV != TextureAddressMode.Clamp))
{
try
{
sampleState = new SamplerState();
sampleState.AddressU = TextureAddressMode.Clamp; //Compatability with Reach
sampleState.AddressV = TextureAddressMode.Clamp;
Device.SamplerStates[0] = sampleState;
}
catch (Exception)
{
if (sampleState != null)
{
sampleState.Dispose();
sampleState = null;
}
}
}
Device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, float.MaxValue, 0);
if (Device.RasterizerState == null ||
Device.RasterizerState.IsDisposed ||
Device.RasterizerState.CullMode != CullMode.None)
{
RasterizerState rState = null;
try
{
rState = new RasterizerState();
rState.CullMode = CullMode.None;
Device.RasterizerState = rState;
}
catch (Exception)
{
if (rState != null)
{
rState.Dispose();
rState = null;
}
}
}
Matrix worldViewProj = drawnScene.WorldViewProj;
//Enables some basic effect characteristics, such as vertex coloring and default lighting.
basicEffect.Projection = drawnScene.Projection;
basicEffect.View = drawnScene.Camera.View;
basicEffect.World = drawnScene.World;
//.........這裏部分代碼省略.........