public void EndGL11() { // Disable Blending by default = BlendState.Opaque GL11.Disable(ALL11.Blend); // set the blend mode if (_blendState == BlendState.NonPremultiplied) { GL11.BlendFunc(ALL11.SrcAlpha, ALL11.OneMinusSrcAlpha); GL11.Enable(ALL11.Blend); } if (_blendState == BlendState.AlphaBlend) { GL11.BlendFunc(ALL11.One, ALL11.OneMinusSrcAlpha); GL11.Enable(ALL11.Blend); } if (_blendState == BlendState.Additive) { GL11.BlendFunc(ALL11.SrcAlpha, ALL11.One); GL11.Enable(ALL11.Blend); } if (_blendState == BlendState.Multiply) { GL11.BlendFunc(ALL11.DstColor, ALL11.Zero); GL11.Enable(ALL11.Blend); } if (_blendState == BlendState.Multiplyx2) { GL11.BlendFunc(ALL11.DstColor, ALL11.SrcColor); GL11.Enable(ALL11.Blend); } // set camera GL11.MatrixMode(ALL11.Projection); GL11.LoadIdentity(); GL11.Ortho(0, this.graphicsDevice.Viewport.Width, this.graphicsDevice.Viewport.Height, 0, -1, 1); // Enable Scissor Tests if necessary if (this.graphicsDevice.RasterizerState.ScissorTestEnable) { GL11.Enable(ALL11.ScissorTest); } GL11.MatrixMode(ALL11.Modelview); GL11.Viewport(0, 0, this.graphicsDevice.Viewport.Width, this.graphicsDevice.Viewport.Height); // Enable Scissor Tests if necessary if (this.graphicsDevice.RasterizerState.ScissorTestEnable) { GL11.Scissor(this.graphicsDevice.ScissorRectangle.X, this.graphicsDevice.ScissorRectangle.Y, this.graphicsDevice.ScissorRectangle.Width, this.graphicsDevice.ScissorRectangle.Height); } GL11.LoadMatrix(ref _matrix.M11); // Initialize OpenGL states (ideally move this to initialize somewhere else) GL11.Disable(ALL11.DepthTest); GL11.TexEnv(ALL11.TextureEnv, ALL11.TextureEnvMode, (int)ALL11.BlendSrc); GL11.Enable(ALL11.Texture2D); GL11.EnableClientState(ALL11.VertexArray); GL11.EnableClientState(ALL11.ColorArray); GL11.EnableClientState(ALL11.TextureCoordArray); // No need to cull sprites. they will all be same-facing by construction. // Plus, setting frontface to Clockwise is a troll move. GLStateManager.Cull(CullMode.None); GL11.Color4(1.0f, 1.0f, 1.0f, 1.0f); _batcher.DrawBatchGL11(_sortMode, _samplerState); if (this.graphicsDevice.RasterizerState.ScissorTestEnable) { GL11.Disable(ALL11.ScissorTest); } }
public void EndGL11() { // Disable Blending by default = BlendState.Opaque GL11.Disable(ALL11.Blend); // set the blend mode if (_blendState == BlendState.NonPremultiplied) { GL11.BlendFunc(ALL11.SrcAlpha, ALL11.OneMinusSrcAlpha); GL11.Enable(ALL11.Blend); } if (_blendState == BlendState.AlphaBlend) { GL11.BlendFunc(ALL11.One, ALL11.OneMinusSrcAlpha); GL11.Enable(ALL11.Blend); } if (_blendState == BlendState.Additive) { GL11.BlendFunc(ALL11.SrcAlpha, ALL11.One); GL11.Enable(ALL11.Blend); } // set camera GL11.MatrixMode(ALL11.Projection); GL11.LoadIdentity(); #if ANDROID // Switch on the flags. switch (this.graphicsDevice.PresentationParameters.DisplayOrientation) { case DisplayOrientation.LandscapeRight: { GL11.Rotate(180, 0, 0, 1); GL11.Ortho(0, this.graphicsDevice.Viewport.Width, this.graphicsDevice.Viewport.Height, 0, -1, 1); break; } case DisplayOrientation.LandscapeLeft: case DisplayOrientation.PortraitUpsideDown: default: { GL11.Ortho(0, this.graphicsDevice.Viewport.Width, this.graphicsDevice.Viewport.Height, 0, -1, 1); break; } } #else GL11.Ortho(0, this.graphicsDevice.Viewport.Width, this.graphicsDevice.Viewport.Height, 0, -1, 1); #endif // Enable Scissor Tests if necessary if (this.graphicsDevice.RasterizerState.ScissorTestEnable) { GL11.Enable(ALL11.ScissorTest); } GL11.MatrixMode(ALL11.Modelview); var client = Game.Instance.Window.ClientBounds; GL11.Viewport(client.X, client.Y, client.Width, client.Height); // Enable Scissor Tests if necessary if (this.graphicsDevice.RasterizerState.ScissorTestEnable) { GL11.Scissor(this.graphicsDevice.ScissorRectangle.X, this.graphicsDevice.ScissorRectangle.Y, this.graphicsDevice.ScissorRectangle.Width, this.graphicsDevice.ScissorRectangle.Height); } GL11.LoadMatrix(ref _matrix.M11); // Initialize OpenGL states (ideally move this to initialize somewhere else) GL11.Disable(ALL11.DepthTest); GL11.TexEnv(ALL11.TextureEnv, ALL11.TextureEnvMode, (int)ALL11.SrcAlpha); GL11.Enable(ALL11.Texture2D); GL11.EnableClientState(ALL11.VertexArray); GL11.EnableClientState(ALL11.ColorArray); GL11.EnableClientState(ALL11.TextureCoordArray); // Enable Culling for better performance GL11.Enable(ALL11.CullFace); GL11.FrontFace(ALL11.Cw); GL11.Color4(1.0f, 1.0f, 1.0f, 1.0f); _batcher.DrawBatchGL11(_sortMode, _samplerState); if (this.graphicsDevice.RasterizerState.ScissorTestEnable) { GL11.Disable(ALL11.ScissorTest); } }