Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RenderTarget2D"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="name">The name of this texture.</param>
        /// <param name="description">The description.</param>
        /// <param name="initialize">if set to <c>true</c> [initialize].</param>
        internal RenderTarget(GraphicsDevice device, Texture texture, ViewType viewType, int arraySlize, int mipSlice, PixelFormat viewFormat = PixelFormat.None)
            : base(device)
        {
            texture.AddReferenceInternal();
            Texture     = texture;
            Description = texture.Description;
            resourceId  = texture.ResourceId;

            Width  = Math.Max(1, Description.Width >> mipSlice);
            Height = Math.Max(1, Description.Height >> mipSlice);

            ViewType   = viewType;
            ArraySlice = arraySlize;
            MipLevel   = mipSlice;
            ViewFormat = viewFormat == PixelFormat.None ? Description.Format : viewFormat;
        }
        /// <summary>
        /// Create a RenderTarget from a texture.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="texture">The texture.</param>
        /// <param name="viewType">The view type.</param>
        /// <param name="arraySlice">The index of the array slice.</param>
        /// <param name="mipSlice">The index of the mip slice.</param>
        /// <param name="viewFormat">The pixel format.</param>
        internal RenderTarget(GraphicsDevice device, Texture texture, ViewType viewType, int arraySlice, int mipSlice, PixelFormat viewFormat = PixelFormat.None)
            : base(device)
        {
            _nativeDeviceChild = texture.NativeDeviceChild;
            Description        = texture.Description;

            NativeRenderTargetView = texture.GetRenderTargetView(viewType, arraySlice, mipSlice);

            Width  = Math.Max(1, Description.Width >> mipSlice);
            Height = Math.Max(1, Description.Height >> mipSlice);

            ViewType   = viewType;
            ArraySlice = arraySlice;
            MipLevel   = mipSlice;
            ViewFormat = viewFormat == PixelFormat.None ? Description.Format : viewFormat;

            Texture = texture;
            Texture.AddReferenceInternal();
        }
Exemple #3
0
 protected Texture(GraphicsDevice device, Texture parentTexture, ViewType viewType, int viewArraySlice, int viewMipLevel, PixelFormat viewFormat = PixelFormat.None)
     : this(device, parentTexture.Description, viewType, viewArraySlice, viewMipLevel, viewFormat)
 {
     ParentTexture = parentTexture;
     ParentTexture.AddReferenceInternal();
 }