Example #1
0
        protected override void Destroy()
        {
            DestroyPlatformDevice();

            // Notify listeners
            if (Disposing != null)
            {
                Disposing(this, EventArgs.Empty);
            }

            SamplerStates.Dispose();
            BlendStates.Dispose();
            RasterizerStates.Dispose();
            if (DepthStencilBuffer != null)
            {
                DepthStencilBuffer.Dispose();
            }
            primitiveQuad.Dispose();

            SamplerStates      = null;
            BlendStates        = null;
            RasterizerStates   = null;
            DepthStencilStates = null;

            base.Destroy();
        }
        protected override void ResizeDepthStencilBuffer(int width, int height, PixelFormat format)
        {
            var newTextureDescrition = DepthStencilBuffer.Texture.NativeDescription;

            newTextureDescrition.Width  = width;
            newTextureDescrition.Height = height;

            // Manually update the texture
            DepthStencilBuffer.Texture.OnDestroyed();

            // Force buffer destruction
            // TODO: We should track all user created depth buffer that points to depthStencilBuffer as well (or deny their creation?)
            DepthStencilBuffer.OnDestroyed();

            // Put it in our back buffer texture
            DepthStencilBuffer.Texture.Recreate(newTextureDescrition);

            // Recreate render target
            DepthStencilBuffer.OnRecreate();

            // Update variables
            // TODO: Should be kept readonly, maybe with reflection (ugly) or some other IL trick?
            DepthStencilBuffer.Texture.Width              = width;
            DepthStencilBuffer.Texture.Height             = height;
            DepthStencilBuffer.DescriptionInternal.Width  = width;
            DepthStencilBuffer.DescriptionInternal.Height = height;
        }
        protected override void ResizeDepthStencilBuffer(int width, int height, PixelFormat format)
        {
            var newTextureDescrition = DepthStencilBuffer.Description;

            newTextureDescrition.Width  = width;
            newTextureDescrition.Height = height;

            // Manually update the texture
            DepthStencilBuffer.OnDestroyed();

            // Put it in our back buffer texture
            DepthStencilBuffer.InitializeFrom(newTextureDescrition);
        }
Example #4
0
        /// <summary>
        /// Creates a texture that can be used as a ShaderResource from an existing depth texture.
        /// </summary>
        /// <returns></returns>
        public Texture2D ToDepthTextureCompatible()
        {
            if ((Description.Flags & TextureFlags.DepthStencil) == 0)
            {
                throw new NotSupportedException("This texture is not a valid depth stencil texture");
            }

            var description = Description;

            description.Format = (PixelFormat)DepthStencilBuffer.ComputeShaderResourceFormat((Format)Description.Format);
            if (description.Format == PixelFormat.None)
            {
                throw new NotSupportedException("This depth stencil format is not supported");
            }

            description.Flags = TextureFlags.ShaderResource;
            return(New(GraphicsDevice, description));
        }
Example #5
0
 /// <summary>
 /// Sets a new depth stencil buffer and multiple render targets to this GraphicsDevice.
 /// </summary>
 /// <param name="depthStencilBuffer">The depth stencil buffer.</param>
 /// <param name="renderTargets">The render targets.</param>
 public void SetDepthAndRenderTargets(DepthStencilBuffer depthStencilBuffer,
                                      params RenderTarget[] renderTargets)
 {
     throw new NotImplementedException();
 }
Example #6
0
 /// <summary>
 /// Clears a depth stencil buffer.
 /// </summary>
 /// <param name="depthStencilBuffer">The depth stencil buffer.</param>
 /// <param name="options">Options for clearing a buffer.</param>
 /// <param name="depth">Set this depth value for the Depth buffer.</param>
 /// <param name="stencil">Set this stencil value for the Stencil buffer.</param>
 public void Clear(DepthStencilBuffer depthStencilBuffer, DepthStencilClearOptions options, float depth = 1, byte stencil = 0)
 {
     throw new NotImplementedException();
 }
Example #7
0
 /// <summary>
 ///     Sets a new depthStencilBuffer to this GraphicsDevice. If there is any RenderTarget already bound, it will be unbinded. See <see cref="Textures+and+render+targets"/> to learn how to use it.
 /// </summary>
 /// <param name="depthStencilBuffer">The depth stencil.</param>
 public void SetRenderTarget(DepthStencilBuffer depthStencilBuffer)
 {
     SetRenderTarget(depthStencilBuffer, null);
 }
 /// <summary>
 /// Sets a new depth stencil buffer and multiple render targets to this GraphicsDevice.
 /// </summary>
 /// <param name="depthStencilBuffer">The depth stencil buffer.</param>
 /// <param name="renderTargets">The render targets.</param>
 public void SetDepthAndRenderTargets(DepthStencilBuffer depthStencilBuffer,
                                       params RenderTarget[] renderTargets)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Clears a depth stencil buffer.
 /// </summary>
 /// <param name="depthStencilBuffer">The depth stencil buffer.</param>
 /// <param name="options">Options for clearing a buffer.</param>
 /// <param name="depth">Set this depth value for the Depth buffer.</param>
 /// <param name="stencil">Set this stencil value for the Stencil buffer.</param>
 public void Clear(DepthStencilBuffer depthStencilBuffer, DepthStencilClearOptions options, float depth = 1, byte stencil = 0)
 {
     throw new NotImplementedException();
 }