internal Framebuffer(
            FramebufferAttachmentDescription?depthTargetDesc,
            IReadOnlyList <FramebufferAttachmentDescription> colorTargetDescs)
        {
            if (depthTargetDesc != null)
            {
                FramebufferAttachmentDescription depthAttachment = depthTargetDesc.Value;
                DepthTarget = new FramebufferAttachment(depthAttachment.Target, depthAttachment.ArrayLayer);
            }
            FramebufferAttachment[] colorTargets = new FramebufferAttachment[colorTargetDescs.Count];
            for (int i = 0; i < colorTargets.Length; i++)
            {
                colorTargets[i] = new FramebufferAttachment(colorTargetDescs[i].Target, colorTargetDescs[i].ArrayLayer);
            }

            ColorTargets = colorTargets;

            if (ColorTargets.Count > 0)
            {
                Width  = ColorTargets[0].Target.Width;
                Height = ColorTargets[0].Target.Height;
            }
            else if (DepthTarget != null)
            {
                Width  = DepthTarget.Value.Target.Width;
                Height = DepthTarget.Value.Target.Height;
            }

            OutputDescription = OutputDescription.CreateFromFramebuffer(this);
        }
예제 #2
0
 /// <summary>
 /// Constructs a new <see cref="FramebufferDescription"/>.
 /// </summary>
 /// <param name="depthTarget">The depth texture, which must have been created with
 /// <see cref="TextureUsage.DepthStencil"/> usage flags. May be null.</param>
 /// <param name="colorTargets">An array of color textures, all of which must have been created with
 /// <see cref="TextureUsage.RenderTarget"/> usage flags. May be null or empty.</param>
 public FramebufferDescription(Texture depthTarget, params Texture[] colorTargets)
 {
     if (depthTarget != null)
     {
         DepthTarget = new FramebufferAttachmentDescription(depthTarget, 0);
     }
     else
     {
         DepthTarget = null;
     }
     ColorTargets = new FramebufferAttachmentDescription[colorTargets.Length];
     for (int i = 0; i < colorTargets.Length; i++)
     {
         ColorTargets[i] = new FramebufferAttachmentDescription(colorTargets[i], 0);
     }
 }