views:

779

answers:

3

In XNA is there a way to render the contents of a spriteBatch after drawing to a texture object before rendering to the screen?

+1  A: 

You'll need to switch your render target for the spritebatch and then grab the texture out of it. This MSDN article explains it pretty well.

http://msdn.microsoft.com/en-us/library/bb976073.aspx

Hexxagonal
+1  A: 

As Hexxagonal already answered, yes you can. But you might get into trouble, if you are using sprites with translucency. The reason is, that two overlapping sprites wont end up with the right alphavalue in your offscreen rendertarget.

To make things right you will have to make your own SpriteBatch and start using premultiplied alpha.

LaZe
A: 

Here's an additional link to Shawn Hargreaves' excellent blog where he talks about rendertarget semantics:
http://blogs.msdn.com/shawnhar/archive/2007/02/04/xna-rendertarget-semantics.aspx

Joel Martinez