/// <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.RootDevice; Description = presentationParameters.Clone(); DefaultViewport = new Viewport(0, 0, Description.BackBufferWidth, Description.BackBufferHeight); // Creates a default DepthStencilBuffer. CreateDepthStencilBuffer(); }
/// <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.RootDevice; 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(); }