A little while ago now, I looked at how d3dx is actually quite slow and looked at why that was and that it’s better to use Direct3D directly to do such things. Generally when one wants to take a screenshot, it needs to beveryfast as to not interfere with the gameplay. This post breaks down what to do when presented with an anti-aliased display so that screenshot taking is nice and quick:
LPDIRECT3DSURFACE9 pd3dsBack = NULL;
if ( SUCCEEDED ( device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pd3dsBack) ))
{
D3DSURFACE_DESC desc;
pd3dsBack->GetDesc(&desc);
LPDIRECT3DSURFACE9 pd3dsCopy = NULL;
if (desc.MultiSampleType != D3DMULTISAMPLE_NONE)
{
if (SUCCEEDED(device->CreateRenderTarget(desc.Width, desc.Height, desc.Format, D3DMULTISAMPLE_NONE, 0, FALSE, &pd3dsCopy, NULL)))
{
if (SUCCEEDED(device->StretchRect(pd3dsBack, NULL, pd3dsCopy, NULL, D3DTEXF_NONE)))
{
pd3dsBack->Release();
pd3dsBack = pd3dsCopy;
}
else
pd3dsCopy->Release();
}
}
}
The first thing you’ll notice is we grab the back buffer and query whether it has multi-sampling. If it is, we create a new render target and then render the scene onto it. This is far quicker to do than trying to take a shot of a multi-sampled scene as you’ve forced the GPU to do the rendering down onto a surface with no multi-sampling. Job done! That way you can then continue with LockRect() etc. and take the shot as you would do normally.
This makes taking shots of multi-sampled scenes not more than 1-2ms longer than those that aren’t. Enjoy!

Hi,
I have started with the DirecTX work recetly and i was playing around with screenshots. I was using the SlimDX dll with C#. But i was stumbled upon the Anti-aliasing screenshots which comes blank with a windows 7 machine.
I could make some sense out of the post which you have given . Can you elaborate a little more on the same if possible. Apart from that, i wanted to get hold of the LPDIRECT3DSURFACE9 datastructure to run it on my machine and play it around with .
Can you help me with the same.
Regards,
Varun