Fixed bug 2685 - SDL_RenderReadPixels() doesn't work with offscreen targets

Andreas Falkenhahn

SDL_RenderReadPixels() doesn't seem to work when trying to read pixels from a texture that has been created using SDL_TEXTUREACCESS_TARGET and has been selected as the render target using SDL_SetRenderTarget().

I am attaching a small program that demonstrates the issue. I get the following result here:

READ PIXEL RETURN: 0 --- COLOR CHECK: ff000000

But it should be:

READ PIXEL RETURN: 0 --- COLOR CHECK: ffff0000

Tested with SDL 2.0.3 on Windows 7.
This commit is contained in:
Sam Lantinga 2014-08-17 14:44:53 -07:00
parent 2e3c778ef5
commit de3d381cb6

View file

@ -1831,9 +1831,10 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
D3DLOCKED_RECT locked; D3DLOCKED_RECT locked;
HRESULT result; HRESULT result;
result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer); if (data->currentRenderTarget) {
if (FAILED(result)) { backBuffer = data->currentRenderTarget;
return D3D_SetError("GetBackBuffer()", result); } else {
backBuffer = data->defaultRenderTarget;
} }
result = IDirect3DSurface9_GetDesc(backBuffer, &desc); result = IDirect3DSurface9_GetDesc(backBuffer, &desc);
@ -1874,7 +1875,6 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
IDirect3DSurface9_UnlockRect(surface); IDirect3DSurface9_UnlockRect(surface);
IDirect3DSurface9_Release(surface); IDirect3DSurface9_Release(surface);
IDirect3DSurface9_Release(backBuffer);
return 0; return 0;
} }