Ejemplo n.º 1
0
        /// <summary>
        /// Tries to detach a <see cref="Texture"/> attached to the specified attachment point.
        /// </summary>
        /// <param name="point">The attachment point to check.</param>
        /// <param name="attachment">The detached <see cref="Texture"/> attachment, if the method returned true.</param>
        /// <returns>Returns whether the operation succeeded.</returns>
        public bool TryDetachTexture(FramebufferAttachmentPoint point, out FramebufferTextureAttachment attachment)
        {
            for (int i = 0; i < textureAttachments.Count; i++)
            {
                if (textureAttachments[i].AttachmentPoint == point)
                {
                    GraphicsDevice.Framebuffer = this;
                    GL.FramebufferTexture(FramebufferTarget.Framebuffer, (FramebufferAttachment)point, 0, 0);
                    attachment = textureAttachments[i];
                    textureAttachments.RemoveAt(i);
                    return(true);
                }
            }

            attachment = default;
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a <see cref="Texture"/> attachment from this <see cref="FramebufferObject"/>.
        /// </summary>
        /// <param name="attachmentPoint">The point to look for a texture attachment at.</param>
        /// <param name="attachment">The attachment found.</param>
        /// <returns>Whether a texture attachment was found at the specified attachment point.</returns>
        public bool TryGetTextureAttachment(FramebufferAttachmentPoint attachmentPoint, out FramebufferTextureAttachment attachment)
        {
            for (int i = 0; i < textureAttachments.Count; i++)
            {
                if (textureAttachments[i].AttachmentPoint == attachmentPoint)
                {
                    attachment = textureAttachments[i];
                    return(true);
                }
            }

            attachment = default;
            return(false);
        }