internal virtual void Apply() { GLStateManager.Cull(graphicsDevice.RasterizerState.CullMode.OpenGL11()); // TODO: This is prolly not right (DepthBuffer, etc) GLStateManager.DepthTest(graphicsDevice.DepthStencilState.DepthBufferEnable); }
public void End() { // set up camera switch (this.graphicsDevice.PresentationParameters.DisplayOrientation) { case DisplayOrientation.LandscapeLeft: case DisplayOrientation.LandscapeRight: case DisplayOrientation.PortraitUpsideDown: throw new NotImplementedException(); default: if (this.graphicsDevice.RenderTarget != null) { Matrix4.CreateOrthographicOffCenter(0, this.graphicsDevice.RenderTarget.Width, this.graphicsDevice.RenderTarget.Height, 0, -1, 1, out GLStateManager.Projection); break; } else { Matrix4.CreateOrthographicOffCenter(0, this.graphicsDevice.Viewport.Width, this.graphicsDevice.Viewport.Height, 0, -1, 1, out GLStateManager.Projection); break; } } GL.Viewport(this.graphicsDevice.Viewport.X, this.graphicsDevice.Viewport.Y, this.graphicsDevice.Viewport.Width, this.graphicsDevice.Viewport.Height); // Enable Scissor Tests if necessary if (this.graphicsDevice.RenderState.ScissorTestEnable) { GL.Enable(EnableCap.ScissorTest); GL.Scissor(this.graphicsDevice.ScissorRectangle.X, this.graphicsDevice.ScissorRectangle.Y, this.graphicsDevice.ScissorRectangle.Width, this.graphicsDevice.ScissorRectangle.Height); } GLStateManager.ModelView = _matrix.ToMatrix4(); // Initialize OpenGL states (ideally move this to initialize somewhere else) GLStateManager.DepthTest(false); GLStateManager.Textures2D(true); // Enable Culling for better performance GLStateManager.Cull(FrontFaceDirection.Cw); switch (_sortMode) { case SpriteSortMode.Immediate: break; default: this.graphicsDevice.RenderState.SourceBlend = _blendState.ColorSourceBlend; this.graphicsDevice.RenderState.DestinationBlend = _blendState.ColorDestinationBlend; break; } GLStateManager.BlendFunc((BlendingFactorSrc)this.graphicsDevice.RenderState.SourceBlend, (BlendingFactorDest)this.graphicsDevice.RenderState.DestinationBlend); _batcher.DrawBatch(_sortMode); // GG EDIT always disable scissor test after drawing a batch if (this.graphicsDevice.RenderState.ScissorTestEnable) { GL.Disable(EnableCap.ScissorTest); } }