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); }
public void WriteDepth(IList <IDrawable> CastingShadowActors, ref Matrix4 ProjectionMatrix) { GL.Viewport(0, 0, m_shadowMapTexture.GetTextureRezolution().X, m_shadowMapTexture.GetTextureRezolution().Y); GL.BindFramebuffer(FramebufferTarget.Framebuffer, m_framebufferHandler); GL.Clear(ClearBufferMask.DepthBufferBit); Matrix4 shadowProjectionMatrix = GetShadowProjectionMatrix(ref ProjectionMatrix); Matrix4 shadowViewMatrix = GetShadowViewMatrix(); m_shadowShader.startProgram(); foreach (IDrawable actor in CastingShadowActors) { if (actor != null) { m_shadowShader.SetUniformValues(actor.GetWorldMatrix(), shadowViewMatrix, shadowProjectionMatrix); actor.GetMeshVao().RenderVAO(PrimitiveType.Triangles); } } m_shadowShader.stopProgram(); GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0); }
public void Bind() { GL.BindFramebuffer(FramebufferTarget.Framebuffer, FramebufferDescriptor); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); GL.Viewport(0, 0, ColorTexture.GetTextureRezolution().X, ColorTexture.GetTextureRezolution().Y); }