本文整理汇总了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;
//.........这里部分代码省略.........