Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GraphicsPresenter" /> class.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="presentationParameters"> </param>
        protected GraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters)
        {
            GraphicsDevice = device;
            var description = presentationParameters.Clone();

            // If we are creating a GraphicsPresenter with
            if (device.Features.HasSRgb && device.ColorSpace == ColorSpace.Linear)
            {
                // If the device support SRgb and ColorSpace is linear, we use automatically a SRgb backbuffer
                if (description.BackBufferFormat == PixelFormat.R8G8B8A8_UNorm)
                {
                    description.BackBufferFormat = PixelFormat.R8G8B8A8_UNorm_SRgb;
                }
                else if (description.BackBufferFormat == PixelFormat.B8G8R8A8_UNorm)
                {
                    description.BackBufferFormat = PixelFormat.B8G8R8A8_UNorm_SRgb;
                }
            }
            else if (!device.Features.HasSRgb)
            {
                // If the device does not support SRgb, but the backbuffer format asked is SRgb, convert it to non SRgb
                if (description.BackBufferFormat == PixelFormat.R8G8B8A8_UNorm_SRgb)
                {
                    description.BackBufferFormat = PixelFormat.R8G8B8A8_UNorm;
                }
                else if (description.BackBufferFormat == PixelFormat.B8G8R8A8_UNorm_SRgb)
                {
                    description.BackBufferFormat = PixelFormat.B8G8R8A8_UNorm;
                }
            }

            Description = description;

            ProcessPresentationParameters();

            // Creates a default DepthStencilBuffer.
            CreateDepthStencilBuffer();
        }
Exemplo n.º 2
0
 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);
 }