当前位置: 首页>>代码示例>>C#>>正文


C# SamplerState.Dispose方法代码示例

本文整理汇总了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;

//.........这里部分代码省略.........
开发者ID:abordt,项目名称:Viking,代码行数:101,代码来源:ViewerControl.cs


注:本文中的Microsoft.Xna.Framework.Graphics.SamplerState.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。