VoxelTerrain.RenderTarget.Initialize C# (CSharp) Method

Initialize() public method

Initializes render target object using specified values. If resources have been created earlier then it will dispose them.
public Initialize ( int width, int height, Format format ) : void
width int Texture width.
height int Texture height.
format Format Texture format.
return void
        public void Initialize(int width, int height, Format format)
        {
            this.width = width;
            this.height = height;
            this.format = format;

            Texture2DDescription textureDescription = new Texture2DDescription()
            {
                ArraySize = 1,
                BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource | BindFlags.UnorderedAccess,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = format,
                Height = height,
                MipLevels = 1,
                OptionFlags = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage = ResourceUsage.Default,
                Width = width
            };

            if (texture != null)
                texture.Dispose();
            texture = new Texture2D(graphicsDevice, textureDescription);

            if (renderTargetView != null)
                renderTargetView.Dispose();
            renderTargetView = new RenderTargetView(graphicsDevice, texture);

            if (shaderResourceView != null)
                shaderResourceView.Dispose();
            shaderResourceView = new ShaderResourceView(graphicsDevice, texture);

            if (unorderedAccessView != null)
                unorderedAccessView.Dispose();
            unorderedAccessView = new UnorderedAccessView(graphicsDevice, texture);
        }
    }

Same methods

RenderTarget::Initialize ( ) : void
RenderTarget::Initialize ( int width, int height ) : void