Original Post
Hi, I am trying to copy a renderTarget surface to a renderTarget Texture. Can I somehow use or is Which one and what would be the fastest? I am trying to implement something like XNA has, RenderTarget.GetTexture();
Surface destination = Surface.FromPointer(source.ComPointer);
bool storedThrow = Configuration.ThrowOnError;
Configuration.ThrowOnError = false;
// future: change the first 0 to the ActiveViewTarget id
Surface destination = texture.GetSurfaceLevel(level);
if (destination == null || Result.Last.IsFailure)
{
Configuration.ThrowOnError = storedThrow;
throw new InvalidOperationException("Could not obtain resolve target surface.");
}
Result result = device.StretchRectangle(source, destination, TextureFilter.Linear);
if (result.IsFailure)
{
result = device.StretchRectangle(source, destination, TextureFilter.None);
if (result.IsFailure)
{
result = Surface.FromSurface(destination, source, Filter.Default, 0);
if (result.IsFailure)
{
destination.Dispose();
source.Dispose();
Configuration.ThrowOnError = storedThrow;
throw new InvalidOperationException("Could not copy the surfaces.");
}
}
}
Configuration.ThrowOnError = storedThrow;
}