How to capture the screen in DirectX 9 to a raw bitmap in memory without using D3DXSaveSurfaceToFile
- by cloudraven
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