Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of <see cref="UIBatch"/>.
        /// </summary>
        /// <param name="device">A valid instance of <see cref="GraphicsDevice"/>.</param>
        public UIBatch(GraphicsDevice device)
            : base(device, UIEffect.Bytecode,
                   ResourceBufferInfo.CreateDynamicIndexBufferInfo("UIBatch.VertexIndexBuffers", MaxIndicesCount, MaxVerticesCount),
                   VertexPositionColorTextureSwizzle.Layout)
        {
            // Create the two ui effects
            uiSeparateAlphaEffect = new Effect(GraphicsDevice, UIEffectSeparateAlpha.Bytecode)
            {
                Name = "SeparatedAlphaBatchEffect"
            };

            // Create a 1x1 pixel white texture
            whiteTexture = Texture.New2D(GraphicsDevice, 1, 1, PixelFormat.R8G8B8A8_UNorm, new Byte[] { 255, 255, 255, 255 });
        }
Ejemplo 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.Profile >= GraphicsProfile.Level_10_0)
            {
                flags |= TextureFlags.ShaderResource;
            }

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

            DepthStencilBuffer = depthTexture.KeepAliveBy(this);
        }
        public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters)
        {
            device.InitDefaultRenderTarget(Description);

            backBuffer = Texture.New2D(device, Description.BackBufferWidth, Description.BackBufferHeight, presentationParameters.BackBufferFormat, TextureFlags.RenderTarget | TextureFlags.ShaderResource);
        }