Exemplo n.º 1
0
        public static ITexture CopyTexture(ITexture src)
        {
            ITexture dst = PoolProxy.GetResource <ObtainRenderTargetPool, RenderTargetAllocationPolicy, TextureParameters, ITexture>(src.GetTextureParameters());

            var renderTarget = GL.GenFramebuffer();

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, renderTarget);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, src.GetTextureParameters().TexTarget, dst.GetTextureDescriptor(), 0);
            GL.DrawBuffer(DrawBufferMode.ColorAttachment0);

            //GL.Disable(EnableCap.DepthTest);
            GL.Viewport(0, 0, src.GetTextureRezolution().X, src.GetTextureRezolution().Y);
            // start copy texture to render target
            copyShader.startProgram();
            src.BindTexture(TextureUnit.Texture0);
            copyShader.SetUniformValues(0);
            var quadBuffer = ScreenQuad.GetScreenQuadBuffer();

            quadBuffer.RenderVAO(PrimitiveType.Triangles);
            copyShader.stopProgram();
            GL.Enable(EnableCap.DepthTest);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
            GL.DeleteFramebuffer(renderTarget);

            return(dst);
        }
Exemplo n.º 2
0
        public static void ResolvePostProcessResultToDefaultFramebuffer(ITexture frameTexture, ITexture postProcessResultTexture, Point actualScreenRezolution)
        {
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
            GL.Clear(ClearBufferMask.DepthBufferBit | ClearBufferMask.ColorBufferBit | ClearBufferMask.StencilBufferBit);
            GL.Viewport(0, 0, actualScreenRezolution.X, actualScreenRezolution.Y);

            //GL.Disable(EnableCap.DepthTest);
            resolvePostProcessShader.startProgram();

            frameTexture.BindTexture(TextureUnit.Texture0);
            postProcessResultTexture.BindTexture(TextureUnit.Texture1);
            resolvePostProcessShader.setPostProcessResultSampler(1);
            var quadBuffer = ScreenQuad.GetScreenQuadBuffer();

            quadBuffer.RenderVAO(PrimitiveType.Triangles);
            resolvePostProcessShader.stopProgram();
            GL.Enable(EnableCap.DepthTest);
        }