示例#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();

            WebGL2Framebuffer originalFramebuffer = Current as WebGL2Framebuffer;

            GL.bindFramebuffer(READ_FRAMEBUFFER_Static, id);
            Swaps++;
            GL.bindFramebuffer(DRAW_FRAMEBUFFER_Static, ((WebGL2Framebuffer)target ?? (WebGL2Framebuffer)Default).id);
            Swaps++;

            Graphics.SetViewport(target);
            Graphics.SetScissorTest(target);
            GL.readBuffer(textureAttachment.ToWebGL2());
            GL.blitFramebuffer(0, 0, Width, Height, rect.Left, rect.Bottom, rect.Right, rect.Top, COLOR_BUFFER_BIT, filter.ToWebGL2());
            //GL.blitFramebuffer(new RectangleI(Width, Height), rect, textureAttachment >= 0 ? BufferBit.Colour : DEPTH_BUFFER_BIT, filter.ToWebGL2());

            // Reset Framebuffer
            GL.bindFramebuffer(FRAMEBUFFER, (originalFramebuffer ?? (WebGL2Framebuffer)Default).id);

            Blits++;

            Graphics.State.OnStateChanged.Invoke();
        }
示例#2
0
 internal override Framebuffer CreateDefaultFramebuffer()
 {
     return(WebGL2Framebuffer.CreateDefault());
 }