Sign in to follow this  

RenderTarget2D not saving

This topic is 2010 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello. I am rendering a scene to a render target and trying to save it to a file, but the picture that is created is always blank(as in it is 0k, not even black pixels are created), I don't know what else to do. The rendering works perfectly so I know things are actually getting rendered, it is just not saving to an image. Here is my code.



RenderTarget2D RenderTarget = new RenderTarget2D(CRenderManager.Singleton.GetGD(), 128, 128, false, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents);
CRenderManager.Singleton.GetGD().SetRenderTarget(RenderTarget);

CRenderManager.Singleton.GetEffect().World = Matrix.CreateTranslation(-pos.getVector3df()) ;
CRenderManager.Singleton.GetEffect().VertexColorEnabled = false;
foreach (EffectPass pass in CRenderManager.Singleton.GetEffect().CurrentTechnique.Passes)
{
pass.Apply();
CRenderManager.Singleton.GetGD().Indices = patch.GetIB();
CRenderManager.Singleton.GetGD().SetVertexBuffer(patch.GetVB());
CRenderManager.Singleton.GetGD().DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, patch.GetVB().VertexCount, 0, patch.GetIB().IndexCount);
}
CRenderManager.Singleton.GetGD().SetRenderTarget(null);
RenderTarget.SaveAsPng(File.OpenWrite("RENDER.png"), RenderTarget.Width, RenderTarget.Height);


Any ideas? Edited by ShadowMan777

Share this post


Link to post
Share on other sites

This topic is 2010 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this