Esempio n. 1
0
        private static Texture CreateWhiteTexture(GraphicsDevice device)
        {
            const int Size      = 2;
            var       whiteData = new Color[Size * Size];

            for (int i = 0; i < Size * Size; i++)
            {
                whiteData[i] = Color.White;
            }

            return(Texture.New2D(device, Size, Size, PixelFormat.R8G8B8A8_UNorm, whiteData));
        }
Esempio n. 2
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)
            {
                flags |= TextureFlags.ShaderResource;
            }

            var depthTexture = Texture.New2D(GraphicsDevice, Description.BackBufferWidth, Description.BackBufferHeight, Description.DepthStencilFormat, flags);

            DepthStencilBuffer = depthTexture.DisposeBy(this);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates the texture.
        /// </summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="mipmap">if set to <c>true</c> [mipmap].</param>
        /// <param name="dynamic">if set to <c>true</c> [dynamic].</param>
        /// <returns></returns>
        public override TextureBase CreateTexture(int width, int height, bool mipmap, bool dynamic)
        {
            if (width == 0 || height == 0)
            {
                return(null);
            }

            Texture2D native = null;

            if (dynamic)
            {
                native = Texture2D.New2D(GraphicsDevice, width, height, PixelFormat.R8G8B8A8_UNorm, usage: GraphicsResourceUsage.Dynamic);
            }
            else
            {
                native = Texture2D.New2D(GraphicsDevice, width, height, PixelFormat.R8G8B8A8_UNorm);
            }

            XenkoTexture texture = new XenkoTexture(native);

            return(texture);
        }
 public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters)
 {
     device.InitDefaultRenderTarget(presentationParameters);
     backBuffer = Texture.New2D(device, Description.BackBufferWidth, Description.BackBufferHeight, presentationParameters.BackBufferFormat, TextureFlags.RenderTarget | TextureFlags.ShaderResource);
 }