public GLTexture Process(Action <GLShader> Action) { RenderTarget.BindUnbind(() => { GL.glClearStencil(0); GL.glClearDepthf(0f); GL.glClearColor(0, 0, 0, 1); GL.glClear(GL.GL_COLOR_CLEAR_VALUE | GL.GL_DEPTH_CLEAR_VALUE | GL.GL_STENCIL_CLEAR_VALUE); Shader.GetAttribute("a_position").NoWarning().SetData <float>(PositionBuffer, 2); Shader.GetAttribute("a_texcoords").NoWarning().SetData <float>(TexcoordsBuffer, 2); Shader.GetUniform("u_textureSize").NoWarning().Set(new Vector4f(Width, Height, 0, 0)); Shader.GetUniform("u_pixelSize").NoWarning() .Set(new Vector4f(1.0f / Width, 1.0f / Height, 0, 0)); Shader.Draw(GLGeometry.GL_TRIANGLE_STRIP, 4, () => { Action(Shader); }); }); return(RenderTarget.TextureColor); }
/// <summary> /// Copies a RenderTarget from one to another /// </summary> /// <param name="From"></param> /// <param name="To"></param> public static void CopyFromTo(GLRenderTarget From, GLRenderTarget To) { Contract.Assert(From != null); Contract.Assert(To != null); From.BindUnbind(() => { To.TextureColor?.BindUnbind(() => { GL.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA4, 0, 0, From.Width, From.Height, 0); }); To.TextureDepth?.BindUnbind(() => { GL.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_DEPTH_COMPONENT, 0, 0, From.Width, From.Height, 0); }); }); }
/// <summary> /// Copies a RenderTarget from one to another /// </summary> /// <param name="From"></param> /// <param name="To"></param> public static void CopyFromTo(GLRenderTarget From, GLRenderTarget To) { Contract.Assert(From != null); Contract.Assert(To != null); From.BindUnbind(() => { if (To.TextureColor != null) { To.TextureColor.BindUnbind(() => { GL.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA4, 0, 0, From.Width, From.Height, 0); }); } if (To.TextureDepth != null) { To.TextureDepth.BindUnbind(() => { GL.glCopyTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_DEPTH_COMPONENT, 0, 0, From.Width, From.Height, 0); }); } }); }