render a copy of the backbuffer
Hello I have read several posts about that, but nothing seems to work for me,
I try to save my backbuffer (to store it in a surface)
then I would like to draw this saved surface...
so, I need two things.
1: save my backbuffer
MyBackBufferSurface=graphics.GraphicsDevice.GetBackBuffer(0,0);
2:render my backBuffer
spriteRenderer.Draw(MyBackBufferTexture,
newRectangle(0, 0, 512, 512),Color.White);I used :MyBackBufferSurface= MyBackBuffertexture.GetSurfaceLevel(0); to assosiate my surface with my texture
I end up with a black surface when I render my texutre
please help me I on this since a week and it makes me crazy.
[1051 byte] By [
kosinus] at [2007-12-24]
thanx it seems to work better, but i end up with a frozen display because I dont know how to get back the original backbuffer at the end.
is it the getbackbuffer funciton ?
Surface oldRenderTarget = device.GetRenderTarget(0);
Surface myTargetSurface = myTargetTexture.GetSurfaceLevel(0);
using (myTargetSurface)
{
device.SetRenderTarget(0, myTargetSurface);
device.Clear(Color.Color); //you may also want to clear depth here
//Render whatever you want to your texture
}
device.SetRenderTarget(0, oldRenderTarget);
thanx a lot
i appreciate your help
it seems to work better...
but not ok yet, I m now with a red flickering screen ( seems to be some kind of system memory...)
i m drawing my target texture with a spritebatch, is that ok ?
I did exactly what you told me. I m not sure where it doesnt work.
This approach have some disadvantages:
1. No hardware anti-aliasing.
2. Need full-resolution render target.
3. Need full-resolution copy from RT to backbuffer.
Better use following approach.
1. Render scene to backbuffer.
2. Stretch backbuffer to RT texture:
device.StretchRectangle(backbuffer_surface, null, texture_surface, null, Microsoft.Xna.Framework.Graphics.TextureFilter.Linear);
I've got this methods from Game Developers conference's publication "Special Effects in Direct3D" by Greg James (nVidia corp.)
P.S. Sorry for my english, i am russian.