예제 #1
0
        public void AttachRenderbuffer(FramebufferAttachmentPoint attachmentPoint, IRenderbuffer renderbuffer)
        {
            var newDesc = new FramebufferAttachmentDescription
            {
                Type         = FramebufferAttachmentType.Renderbufer,
                Renderbuffer = renderbuffer,
            };

            if (IsRedundant(attachmentPoint, ref newDesc))
            {
                return;
            }
            var framebufferTarget = context.Bindings.Framebuffers.EditingTarget;

            context.Bindings.Framebuffers.ByTarget(framebufferTarget).Set(this);
            GL.FramebufferRenderbuffer((int)framebufferTarget, (int)attachmentPoint, (int)RenderbufferTarget.Renderbuffer, renderbuffer.Handle);
            UpdateStoredDescription(attachmentPoint, ref newDesc);
        }
예제 #2
0
        public void AttachTextureAsLayeredImage(FramebufferAttachmentPoint attachmentPoint, ITexture2DMultisampleArray texture)
        {
            var newDesc = new FramebufferAttachmentDescription
            {
                Type          = FramebufferAttachmentType.TextureLayers,
                TextureTarget = TextureTarget.Texture2DMultisampleArray,
                Texture       = texture
            };

            if (IsRedundant(attachmentPoint, ref newDesc))
            {
                return;
            }
            var framebufferTarget = context.Bindings.Framebuffers.EditingTarget;

            context.Bindings.Framebuffers.ByTarget(framebufferTarget).Set(this);
            //gl.FramebufferTexture((int)framebufferTarget, (int)attachmentPoint, texture.Handle, 0);
            GL.FramebufferTexture2D((int)framebufferTarget, (int)attachmentPoint, (int)texture.Target, texture.Handle, 0);
            UpdateStoredDescription(attachmentPoint, ref newDesc);
        }
예제 #3
0
 private void UpdateStoredDescription(FramebufferAttachmentPoint attachmentPoint, ref FramebufferAttachmentDescription newDesc)
 {
     if ((FramebufferAttachmentPoint.Color0 <= attachmentPoint && attachmentPoint <= FramebufferAttachmentPoint.Color15))
     {
         int index = attachmentPoint - FramebufferAttachmentPoint.Color0;
         colorAttachments[index] = newDesc;
         if (index >= enabledColorAttachmentsRange)
         {
             enabledColorAttachmentsRange = index + 1;
         }
     }
     else if (attachmentPoint == FramebufferAttachmentPoint.DepthStencil || attachmentPoint == FramebufferAttachmentPoint.Depth)
     {
         depthAttachment = newDesc;
     }
     else if (attachmentPoint == FramebufferAttachmentPoint.DepthStencil || attachmentPoint == FramebufferAttachmentPoint.Stencil)
     {
         stencilAttachment = newDesc;
     }
 }
예제 #4
0
        public void AttachTextureAsLayeredImage(FramebufferAttachmentPoint attachmentPoint, ITextureCubemap texture, int level)
        {
            var newDesc = new FramebufferAttachmentDescription
            {
                Type          = FramebufferAttachmentType.TextureLayers,
                TextureTarget = TextureTarget.TextureCubeMap,
                Texture       = texture,
                Level         = level
            };

            if (IsRedundant(attachmentPoint, ref newDesc))
            {
                return;
            }
            var framebufferTarget = context.Bindings.Framebuffers.EditingTarget;

            context.Bindings.Framebuffers.ByTarget(framebufferTarget).Set(this);
            //gl.FramebufferTexture(ft, fa, d.Texture.Handle, d.Level);
            GL.FramebufferTexture2D((int)framebufferTarget, (int)attachmentPoint, (int)texture.Target, texture.Handle, level);
            UpdateStoredDescription(attachmentPoint, ref newDesc);
        }
