Beispiel #1
0
        public void BlitTextureTo(Framebuffer target, TextureAttachment textureAttachment, BlitFilter filter, RectangleI rect)
        {
            if (textureAttachment < 0)
            {
                throw new ArgumentOutOfRangeException($"Can't blit a depth texture.");
            }

            Graphics.State.OnStateChanging.Invoke();

            OpenGLFramebuffer originalFramebuffer = Current as OpenGLFramebuffer;

            GL.BindFramebuffer(FramebufferTarget.Read, id);
            Swaps++;
            GL.BindFramebuffer(FramebufferTarget.Draw, ((OpenGLFramebuffer)target ?? (OpenGLFramebuffer)Default).id);
            Swaps++;

            Graphics.SetViewport(target);
            Graphics.SetScissorTest(target);
            GL.ReadBuffer((ReadBuffer)((uint)ReadBuffer.Colour0 + (uint)textureAttachment));
            GL.BlitFramebuffer(new RectangleI(Width, Height), rect, BufferBit.Colour, filter.ToOpenGL());
            //GL.BlitFramebuffer(new RectangleI(Width, Height), rect, textureAttachment >= 0 ? BufferBit.Colour : BufferBit.Depth, filter.ToOpenGL());

            // Reset Framebuffer
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, (originalFramebuffer ?? (OpenGLFramebuffer)Default).id);

            Blits++;

            Graphics.State.OnStateChanged.Invoke();
        }
Beispiel #2
0
 internal override Framebuffer CreateDefaultFramebuffer()
 {
     return(OpenGLFramebuffer.CreateDefault());
 }