Sign in to follow this  
FeverGames

SlimDX resolve backbuffer

Recommended Posts

Hey, i am trying to resolve the backbuffer to a texture, so i can use the backbuffer 'copy' for post processing. Why isn't there any way to do Texture.SetSurface(index, surface); ? How should i do this then?

Share this post


Link to post
Share on other sites
From the SlimDX SampleFramework (Direct3D9Manager.cs):


public void ResolveBackBuffer(Texture target, int backBufferIndex)
{
bool storedThrow = Configuration.ThrowOnError;
Configuration.ThrowOnError = false;

Surface backBuffer = Device.GetBackBuffer(0, backBufferIndex);
if (backBuffer == null || Result.Last.IsFailure)
{
Configuration.ThrowOnError = storedThrow;
throw new InvalidOperationException("Could not obtain back buffer surface.");
}

Surface destination = target.GetSurfaceLevel(0);
if (destination == null || Result.Last.IsFailure)
{
backBuffer.Dispose();
Configuration.ThrowOnError = storedThrow;
throw new InvalidOperationException("Could not obtain resolve target surface.");
}

if (Device.StretchRectangle(backBuffer, destination, TextureFilter.Linear).IsFailure)
{
if (Device.StretchRectangle(backBuffer, destination, TextureFilter.None).IsFailure)
{
if (Surface.FromSurface(destination, backBuffer, Filter.Default, 0).IsFailure)
{
backBuffer.Dispose();
destination.Dispose();
Configuration.ThrowOnError = storedThrow;
throw new InvalidOperationException("Could not copy surfaces.");
}
}
}

backBuffer.Dispose();
destination.Dispose();
Configuration.ThrowOnError = storedThrow;
}

Share this post


Link to post
Share on other sites

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