Exemple #1
0
        public float[] ReadAttachment(FrameBufferAttachment attachment)
        {
            var data = new float[Width * Height * (attachment == FrameBufferAttachment.Depth ? 1 : 4)];

            GL.ReadPixels(0, 0, Width, Height, attachment == FrameBufferAttachment.Depth ? PixelFormat.DepthComponent : PixelFormat.Rgba, PixelType.Float, data);
            return(data);
        }
 public FrameBuffer()
     : base(AllocateId())
 {
     FrameBufferAttachment[] color = new FrameBufferAttachment[Device.GetInt32(GetPName.MaxColorAttachments)];
     for (int index = 0; index < color.Length; index++)
         color[index] = new FrameBufferAttachment(this, FramebufferAttachment.ColorAttachment0 + index);
     this.color = new FrameBufferAttachmentCollection(color);
     this.depth = new FrameBufferAttachment(this, (FramebufferAttachment)FramebufferAttachment.DepthAttachment);
     this.stencil = new FrameBufferAttachment(this, (FramebufferAttachment)FramebufferAttachment.StencilAttachment);
 }
Exemple #3
0
        internal FrameBufferAttachment CreateAttachment(string AttachmentLookupID, Format format, ImageViewType view2D, Image image, ImageAspectFlags color, uint levelCount, uint layercount)
        {
            myImage = image;
            if (Initialized)
            {
                throw new Exception("Attempted to add attachment to initialized Framebuffer!");
            }
            if (myAttachments.ContainsKey(AttachmentLookupID))
            {
                throw new Exception("A framebuffer attachment with ID: " + AttachmentLookupID + " was added to frame buffer twice.");
            }
            var myAttache = new FrameBufferAttachment(AttachmentLookupID, image, view2D, format, color, levelCount, layercount);

            myAttachments[AttachmentLookupID] = myAttache;
            return(myAttache);
        }