public void RenderEffect() { if (effect == null) { return; } int curTex = 0; if (effCount % 2 == 0) { GL.ReadBuffer(ReadBufferMode.ColorAttachment0); GL.DrawBuffer(DrawBufferMode.ColorAttachment1); curTex = 0; } else { GL.ReadBuffer(ReadBufferMode.ColorAttachment1); GL.DrawBuffer(DrawBufferMode.ColorAttachment0); curTex = 1; } effect.UseProgram(); destinationFbo.ColorTextures[curTex].DrawFullScreen(0, 0); PostEffect.effCount++; }
/// <summary> /// renderoi worldin valosta päin (pelkän depthin) /// </summary> public static void SetupShadows(Renderable world, int lightNo, bool withParticles) { if (UseShadowMapping == false) { return; } if (Light.Lights.Count == 0) { Log.WriteLine("SetupShadows requires at least one light source!", false); return; } GL.Disable(EnableCap.Blend); GL.ColorMask(false, false, false, false); GL.Disable(EnableCap.CullFace); GL.PolygonOffset(1, 1); GL.Enable(EnableCap.PolygonOffsetFill); fbo.BindDepth(); fbo.BindFBO(); fbo.Clear(); // kuvakulma valosta päin GLExt.LoadMatrix(ref Light.Lights[lightNo].OrigOrientationMatrix); GLExt.Translate(-Light.Lights[lightNo].Position.X, -Light.Lights[lightNo].Position.Y, -Light.Lights[lightNo].Position.Z); SetTextureMatrix(); Frustum.CalculateFrustum(); VBO.FastRenderPass = true; depthShader.UseProgram(); world.Render(); if (withParticles) { depthShaderAlphaTest.UseProgram(); Particles.Render(); GLSLShader.UnBindShader(); } VBO.FastRenderPass = false; fbo.UnBindFBO(); GL.Disable(EnableCap.PolygonOffsetFill); GL.Enable(EnableCap.CullFace); GL.ColorMask(true, true, true, true); GLExt.LoadIdentity(); GameClass.NumOfObjects = 0; ShadowMapping.UnBindLightMask(); }
/// <summary> /// renderoi vbo /// </summary> public void Render() { GL.ActiveTexture(TextureUnit.Texture0); if (VBO.FastRenderPass == false) { if (Shader != null) { Shader.UseProgram(); } } if (Settings.UseGL3 == true) { GL.BindVertexArray(vaoID); GL.BindBuffer(BufferTarget.ArrayBuffer, vertexID); GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexID); if (GLSLShader.CurrentShader != null) { GLSLShader.CurrentShader.SetUniforms(); GLSLShader.CurrentShader.SetAttributes(); } GL.DrawElements(BeginMode.Triangles, numOfIndices, DrawElementsType.UnsignedShort, IntPtr.Zero); GL.BindVertexArray(0); return; } else { // gl2 GL.BindBuffer(BufferTarget.ArrayBuffer, vertexID); GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexID); if (GLSLShader.CurrentShader != null) { GLSLShader.CurrentShader.SetUniforms(); GLSLShader.CurrentShader.SetAttributes(); } else { GLSLShader.UnBindShader(); } GL.DrawElements(BeginMode.Triangles, numOfIndices, DrawElementsType.UnsignedShort, IntPtr.Zero); } }
public static void SetDepthProgram() { depthShader.UseProgram(); }