How to capture the screen in DirectX 9 to a raw bitmap in memory without using D3DXSaveSurfaceToFile
Posted
by
cloudraven
on Game Development
See other posts from Game Development
or by cloudraven
Published on 2012-11-01T07:38:21Z
Indexed on
2012/11/01
11:16 UTC
Read the original article
Hit count: 264
I know that in OpenGL I can do something like this
glReadBuffer( GL_FRONT );
glReadPixels( 0, 0, _width, _height, GL_RGB, GL_UNSIGNED_BYTE, _buffer );
And its pretty fast, I get the raw bitmap in _buffer. When I try to do this in DirectX. Assuming that I have a D3DDevice object I can do something like this
if (SUCCEEDED(D3DDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackbuffer))) {
HResult hr = D3DXSaveSurfaceToFileA(filename, D3DXIFF_BMP, pBackbuffer, NULL, NULL);
But D3DXSaveSurfaceToFile is pretty slow, and I don't need to write the capture to disk anyway, so I was wondering if there was a faster way to do this
© Game Development or respective owner