예제 #1
0
        public void Draw(ITexture2D resolvedTexture, Color4 color)
        {
            var prevShader          = glContext.Bindings.Program.Get();
            var prevVao             = glContext.Bindings.VertexArray.Get();
            var prevUb              = glContext.Bindings.Buffers.UniformIndexed[0].Get();
            var prevDepthMask       = glContext.States.DepthStencil.DepthMask.Get();
            var prevDepthTestEnable = glContext.States.DepthStencil.DepthTestEnable.Get();
            var prevCullFaceEnable  = glContext.States.Rasterizer.CullFaceEnable.Get();

            glContext.Bindings.Program.Set(program);
            glContext.Bindings.VertexArray.Set(vao);

            glContext.States.DepthStencil.DepthMask.Set(false);
            glContext.States.DepthStencil.DepthTestEnable.Set(false);
            glContext.States.Rasterizer.CullFaceEnable.Set(false);

            glContext.Bindings.Textures.ActiveUnit.Set(0);
            glContext.Bindings.Textures.Units[0].Set(resolvedTexture);

            paramsUb.SetData(color);
            paramsUb.Bind(glContext, 0);

            glContext.Actions.Draw.Arrays(BeginMode.TriangleStrip, 0, 4);

            glContext.States.DepthStencil.DepthMask.Set(prevDepthMask);
            glContext.States.DepthStencil.DepthTestEnable.Set(prevDepthTestEnable);
            glContext.States.Rasterizer.CullFaceEnable.Set(prevCullFaceEnable);

            glContext.Bindings.Program.Set(prevShader);
            glContext.Bindings.VertexArray.Set(prevVao);
            glContext.Bindings.Buffers.UniformIndexed[0].Set(prevUb);
        }
예제 #2
0
        public void Draw(ITextureCubemap gltextureCubemap, CameraFrame cameraFrame, float fieldOfView, float aspectRatio)
        {
            glContext.States.DepthStencil.DepthTestEnable.Set(false);
            glContext.States.DepthStencil.DepthMask.Set(false);
            // todo: to ObjectGL
            glContext.GL.Enable((int)All.TextureCubeMapSeamless);

            glContext.Bindings.Program.Set(shaderProgram);
            glContext.Bindings.VertexArray.Set(vao);

            var simplifiedViewFrame = new CameraFrame(Vector3.Zero, cameraFrame.Forward, cameraFrame.Up, cameraFrame.Right);
            var viewMat             = simplifiedViewFrame.GetViewMat();
            var projMat             = Matrix4x4.PerspectiveFovDx(fieldOfView, aspectRatio, 0.1f, 100f);

            cameraUb.SetData(viewMat * projMat);
            cameraUb.Bind(glContext, 0);

            glContext.Bindings.Textures.ActiveUnit.Set(0);
            glContext.Bindings.Textures.Units[0].Set(gltextureCubemap);
            glContext.Bindings.Samplers[0].Set(sampler);

            glContext.States.Rasterizer.CullFaceEnable.Set(false);

            glContext.Actions.Draw.Elements(BeginMode.Triangles, 36, DrawElementsType.UnsignedInt, 0);
        }
예제 #3
0
        public void Draw(Color4 color4)
        {
            glContext.Bindings.Program.Set(shaderProgram);
            glContext.Bindings.VertexArray.Set(vao);

            glContext.States.DepthStencil.DepthTestEnable.Set(false);

            glContext.States.Blend.BlendEnable.Set(true);
            glContext.States.Blend.United.Equation.Set(BlendMode.Add);
            glContext.States.Blend.United.Function.Set(BlendFactor.SrcAlpha, BlendFactor.OneMinusSrcAlpha);

            colorUb.SetData(color4);
            colorUb.Bind(glContext, 0);

            glContext.Actions.Draw.Arrays(BeginMode.TriangleStrip, 0, 4);

            glContext.States.Blend.BlendEnable.Set(false);
            glContext.States.DepthStencil.DepthTestEnable.Set(true);
        }