Esempio n. 1
0
        private void DrawSprites(List <SpriteBatchRenderItem> spritesToDraw)
        {
            // Draw the current spritebatch
            if (spritesToDraw.Count > 0)
            {
                List <float> Vertices      = new List <float>();
                List <float> TextureCoords = new List <float>();
                TextureCoords.Capacity = spritesToDraw.Count * 4;
                Vertices.Capacity      = spritesToDraw.Count * 4;

                RenderMode actualMode = spritesToDraw[0].RenderData;

                // Draw sprite vertices
                for (int sbi = 0; sbi < spritesToDraw.Count; sbi++)
                {
                    SpriteBatchRenderItem sb = spritesToDraw[sbi];

                    if ((!actualMode.IsCompatible(sb.RenderData)) || (actualMode.Texture.Image.Name != sb.RenderData.Texture.Image.Name))
                    {
                        // Render sprites
                        _device.RenderSprites(Vector2.Zero, TextureCoords.ToArray(), Vertices.ToArray(), actualMode);
                        Vertices.Clear();
                        TextureCoords.Clear();
                        actualMode = sb.RenderData;
                    }

                    // put the vertices in vertex array
                    AddToFloatList(sb.Vertices, Vertices);
                    AddToFloatList(sb.TextureCoordinates, TextureCoords);
                }

                // Render the sprites
                _device.RenderSprites(Vector2.Zero, TextureCoords.ToArray(), Vertices.ToArray(), spritesToDraw[spritesToDraw.Count - 1].RenderData);
            }
        }
Esempio n. 2
0
 internal void AddToSpriteBuffer(SpriteBatchRenderItem sbItem)
 {
     _spriteDevice.AddToSpriteBuffer(sbItem);
 }
Esempio n. 3
0
 public void AddToSpriteBuffer(SpriteBatchRenderItem sbItem)
 {
     _sprites.Add(sbItem);
 }