diff --git a/spine-xna/example/src/ExampleGame.cs b/spine-xna/example/src/ExampleGame.cs index 0d8034079..37d544cda 100644 --- a/spine-xna/example/src/ExampleGame.cs +++ b/spine-xna/example/src/ExampleGame.cs @@ -88,7 +88,9 @@ namespace Spine { time += gameTime.ElapsedGameTime.Milliseconds / 1000f; animation.Apply(skeleton, time, true); skeleton.UpdateWorldTransform(); + skeletonRenderer.Begin(); skeletonRenderer.Draw(skeleton); + skeletonRenderer.End(); base.Draw(gameTime); } diff --git a/spine-xna/src/SkeletonRenderer.cs b/spine-xna/src/SkeletonRenderer.cs index 5b3ff1e22..55ebeb350 100644 --- a/spine-xna/src/SkeletonRenderer.cs +++ b/spine-xna/src/SkeletonRenderer.cs @@ -53,12 +53,25 @@ namespace Spine { Bone.yDown = true; } + public void Begin () { + device.RasterizerState = rasterizerState; + device.BlendState = BlendState.AlphaBlend; + } + + public void End () { + foreach (EffectPass pass in effect.CurrentTechnique.Passes) { + pass.Apply(); + batcher.Draw(device); + } + } + public void Draw (Skeleton skeleton) { List drawOrder = skeleton.DrawOrder; for (int i = 0, n = drawOrder.Count; i < n; i++) { Slot slot = drawOrder[i]; Attachment attachment = slot.Attachment; - if (attachment == null) continue; + if (attachment == null) + continue; if (attachment is RegionAttachment) { RegionAttachment regionAttachment = (RegionAttachment)attachment; @@ -112,14 +125,6 @@ namespace Spine { item.vertexTR.TextureCoordinate.Y = uvs[RegionAttachment.Y4]; } } - - device.RasterizerState = rasterizerState; - device.BlendState = BlendState.AlphaBlend; - - foreach (EffectPass pass in effect.CurrentTechnique.Passes) { - pass.Apply(); - batcher.Draw(device); - } } } } diff --git a/spine-xna/src/SpriteBatcher.cs b/spine-xna/src/SpriteBatcher.cs index e24767400..07f532025 100644 --- a/spine-xna/src/SpriteBatcher.cs +++ b/spine-xna/src/SpriteBatcher.cs @@ -77,11 +77,6 @@ namespace Spine { /// sent to the GPU). /// public class SpriteBatcher { - /* - * Note that this class is fundamental to high performance for SpriteBatch games. Please exercise - * caution when making changes to this class. - */ - /// /// Initialization size for the batch item list and queue. /// @@ -175,11 +170,6 @@ namespace Spine { _vertexArray = new VertexPositionColorTexture[4 * numBatchItems]; } - /// - /// Sorts the batch items and then groups batch drawing into maximal allowed batch sets that do not - /// overflow the 16 bit array indices for vertices. - /// - /// The type of depth sorting desired for the rendering. public void Draw (GraphicsDevice device) { // nothing to do if (_batchItemList.Count == 0) @@ -225,8 +215,7 @@ namespace Spine { } // flush the remaining vertexArray data FlushVertexArray(device, startIndex, index); - // Update our batch count to continue the process of culling down - // large batches + // Update our batch count to continue the process of culling down large batches batchCount -= numBatchesToProcess; } _batchItemList.Clear();