protected override void OnRenderFrame(FrameEventArgs E) { MakeCurrent(); OpenGLGC.CollectAll(); SetShaderUniforms(); GL.Disable(EnableCap.ScissorTest); GL.Disable(EnableCap.StencilTest); GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); //GL.Disable(EnableCap.CullFace); GL.FrontFace(FrontFaceDirection.Ccw); GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Lequal); GL.Viewport(0, 0, Width, Height); GL.ClearColor(0.01f, 0.01f, 0.01f, 1.0f); ClearBuffers(); // World geometry GFrameBuffer.Bind(); { ClearBuffers(); OnRenderClient?.Invoke((float)E.Time); } GFrameBuffer.Unbind(); // Screen quad { Camera CurCam = Camera.GetCurrent(); Camera.Push(UICam); GL.FrontFace(FrontFaceDirection.Cw); SSAOFrameBuffer.Bind(); //GL.Viewport(0, 0, Width / 2, Height / 2); { SSAOShader.SetUniform("MatProjection2", CurCam.Projection, false); ScreenQuad.Draw(SSAOShader); } //GL.Viewport(0, 0, Width, Height); SSAOFrameBuffer.Unbind(); float T = (float)SWatch.ElapsedMilliseconds / 1000; PostShader.SetUniform("LightDir[0]", new Vector3((float)Math.Cos(T), 1, (float)Math.Sin(T)).Normalized(), false); PostShader.SetUniform("MatTranslation2", CurCam.Translation, false); PostShader.SetUniform("MatRotation2", CurCam.RotationMat, false); PostShader.SetUniform("MatProjection2", CurCam.Projection, false); ScreenQuad.Draw(PostShader); Camera.Pop(); CheckError(); } // UI OnRenderUI?.Invoke((float)E.Time); SwapBuffers(); }
public override RenderTexture Bind() { GL.GetInteger(GetPName.Viewport, OldViewport); RTStack.Push(this); if (IsDoubleBuffered) { OldBuffer.LoadData(NewBuffer); } FrameBuffer.Bind(); GL.Viewport(0, 0, Width, Height); return(this); }