2011-11-28 11:27:07 +00:00
|
|
|
#region Using Statements
|
2011-11-28 11:11:54 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using Microsoft.Xna.Framework.Audio;
|
|
|
|
using Microsoft.Xna.Framework.Content;
|
|
|
|
using Microsoft.Xna.Framework.GamerServices;
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
using Microsoft.Xna.Framework.Input;
|
|
|
|
using Microsoft.Xna.Framework.Media;
|
2011-11-28 11:27:07 +00:00
|
|
|
#endregion
|
2011-11-28 11:11:54 +00:00
|
|
|
|
|
|
|
namespace RenderTarget
|
|
|
|
{
|
|
|
|
public class Game1 : Microsoft.Xna.Framework.Game
|
|
|
|
{
|
|
|
|
GraphicsDeviceManager graphics;
|
|
|
|
SpriteBatch spriteBatch;
|
|
|
|
|
2011-11-28 11:27:07 +00:00
|
|
|
RenderTarget2D renderTarget;
|
|
|
|
|
2011-11-28 11:11:54 +00:00
|
|
|
public Game1()
|
|
|
|
{
|
|
|
|
graphics = new GraphicsDeviceManager(this);
|
|
|
|
Content.RootDirectory = "Content";
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Initialize()
|
|
|
|
{
|
2011-11-28 11:27:07 +00:00
|
|
|
|
2011-11-28 11:11:54 +00:00
|
|
|
|
|
|
|
base.Initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadContent()
|
|
|
|
{
|
|
|
|
spriteBatch = new SpriteBatch(GraphicsDevice);
|
|
|
|
|
2011-11-28 11:27:07 +00:00
|
|
|
this.renderTarget = new RenderTarget2D(GraphicsDevice, 128, 128, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8);
|
2011-11-28 11:11:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void UnloadContent()
|
|
|
|
{
|
2011-11-28 11:27:07 +00:00
|
|
|
|
2011-11-28 11:11:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update(GameTime gameTime)
|
|
|
|
{
|
2011-11-28 11:27:07 +00:00
|
|
|
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
|
|
|
|
Keyboard.GetState().IsKeyDown(Keys.Escape))
|
2011-11-28 11:11:54 +00:00
|
|
|
this.Exit();
|
|
|
|
|
2011-11-28 11:27:07 +00:00
|
|
|
|
2011-11-28 11:11:54 +00:00
|
|
|
|
|
|
|
base.Update(gameTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Draw(GameTime gameTime)
|
|
|
|
{
|
2011-11-28 11:27:07 +00:00
|
|
|
GraphicsDevice.SetRenderTarget(this.renderTarget);
|
|
|
|
GraphicsDevice.Clear(ClearOptions.Target, Color.Green, 1.0f, 0);
|
|
|
|
GraphicsDevice.SetRenderTarget(null);
|
|
|
|
|
2011-11-28 11:11:54 +00:00
|
|
|
GraphicsDevice.Clear(Color.CornflowerBlue);
|
|
|
|
|
2011-11-28 11:27:07 +00:00
|
|
|
spriteBatch.Begin();
|
|
|
|
spriteBatch.Draw(this.renderTarget, new Vector2(64, 64), Color.White);
|
|
|
|
spriteBatch.End();
|
2011-11-28 11:11:54 +00:00
|
|
|
|
|
|
|
base.Draw(gameTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|