Example #1
0
        public override void Setup()
        {
            FXShader.LoadFromString(vs, fs);
            FXShader.SetInt("screenTexture", 0);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

            //GL.PatchParameter(PatchParameterInt.PatchVertices, 3);
            Helper.CheckGLError(this);



            //screen quad
            // screen quad VAO to render on
            GL.GenVertexArrays(1, out quadVAO);
            GL.GenBuffers(1, out quadVBO);
            GL.BindVertexArray(quadVAO);
            GL.BindBuffer(BufferTarget.ArrayBuffer, quadVBO);
            GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * quadVertices.Length, quadVertices, BufferUsageHint.StaticDraw);
            GL.EnableVertexAttribArray(0);
            GL.VertexAttribPointer(0, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), 0);
            GL.EnableVertexAttribArray(1);
            GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 4 * sizeof(float), (2 * sizeof(float)));
            //return;

            GL.ClearColor(ClearColor);
            //   GL.DepthFunc(DepthFunction.Greater);
            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Less);

            //  Helper.CheckGLError(this);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.ActiveTexture(TextureUnit.Texture0);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            //gamma correction
            //GL.Enable(EnableCap.FramebufferSrgb);

            GL.Enable(EnableCap.Multisample);
            GL.PatchParameter(PatchParameterInt.PatchVertices, 3);
            float[] innerLevel = new float[] { 5 };
            float[] outerLevel = new float[] { 3, 3, 3 };
            GL.PatchParameter(PatchParameterFloat.PatchDefaultOuterLevel, outerLevel);
            GL.PatchParameter(PatchParameterFloat.PatchDefaultInnerLevel, innerLevel);

            // GL.PatchParameter(PatchParameterInt.PatchVertices, 3);

            //setup fbos

            Resize(MScreen.Width, MScreen.Height);
        }
Example #2
0
 public MRenderer() : base(EType.Other, "Renderer")
 {
     FXShader = new MShader("FX");
     try {
         FXShader.LoadFromString(vs, fs);
     }
     catch (Exception e)
     {
         Console.WriteLine("MRenderer: " + e.Message + " . OPENGL Setup?");
     }
     BufferSize = new Vector2(MScreen.Width, MScreen.Height);
 }