Sign in to follow this  
Roof Top Pew Wee

[C#, MDX] Screenshot code works in Release, pink file in debug. SOLVED

Recommended Posts

I'm a little confuses as to why the following code works perfectly when Direct3D is in release mode, but not when in debug:
            Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
            SurfaceLoader.Save(fileName, ImageFileFormat.Jpg, backbuffer);
            backbuffer.Dispose();

The backbuffer is retrieved either way because the image saved matches the dimensions of my window, but when I switch the D3D Runtime to the Debug Version, I just get a pink screen. I've looked around for info on this, but haven't been able to find anything on Google/Docs/books. Any pointers? --Vic-- [Edited by - Roof Top Pew Wee on April 1, 2006 4:21:33 PM]

Share this post


Link to post
Share on other sites
You're calling that code before you render you scene, or after you call Present(), aren't you?

The debug runtime clears the backbuffer to alternating magenta and green each frame, so you can see if you forgot to clear the backbuffer or any other problems. There's no guarantee that what you have on the backbuffer in one frame will stay there for the next. Just because it works on your card doesn't mean it'll always work. This is a warning from D3D.

What's happening is you're probably rendering your scene, then calling Present(), which swaps the buffers. The debug runtime now fills the backbuffer with either magenta or green. You then grab the backbuffer and save it to a file. Result: A pink or green screenshot.

Moving the code you have to just before Present() should fix that problem I think.

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