• Advertisement
Sign in to follow this  

SlimDX resolve backbuffer

This topic is 3352 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

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
Advertisement
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
Sorry guys somehow i didn't get an email that a message was posted, or maybe i just forgot to check the box for it. Thanks a lot for the info and the function you posted! Very helpfull!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement