public void Render() { IGraphicsService graphicsService = GameService.GetService <IGraphicsService>(); IGraphicsPipelineNode currentNode = StartNode; while (currentNode != null) { if (!graphicsService.IsDrawing) { currentNode.Prep(); graphicsService.StartDrawing(); } IGraphicsPipelineNode nextNode = currentNode.PopAndRender(); if ( nextNode != null && ( nextNode.ActiveEffect != currentNode.ActiveEffect || nextNode.DepthState != currentNode.DepthState || nextNode.TargetID != currentNode.TargetID ) ) { graphicsService.EndDrawing(); } currentNode = nextNode; } graphicsService.EndDrawing(); }