This project is read-only.

RenderTarget2D Support

Jun 28, 2011 at 6:20 PM

I've been working on porting a project to use SilverSprite, and believe that I'm stuck on porting some code that renders into a custom render target.  I know there were some differences regarding RenderTargets between XNA3.1 and XNA4.0, but am curious whether there are any additional limitations or requirements when using SilverSprite.  Then most relevant code snippets seem to be the following.  Any advice will be greatly appreciated.  Thanks in advance.

// Initialization
m_screen = new RenderTarget2D(GraphicsDevice, GraphicsDevice.PresentationParameters.BackBufferWidth,
GraphicsDevice.PresentationParameters.BackBufferHeight, 1,

// Update RenderTarget
GraphicsDevice.SetRenderTarget(0, m_screen);
    // Draw to rendertarget code here
GraphicsDevice.SetRenderTarget(0, null);
m_screenTexture = m_screen.GetTexture();

// Draw to Screen
    m_spriteBatch.Draw(m_screenTexture, m_titleSafe, m_titleSafe, Color.White);

Jun 29, 2011 at 12:50 AM

Render targets are one of the pieces of SilverSprite that are not completely implemented because of limitations in Silverlight 4. I'm working on a Silverlight 5 version and I expect it to have much more compatible render target support. SilverSprite is based on XNA 3.x currently so you'll have better luck if you try to make it look like XNA 3. Are you getting an error or is it just not working?

Jun 29, 2011 at 4:47 AM

Thanks for the quick response!

There aren't any errors, but I can't seem to draw anything to the render target (m_screen) using SpriteBatch.  I can however clear the render target's contents with GraphicsDevice.Clear().

It's a shame this isn't working, but overall I've been very impressed with SilverSprite, and am glad to hear that you are continuing to improve it.  

Thanks for creating and continuing to support such a useful tool!