Пример #1
0
        public void RenderTexture(RTexture texture, Math.Rectangle bounds, RColor color, Matrix matrix, bool font)
        {
            RViewport viewport = REngine.Instance._viewport;

            UpdateQuad(bounds);
            blendState.PlatformApplyState();

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

            defaultShader.Bind();
            defaultShader.SetSamplerValue(RTextureLayer.DIFFUSE, texture);
            vertexQuad2D.Bind();
            vertexQuad2D.BindVertexArray();
            indexQuad2D.Bind();


            defaultShader.SetUniformValue("projection", camera2d.Projection);
            defaultShader.SetUniformValue("view", camera2d.View);
            defaultShader.SetUniformValue("diffuse_color", color.ToVector4());
            defaultShader.SetUniformValue("model", matrix);
            defaultShader.SetUniformValue("font", font);
            vertexQuad2D.VertexDeclaration.Apply(defaultShader, IntPtr.Zero);


            GL.DrawElements(PrimitiveType.Triangles, indexQuad2D.IndexCount, DrawElementsType.UnsignedShort, IntPtr.Zero);
            REngine.CheckGLError();

            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.DstAlpha);
            GL.Disable(EnableCap.Blend);
            indexQuad2D.Unbind();
            vertexQuad2D.UnbindVertexArray();
            vertexQuad2D.Unbind();
            defaultShader.Unbind();
        }
Пример #2
0
        public void RenderFullscreenQuad(RShader shader)
        {
            RViewport viewport = REngine.Instance._viewport;

            quadVerts[0].Position = new Vector2(-1, -1);
            quadVerts[0].TexCoord = new Vector2(0, 0);
            quadVerts[1].Position = new Vector2(1, -1);
            quadVerts[1].TexCoord = new Vector2(1, 0);
            quadVerts[2].Position = new Vector2(1, 1);
            quadVerts[2].TexCoord = new Vector2(1, 1);
            quadVerts[3].Position = new Vector2(-1, 1);
            quadVerts[3].TexCoord = new Vector2(0, 1);
            vertexQuad2D.SetData <RVertexData2D>(quadVerts);
            shader.Bind();
            GL.Disable(EnableCap.DepthTest);
            GL.Disable(EnableCap.CullFace);
            vertexQuad2D.Bind();
            vertexQuad2D.BindVertexArray();
            indexQuad2D.Bind();

            vertexQuad2D.VertexDeclaration.Apply(shader, IntPtr.Zero);


            GL.DrawElements(PrimitiveType.Triangles, indexQuad2D.IndexCount, DrawElementsType.UnsignedShort, IntPtr.Zero);
            REngine.CheckGLError();

            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.DstAlpha);

            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);
            indexQuad2D.Unbind();
            vertexQuad2D.UnbindVertexArray();
            vertexQuad2D.Unbind();
            shader.Unbind();
        }
Пример #3
0
 public void EndHDR()
 {
     hdrFrameBuffer.Unbind();
     hdrShader.Bind();
     hdrShader.SetSamplerValue(RTextureLayer.DIFFUSE, hdrFrameBuffer);
     hdrShader.Unbind();
 }