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

Started by
1 comment, last by Roof Top Pew Wee 18 years, 1 month ago
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]
Advertisement
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.
<searches for my "I'm an idiot!" shirt>

Man, why didn't I think of that? Thanks for the quick and informative reply.

--Vic--

This topic is closed to new replies.

Advertisement