I'm having a problem with drawing 2 RenderTargets to the screen.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
namespace Please
{
class Class1
{
RenderTarget2D rt;
Texture2D temp;
Vector2 v;
public Class1(Vector2 v,GraphicsDevice g)
{
this.v = v;
rt=new RenderTarget2D(g,800,600);
}
public void Draw(SpriteBatch sb,GraphicsDevice gd,ContentManager cm)
{
gd.SetRenderTarget(rt);
sb.Begin();
sb.Draw(cm.Load<Texture2D>("Untitled.png"),v,Color.White);
sb.End();
gd.SetRenderTarget(null);
temp = (Texture2D)rt;
sb.Begin();
sb.Draw(temp, Vector2.Zero, Color.White);
sb.End();
}
}
}
Here's my draw function in the actual "game"
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime);
one.Draw(spriteBatch, graphics.GraphicsDevice, Content);
two.Draw(spriteBatch, graphics.GraphicsDevice, Content);
}
one and two have positions (100,200) and (300,200) respectively, so, they should be drawn 100 pixels apart, however, only two is being drawn with the rest of the screen black