protected override void Draw ( GameTime gameTime, StereoEye stereoEye )
{
var sb = GetService<SpriteBatch>();
var rand = new Random();
var data = Enumerable.Range(0,64*64)
.Select( i => rand.NextColor() )
.ToArray();
dynamicTexture.SetData(0, null, data, 0, 64*64 );
GraphicsDevice.SetTargets( dsMS.Surface, rtMS.Surface );
GraphicsDevice.Clear( dsMS.Surface );
GraphicsDevice.Clear( rtMS.Surface, Color4.Black );
sb.Begin(SpriteBlend.AlphaBlend,null,null, Matrix.OrthoRH(256,256,-1,1));
sb.DrawSprite( texture, 0,0,256, angle, Color.White );
sb.End();
GraphicsDevice.Resolve( rtMS, rt );
GraphicsDevice.RestoreBackbuffer();
int w = GraphicsDevice.DisplayBounds.Width;
int h = GraphicsDevice.DisplayBounds.Height;
// begin sprite gathering/accumulation :
sb.Begin();
if (InputDevice.IsKeyDown(Keys.T)) {
sb.Draw( texture2, 0, 0, 256, 256, Color.White );
sb.Draw( texture , 256+128*0, 0, 128, 128, Color.Red );
sb.Draw( texture2, 256+128*1, 0, 128, 128, Color.Lime );
sb.Draw( texture , 256+128*2, 0, 128, 128, Color.Blue );
} else {
sb.Draw( rt, 0, 0, 256, 256, Color.White );
sb.Draw( rt, 256+128*0, 0, 128, 128, Color.Red );
sb.Draw( rt, 256+128*1, 0, 128, 128, Color.Lime );
sb.Draw( rt, 256+128*2, 0, 128, 128, Color.Blue );
}
sb.Restart(SpriteBlend.AlphaBlend, SamplerState.PointClamp);
sb.DrawSprite( texture, 576,192,128, angle, Color.White );
sb.Restart(SpriteBlend.AlphaBlend, SamplerState.LinearClamp);
sb.DrawSprite( texture, 704,192,128, angle, Color.White );
sb.Restart(SpriteBlend.AlphaBlend, SamplerState.PointClamp);
sb.DrawSprite( texture2, 576,192+128,128, angle, Color.White );
sb.Restart(SpriteBlend.AlphaBlend, SamplerState.LinearClamp);
sb.DrawSprite( texture2, 704,192+128,128, angle, Color.White );
sb.Restart();
for (int i=0; i<numSprites; i++) {
//sb.DrawSprite( sb.TextureWhite, r.Next(w), r.Next(h), 7, r.NextFloat(0,360), r.NextColor() );
sb.Draw( sb.TextureWhite, r.Next(w), r.Next(h), 7, 7, r.NextColor() );
}
var h1 = font1.LineHeight;
var h2 = font2.LineHeight;
font1.DrawString( sb, "Lenna Soderberg", 64, 256 + h1, Color.White );
font2.DrawString( sb, "Text (tracking = 0)", 64, 256 + h1+h2, Color.Red );
font2.DrawString( sb, "Text (tracking = 2)", 64, 256 + h1+h2*2, Color.Lime, 2 );
font2.DrawString( sb, "Text (tracking = 4)", 64, 256 + h1+h2*3, Color.Lime, 4 );
font2.DrawString( sb, string.Format("{1} sprites -> FPS = {0}", gameTime.Fps, numSprites), 64, 256 + h1+h2*4, Color.White );
sb.Restart( SpriteBlend.Additive );
sb.Draw( sb.TextureWhite, 256, 128, 128, 128, Color.Gray );
sb.Draw( texture, 256, 128, 128, 128, Color.Gray );
sb.Restart( SpriteBlend.AlphaBlend );
sb.Draw( sb.TextureWhite, 256+128, 128, 128, 128, new Color(240,225,160,255) );
sb.Restart( SpriteBlend.NegMultiply );
sb.Draw( texture, 256+128, 128, 128, 128, Color.White );
sb.Restart(SpriteBlend.AlphaBlend, SamplerState.AnisotropicWrap);
sb.DrawBeam( texture2, new Vector2(350,540), new Vector2(750,415), Color.Yellow, Color.LightYellow, 80, 5.5f, offset );
sb.Restart(SpriteBlend.AlphaBlend, SamplerState.PointClamp);
sb.Draw( dynamicTexture, 0,0,256,256,new Color(255,255,255,64) );
sb.Draw( sb.TextureBlack, 0,0,8,8, Color.White);
sb.Draw( sb.TextureBlue, 8,0,8,8, Color.White);
sb.Draw( sb.TextureGreen, 16,0,8,8, Color.White);
sb.Draw( sb.TextureRed, 24,0,8,8, Color.White);
sb.Draw( sb.TextureWhite, 32,0,8,8, Color.White);
sb.Restart();
/*var name = atlas.SubImageNames[ ((int)atlasId) % atlas.SubImageNames.Length ];
var ar = atlas.GetSubImageRectangle( name );
sb.Draw( atlas.Texture, new Rectangle(10,400, ar.Width, ar.Height), ar, Color.White );
sb.DrawDebugString( 10, 392, name, Color.White );
atlasId += gameTime.ElapsedSec * 2;*/
sb.End();
base.Draw( gameTime, stereoEye );
}
}