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


C# GraphicsDevice.CreateDepthStencilSurface方法代码示例

本文整理汇总了C#中GraphicsDevice.CreateDepthStencilSurface方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice.CreateDepthStencilSurface方法的具体用法?C# GraphicsDevice.CreateDepthStencilSurface怎么用?C# GraphicsDevice.CreateDepthStencilSurface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicsDevice的用法示例。


在下文中一共展示了GraphicsDevice.CreateDepthStencilSurface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WaterSurface

        public WaterSurface(GraphicsDevice device, Camera camera, Vector3 normal, float position, int sizeX, int sizeY)
        {
            Vector3 x;

            Device = device;
            Camera = camera;
            Normal = normal;
            Position = position;
            Plane = new Plane(normal, position);
            NoiseMaker = new NoiseMaker(Device, GridSizeX, GridSizeY);
            PlaneWithinFrustum = false;

            // Set the initial water color
            WaterColor = Color.Aquamarine;

            // Calculate the U and V vectors
            if (Math.Abs(Vector3.Dot(Vector3.UnitX, normal)) < Math.Abs(Vector3.Dot(Vector3.UnitY, normal)))
            {
                x = Vector3.UnitX;
            }
            else
            {
                x = Vector3.UnitY;
            }

            U = x - normal * Vector3.Dot(normal, x);
            U = Vector3.Normalize(U);

            // Get V (cross)
            V = Vector3.Cross(U, normal);

            GridSizeX = sizeX + 1;
            GridSizeY = sizeY + 1;

            SetDisplacementAmplitude(0);

            if (!InitializeBuffers())
            {
                return;
            }

            // Load the textures
            if ((Fresnel = Texture2D.FromFile(Device, "textures/fresnel_water_linear.bmp")) == null)
            {
                return;
            }
            if ((XYNoise = Texture2D.FromFile(Device, "textures/xynoise.png")) == null)
            {
                return;
            }

            // Initialize the reflection and refraction textures, and the depth stencil
            Reflection = new Texture2D(Device, REFLREFRDETAIL, REFLREFRDETAIL, 1, ResourceUsage.RenderTarget,
                SurfaceFormat.Color, ResourcePool.Default);
            Refraction = new Texture2D(Device, REFLREFRDETAIL, REFLREFRDETAIL, 1, ResourceUsage.RenderTarget,
                SurfaceFormat.Color, ResourcePool.Default);
            DepthStencil = Device.CreateDepthStencilSurface(REFLREFRDETAIL, REFLREFRDETAIL, DepthFormat.Depth24Stencil8,
                MultiSampleType.None, 0, true);

            // Load the effect
            CompiledEffect water = Effect.CompileEffectFromFile("shaders/watereffect.fx", null, null,
                CompilerOptions.Debug | CompilerOptions.SkipOptimization, TargetPlatform.Windows);
            if (!water.Success)
            {
                return;
            }
            else
            {
                WaterEffect = new Effect(Device, water.GetShaderCode(), CompilerOptions.None, null);
            }

            Initialized = true;
        }
开发者ID:BackupTheBerlios,项目名称:libsecondlife-svn,代码行数:73,代码来源:WaterSurface.cs


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