Пример #1
0
        private void End20()
        {
            // Disable Blending by default = BlendState.Opaque
            GL20.Disable(All20.Blend);

            // set the blend mode
            if (_blendState == BlendState.NonPremultiplied)
            {
                GL20.BlendFunc(All20.One, All20.OneMinusSrcAlpha);
                GL20.Enable(All20.Blend);
                GL20.BlendEquation(All20.FuncAdd);
            }

            if (_blendState == BlendState.AlphaBlend)
            {
                GL20.BlendFunc(All20.SrcAlpha, All20.OneMinusSrcAlpha);
                GL20.Enable(All20.Blend);
                GL20.BlendEquation(All20.FuncAdd);
            }

            if (_blendState == BlendState.Additive)
            {
                GL20.BlendFunc(All20.SrcAlpha, All20.One);
                GL20.Enable(All20.Blend);
                GL20.BlendEquation(All20.FuncAdd);
            }

            //CullMode
            GL20.FrontFace(All20.Cw);

            GL20.Enable(All20.CullFace);

            GL20.Viewport(0, 0, this.graphicsDevice.Viewport.Width, this.graphicsDevice.Viewport.Height);                       // configura el viewport
            GL20.UseProgram(program);

            if (GraphicsDevice.defaultFramebuffer)
            {
                GL20.CullFace(All20.Back);
                SetUniformMatrix4(uniformWVP, false, ref matWVPScreen);
            }
            else
            {
                GL20.CullFace(All20.Front);
                SetUniformMatrix4(uniformWVP, false, ref matWVPFramebuffer);
                GL20.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
                GL20.Clear((int)(All20.ColorBufferBit | All20.DepthBufferBit));
            }

            _batcher.DrawBatch20(_sortMode);


            GL20.Disable(All20.Texture2D);
        }
Пример #2
0
        private void EndGL20()
        {
            // Disable Blending by default = BlendState.Opaque
            GL20.Disable(ALL20.Blend);

            // set the blend mode
            if (_blendState == BlendState.NonPremultiplied)
            {
                GL20.BlendFunc(ALL20.SrcAlpha, ALL20.OneMinusSrcAlpha);
                GL20.Enable(ALL20.Blend);
                GL20.BlendEquation(ALL20.FuncAdd);
            }

            if (_blendState == BlendState.AlphaBlend)
            {
                GL20.BlendFunc(ALL20.One, ALL20.OneMinusSrcAlpha);
                GL20.Enable(ALL20.Blend);
                GL20.BlendEquation(ALL20.FuncAdd);
            }

            if (_blendState == BlendState.Additive)
            {
                GL20.BlendFunc(ALL20.SrcAlpha, ALL20.One);
                GL20.Enable(ALL20.Blend);
                GL20.BlendEquation(ALL20.FuncAdd);
            }

            //CullMode
            GL20.FrontFace(ALL20.Cw);
            GL20.Enable(ALL20.CullFace);


            UpdateWorldMatrixOrientation();

            // Configure ViewPort
            var client = Game.Instance.Window.ClientBounds;

            GL20.Viewport(client.X, client.Y, client.Width, client.Height);
            GL20.UseProgram(program);

            // Enable Scissor Tests if necessary
            if (this.graphicsDevice.RasterizerState.ScissorTestEnable)
            {
                GL20.Enable(ALL20.ScissorTest);
                GL20.Scissor(this.graphicsDevice.ScissorRectangle.X, this.graphicsDevice.ScissorRectangle.Y, this.graphicsDevice.ScissorRectangle.Width, this.graphicsDevice.ScissorRectangle.Height);
            }

            if (GraphicsDevice.DefaultFrameBuffer)
            {
                GL20.CullFace(ALL20.Back);
                SetUniformMatrix(uniformWVP, false, ref matWVPScreen);
            }
            else
            {
                GL20.CullFace(ALL20.Front);
                SetUniformMatrix(uniformWVP, false, ref matWVPFramebuffer);

                // FIXME: Why clear the framebuffer during End?
                //        Doing so makes it so that only the
                //        final Begin/End pair in a frame can
                //        ever be shown.  Is that desirable?
                //GL20.ClearColor(0.0f,0.0f,0.0f,0.0f);
                //GL20.Clear((int) (ALL20.ColorBufferBit | ALL20.DepthBufferBit));
            }

            _batcher.DrawBatchGL20(_sortMode, _samplerState);

            if (this.graphicsDevice.RasterizerState.ScissorTestEnable)
            {
                GL20.Disable(ALL20.ScissorTest);
            }

            GL20.Disable(ALL20.Texture2D);
        }