예제 #5
0
        public void AttachTextureImage(FramebufferAttachmentPoint attachmentPoint, ITextureCubemap texture, int level, CubemapFace cubemapFace)
        {
            var newDesc = new FramebufferAttachmentDescription
            {
                Type          = FramebufferAttachmentType.Texture,
                TextureTarget = TextureTarget.TextureCubeMap,
                Texture       = texture,
                Level         = level,
                Layer         = cubemapFace - CubemapFace.PositiveX
            };

            if (IsRedundant(attachmentPoint, ref newDesc))
            {
                return;
            }
            var framebufferTarget = context.Bindings.Framebuffers.EditingTarget;

            context.Bindings.Framebuffers.ByTarget(framebufferTarget).Set(this);
            GL.FramebufferTexture2D((int)framebufferTarget, (int)attachmentPoint, (int)cubemapFace, texture.Handle, level);
            UpdateStoredDescription(attachmentPoint, ref newDesc);
        }
예제 #6
0
        public void AttachTextureImage(FramebufferAttachmentPoint attachmentPoint, ITexture3D texture, int level, int depthLayer)
        {
            var newDesc = new FramebufferAttachmentDescription
            {
                Type          = FramebufferAttachmentType.Texture,
                TextureTarget = TextureTarget.Texture3D,
                Texture       = texture,
                Level         = level,
                Layer         = depthLayer
            };

            if (IsRedundant(attachmentPoint, ref newDesc))
            {
                return;
            }
            var framebufferTarget = context.Bindings.Framebuffers.EditingTarget;

            context.Bindings.Framebuffers.ByTarget(framebufferTarget).Set(this);
            GL.FramebufferTextureLayer((int)framebufferTarget, (int)attachmentPoint, texture.Handle, level, depthLayer);
            UpdateStoredDescription(attachmentPoint, ref newDesc);
        }
예제 #7
0
        public static bool Equals(ref FramebufferAttachmentDescription a1, ref FramebufferAttachmentDescription a2)
        {
            switch (a1.Type)
            {
            case FramebufferAttachmentType.Disabled:
                return(a2.Type == FramebufferAttachmentType.Disabled);

            case FramebufferAttachmentType.Renderbufer:
                return(a2.Type == FramebufferAttachmentType.Renderbufer &&
                       a1.Renderbuffer == a2.Renderbuffer);

            case FramebufferAttachmentType.Texture:
            case FramebufferAttachmentType.TextureLayers:
                return(a1.Type == a2.Type &&
                       a1.TextureTarget == a2.TextureTarget &&
                       a1.Texture == a2.Texture &&
                       a1.Level == a2.Level &&
                       a1.Layer == a2.Layer);

            default: throw new ArgumentOutOfRangeException("a1.Type");
            }
        }
예제 #8
0
        private bool IsRedundant(FramebufferAttachmentPoint attachmentPoint, ref FramebufferAttachmentDescription newDesc)
        {
            switch (attachmentPoint)
            {
            case FramebufferAttachmentPoint.Color0:
            case FramebufferAttachmentPoint.Color1:
            case FramebufferAttachmentPoint.Color2:
            case FramebufferAttachmentPoint.Color3:
            case FramebufferAttachmentPoint.Color4:
            case FramebufferAttachmentPoint.Color5:
            case FramebufferAttachmentPoint.Color6:
            case FramebufferAttachmentPoint.Color7:
            case FramebufferAttachmentPoint.Color8:
            case FramebufferAttachmentPoint.Color9:
            case FramebufferAttachmentPoint.Color10:
            case FramebufferAttachmentPoint.Color11:
            case FramebufferAttachmentPoint.Color12:
            case FramebufferAttachmentPoint.Color13:
            case FramebufferAttachmentPoint.Color14:
            case FramebufferAttachmentPoint.Color15:
                return(FramebufferAttachmentDescription.Equals(ref newDesc, ref colorAttachments[attachmentPoint - FramebufferAttachmentPoint.Color0]));

            case FramebufferAttachmentPoint.DepthStencil:
                return(FramebufferAttachmentDescription.Equals(ref newDesc, ref depthAttachment) &&
                       FramebufferAttachmentDescription.Equals(ref newDesc, ref stencilAttachment));

            case FramebufferAttachmentPoint.Depth:
                return(FramebufferAttachmentDescription.Equals(ref newDesc, ref depthAttachment));

            case FramebufferAttachmentPoint.Stencil:
                return(FramebufferAttachmentDescription.Equals(ref newDesc, ref stencilAttachment));

            default:
                throw new ArgumentOutOfRangeException("attachmentPoint");
            }
        }