Пример #1
0
        /// <summary>
        /// Creates the depth stencil buffer.
        /// </summary>
        protected virtual void CreateDepthStencilBuffer()
        {
            // If no depth stencil buffer, just return
            if (Description.DepthStencilFormat == PixelFormat.None)
            {
                return;
            }

            // Creates the depth stencil buffer.
            var flags = TextureFlags.DepthStencil;

            if (GraphicsDevice.Features.CurrentProfile >= GraphicsProfile.Level_10_0 && Description.MultisampleCount == MultisampleCount.None)
            {
                flags |= TextureFlags.ShaderResource;
            }

            // Create texture description
            var depthTextureDescription = TextureDescription.New2D(Description.BackBufferWidth, Description.BackBufferHeight, Description.DepthStencilFormat, flags);

            depthTextureDescription.MultisampleCount = Description.MultisampleCount;

            var depthTexture = Texture.New(GraphicsDevice, depthTextureDescription);

            DepthStencilBuffer = depthTexture.DisposeBy(this);
        }
Пример #2
0
 /// <summary>
 /// Creates a new 2D <see cref="Texture" />.
 /// </summary>
 /// <param name="device">The <see cref="GraphicsDevice" />.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="mipCount">Number of mipmaps, set to true to have all mipmaps, set to an int &gt;=1 for a particular mipmap count.</param>
 /// <param name="format">Describes the format to use.</param>
 /// <param name="textureData">Texture datas through an array of <see cref="DataBox" /></param>
 /// <param name="textureFlags">true if the texture needs to support unordered read write.</param>
 /// <param name="arraySize">Size of the texture 2D array, default to 1.</param>
 /// <param name="usage">The usage.</param>
 /// <param name="multisampleCount">The multisample count.</param>
 /// <param name="options">The options, e.g. sharing</param>
 /// <returns>
 /// A new instance of 2D <see cref="Texture" /> class.
 /// </returns>
 public static Texture New2D(
     GraphicsDevice device,
     int width,
     int height,
     MipMapCount mipCount,
     PixelFormat format,
     DataBox[] textureData,
     TextureFlags textureFlags         = TextureFlags.ShaderResource,
     int arraySize                     = 1,
     GraphicsResourceUsage usage       = GraphicsResourceUsage.Default,
     MultisampleCount multisampleCount = MultisampleCount.None,
     TextureOptions options            = TextureOptions.None)
 {
     return(new Texture(device).InitializeFrom(TextureDescription.New2D(width, height, mipCount, format, textureFlags, arraySize, usage, multisampleCount, options), textureData));
 }