Esempio n. 1
0
        public override void DrawTextures(Texture texture, int[] vertices, int offset, int count)
        {
            var bmp = texture.GetTexture();

            if (bmp != null)
            {
                for (int i = 0; i < count; i++)
                {
                    int idx       = offset;
                    int x         = vertices[idx] + transX;
                    int y         = vertices[idx + 1] + transY;
                    int width     = vertices[idx + 2];
                    int height    = vertices[idx + 3];
                    int srcX      = vertices[idx + 4];
                    int srcY      = vertices[idx + 5];
                    int srcWidth  = vertices[idx + 6];
                    int srcHeight = vertices[idx + 7];
                    int trans     = vertices[idx + 8];
                    int tint      = vertices[idx + 9];
                    var dstRect   = new Microsoft.Xna.Framework.Rectangle(x, y, width, height);
                    var srcRect   = new Microsoft.Xna.Framework.Rectangle(srcX, srcY, srcWidth, srcHeight);
                    var c         = Microsoft.Xna.Framework.Color.White;
                    if (tint != 0xFFFFFF)
                    {
                        c = new Microsoft.Xna.Framework.Color((uint)tint);
                    }
                    if (trans > 0)
                    {
                        c *= (float)((255 - trans) / 256.0);
                    }
                    batch.Draw(bmp, dstRect, srcRect, c, 0.0f, Microsoft.Xna.Framework.Vector2.Zero, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, 1.0f);
                    offset += NUM_VERTICES;
                }
            }
        }
Esempio n. 2
0
 public void EndFrame(ExtendedSpriteBatch batch)
 {
     batch.End();
     Microsoft.Xna.Framework.Rectangle dst = new Microsoft.Xna.Framework.Rectangle(0, 0, Width, Height);
     Microsoft.Xna.Framework.Rectangle src = new Microsoft.Xna.Framework.Rectangle(0, 0, view.Width, view.Height);
     game.GraphicsDevice.SetRenderTarget(null);
     batch.Begin(Microsoft.Xna.Framework.Graphics.SpriteSortMode.Immediate, Microsoft.Xna.Framework.Graphics.BlendState.Opaque);
     batch.Draw(view, dst, src, Microsoft.Xna.Framework.Color.White);
     batch.End();
     this.batch = null;
     EndFrame();
 }