Sign in to follow this  

Problem with screenshots

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

Hello, I have an issue with making screenshots. If my app is running fullscreen and I press the printscreen-key, the resulting picture often is purely green/pink. If make a screenshot myself like this,
D3DXSaveSurfaceToFile("screen.bmp", D3DXIFF_BMP, pRenderSurface, 0, 0);

it actually depends where I place this line. I understand it would not be wise to make a screenshot directly after a call to Clear() but that is not what I do. I only get proper screenshots if I run the above code before a call to Present(), and that is what I don't understand. Present() does not make anything green/pink, does it?

Share this post


Link to post
Share on other sites
The green/pink part is from the debug runtimes - it's a special "code" that indicates an unused/uncleared buffer. You'll get it in other places as well - iirc, don't clear your render target and present it to the screen and you'll get a mucky pink/green mess [lol]

Normally you'd want to take a snapshot after the present operation as you'll get a properly anti-aliased image (if thats what you want) from the front buffer.

Two things:

1. What's your discard/presentation-parameters configuration?

2. What's your code for retrieving the image from the display? are you using GetRenderTargetData(), GetFrontBuffer() or GetBackBuffer()?

Cheers,
Jack

Share this post


Link to post
Share on other sites
Well, actually I was using something like this:


IDirect3DSurface9* pRenderSurface = 0;
GetRenderTarget(0, &pRenderSurface);




Never thought about GetBackBuffer().
Changing the present/discard config did not matter I believe.


EDIT:

What msdn has to say about GetFrontBufferData():
"This method is the only way to capture an antialiased screen shot."

I guess that is what I want. :)

Share this post


Link to post
Share on other sites
I tried this:

IDirect3DSurface9* pFrontBuffer = 0;
IDirect3DTexture9* pTexture = 0;

pD3DDevice->CreateTexture(Width, Height,
1, D3DUSAGE_RENDERTARGET,
D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT,
&pTexture, 0) ;
pTexture->GetSurfaceLevel(0, &pFrontBuffer);

pD3DDevice->GetFrontBufferData(0, pFrontBuffer);

D3DXSaveSurfaceToFile("screen.bmp", D3DXIFF_BMP, pFrontBuffer , 0, 0);

SAFE_RELEASE(pFrontBuffer);
SAFE_RELEASE(pTexture);


And got this:
"Destination surface must be in system or scratch memory. GetFrontBufferData fails."

Any idea?

Share this post


Link to post
Share on other sites

This topic is 4306 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.

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