예제 #1
0
        internal static OpenGLBindings.BlitFilter ToOpenGL(this BlitFilter blitFilter)
        {
            switch (blitFilter)
            {
            case BlitFilter.Nearest:
                return(OpenGLBindings.BlitFilter.Nearest);

            case BlitFilter.Linear:
                return(OpenGLBindings.BlitFilter.Linear);

            default:
                throw new IllegalValueException(typeof(BlitFilter), blitFilter);
            }
        }
예제 #2
0
        internal static double ToWebGL2(this BlitFilter blitFilter)
        {
            switch (blitFilter)
            {
            case BlitFilter.Nearest:
                return(NEAREST);

            case BlitFilter.Linear:
                return(LINEAR);

            default:
                throw new IllegalValueException(typeof(BlitFilter), blitFilter);
            }
        }
예제 #3
0
 public void BlitTextureTo(RenderTarget target, int textureNum, BlitFilter filter, int x, int y)
 {
     BlitTextureTo(target, textureNum, filter, new RectangleI(x, y, Width, Height));
 }
예제 #4
0
 public void BlitTextureTo(Framebuffer target, TextureAttachment textureAttachment, BlitFilter filter, RectangleI rect)
 {
     throw new CKGLException($"WebGL 1.0 does not support blitting framebuffers.");
 }
예제 #5
0
 public void BlitTextureTo(Framebuffer target, TextureAttachment textureAttachment, BlitFilter filter, int x, int y) => BlitTextureTo(target, textureAttachment, filter, new RectangleI(x, y, Width, Height));
예제 #6
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();
        }
예제 #7
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();
        }