Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualHeadkaze

Posted 16 February 2013 - 02:09 AM

I also tried this
 
 
public static Texture TakeSnapshot(Device device)
{
    Texture texture = null;
 
    using (Surface renderSurface = device.GetRenderTarget(0))
    {
        using (Surface offscreenSurface = Surface.CreateOffscreenPlain(device, renderSurface.Description.Width, renderSurface.Description.Height, renderSurface.Description.Format, Pool.SystemMemory))
        {
            texture = new Texture(device, renderSurface.Description.Width, renderSurface.Description.Height, 1, 0, renderSurface.Description.Format, Pool.Default);
            Surface surface = texture.GetSurfaceLevel(0);
 
            device.GetRenderTargetData(renderSurface, offscreenSurface);
            device.StretchRectangle(offscreenSurface, Rectangle.Empty, surface, Rectangle.Empty, TextureFilter.None);
        }
    }
 
    return texture;
}
But I get the error "[5220] Direct3D9: (ERROR) :D3DPOOL_DEFAULT must be set for surfaces passed to StretchRect and ColorFill"

If I change it to Pool.Default then I get the error "[4936] Direct3D9: (ERROR) :The destination surface must be created using D3DPOOL_SYSTEMMEM. GetRenderTargetData fails"

#1Headkaze

Posted 16 February 2013 - 02:08 AM

I also tried this

 

public static Texture TakeSnapshot(Device device)
{
    Texture texture = null;
 
    using (Surface renderSurface = device.GetRenderTarget(0))
    {
        using (Surface offscreenSurface = Surface.CreateOffscreenPlain(device, renderSurface.Description.Width, renderSurface.Description.Height, renderSurface.Description.Format, Pool.SystemMemory))
        {
            texture = new Texture(device, renderSurface.Description.Width, renderSurface.Description.Height, 1, 0, renderSurface.Description.Format, Pool.Default);
            Surface surface = texture.GetSurfaceLevel(0);
 
            device.GetRenderTargetData(renderSurface, offscreenSurface);
            device.StretchRectangle(offscreenSurface, Rectangle.Empty, surface, Rectangle.Empty, TextureFilter.None);
        }
    }
 
    return texture;
}

PARTNERS