/// <summary> /// Initializes a new instance of the <see cref="CustomCompositor"/> class. /// </summary> /// <param name="uv">The Ultraviolet context.</param> /// <param name="window">The window with which this compositor is associated.</param> public CustomCompositor(UltravioletContext uv, IUltravioletWindow window) : base(uv, window) { rtScene = RenderTarget2D.Create(BufferWidth, BufferHeight); rtSceneColor = RenderBuffer2D.Create(RenderBufferFormat.Color, BufferWidth, BufferHeight); rtScene.Attach(rtSceneColor); rtSceneDepthStencil = RenderBuffer2D.Create(RenderBufferFormat.Depth24Stencil8, BufferWidth, BufferHeight); rtScene.Attach(rtSceneDepthStencil); rtInterface = RenderTarget2D.Create(BufferWidth, BufferHeight); rtInterfaceColor = RenderBuffer2D.Create(RenderBufferFormat.Color, BufferWidth, BufferHeight); rtInterface.Attach(rtInterfaceColor); rtInterfaceDepthStencil = RenderBuffer2D.Create(RenderBufferFormat.Depth24Stencil8, BufferWidth, BufferHeight); rtInterface.Attach(rtInterfaceDepthStencil); rtComposition = RenderTarget2D.Create(BufferWidth, BufferHeight, RenderTargetUsage.PreserveContents); rtCompositionColor = RenderBuffer2D.Create(RenderBufferFormat.Color, BufferWidth, BufferHeight); rtComposition.Attach(rtCompositionColor); rtCompositionDepthStencil = RenderBuffer2D.Create(RenderBufferFormat.Depth24Stencil8, BufferWidth, BufferHeight); rtComposition.Attach(rtCompositionDepthStencil); spriteBatch = SpriteBatch.Create(); }
/// <summary> /// Initializes a new instance of the <see cref="OutOfBandRenderTarget"/> class. /// </summary> /// <param name="uv">The Ultraviolet context.</param> internal OutOfBandRenderTarget(UltravioletContext uv) : base(uv) { renderTarget = RenderTarget2D.Create(1, 1); colorBuffer = RenderBuffer2D.Create(RenderBufferFormat.Color, 1, 1, RenderBufferOptions.None); renderTarget.Attach(colorBuffer); if (uv.GetGraphics().Capabilities.SupportsDepthStencilTextures) { depthBuffer = RenderBuffer2D.Create(RenderBufferFormat.Depth24Stencil8, 1, 1, RenderBufferOptions.WillNotBeSampled); renderTarget.Attach(depthBuffer); } else { depthBuffer = RenderBuffer2D.Create(RenderBufferFormat.Depth16, 1, 1, RenderBufferOptions.WillNotBeSampled); renderTarget.Attach(depthBuffer); stencilBuffer = RenderBuffer2D.Create(RenderBufferFormat.Stencil8, 1, 1, RenderBufferOptions.WillNotBeSampled); renderTarget.Attach(stencilBuffer); } }
/// <inheritdoc/> protected override void OnLoadingContent() { var window = Ultraviolet.GetPlatform().Windows.GetPrimary(); if (!headless) { // HACK: AMD drivers produce weird rasterization artifacts when rendering // to a NPOT render buffer??? So we have to fix it with this stupid hack??? var width = MathUtil.FindNextPowerOfTwo(window.DrawableSize.Width); var height = MathUtil.FindNextPowerOfTwo(window.DrawableSize.Height); rtargetColorBuffer = RenderBuffer2D.Create(RenderBufferFormat.Color, width, height); rtargetDepthStencilBuffer = RenderBuffer2D.Create(RenderBufferFormat.Depth24Stencil8, width, height); rtarget = RenderTarget2D.Create(width, height); rtarget.Attach(rtargetColorBuffer); rtarget.Attach(rtargetDepthStencilBuffer); } if (loader != null) { content = ContentManager.Create("Content"); loader(content); } base.OnLoadingContent(); }