/// <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();

            DefaultViewport = new Viewport(0, 0, Description.BackBufferWidth, Description.BackBufferHeight);

            // Creates a default DepthStencilBuffer.
            CreateDepthStencilBuffer();
        }
 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);
 }
 public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters)
 {
     device.InitDefaultRenderTarget(presentationParameters);
     backBuffer         = device.DefaultRenderTarget;
     DepthStencilBuffer = device.windowProvidedDepthTexture;
 }
Beispiel #4
0
 /// <summary>
 /// Initializes this instance.
 /// </summary>
 /// <param name="adapter">The graphics adapter.</param>
 /// <param name="profile">The graphics profile.</param>
 protected void Initialize(GraphicsAdapter adapter, GraphicsProfile profile, PresentationParameters presentationParameters, object windowHandle)
 {
     throw new NotImplementedException();
 }