RenderTarget2D behavior in XNA
- by Utkarsh Sinha
I've been dabbling with XNA for a couple of days now. This chunk of code doesn't work as I expect. The goal is to render sprites individually and composite them on another rendertarget.
P = RenderTarget2D(with RenderTargetUsage.PreserveContents)
D = RenderTarget2D(with RenderTargetUsage.DiscardContents)
for all sprites:
graphicsDevice.SetRenderTarget(D);
<draw sprite i>
graphicsDevice.SetRenderTarget(P);
<Draw D>
graphicsDevice.SetRenderTarget(null);
<Draw P>
The result I get is - only the last sprite is visible. I'm sure I'm missing some piece of information about RenderTarget2D. Any hints on what that might be?
Cross posted from - http://stackoverflow.com/questions/9970349/weird-rendertarget2d-behaviour