mirror of https://github.com/encounter/SDL.git
sync D3D_RenderReadPixels with D3D11_RenderReadPixels
- use the result of SDL_ConvertPixels to propagate error - get rid of the verbose error message of D3D11_RenderReadPixels in case SDL_ConvertPixels failed
This commit is contained in:
parent
3bef4a5da6
commit
2cfc83eab7
|
@ -1271,6 +1271,7 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
RECT d3drect;
|
||||
D3DLOCKED_RECT locked;
|
||||
HRESULT result;
|
||||
int status;
|
||||
|
||||
if (data->currentRenderTarget) {
|
||||
backBuffer = data->currentRenderTarget;
|
||||
|
@ -1305,7 +1306,7 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
return D3D_SetError("LockRect()", result);
|
||||
}
|
||||
|
||||
SDL_ConvertPixels(rect->w, rect->h,
|
||||
status = SDL_ConvertPixels(rect->w, rect->h,
|
||||
D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch,
|
||||
format, pixels, pitch);
|
||||
|
||||
|
@ -1313,7 +1314,7 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
|
||||
IDirect3DSurface9_Release(surface);
|
||||
|
||||
return 0;
|
||||
return status;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -2235,30 +2235,20 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
/* Copy the data into the desired buffer, converting pixels to the
|
||||
* desired format at the same time:
|
||||
*/
|
||||
if (SDL_ConvertPixels(
|
||||
status = SDL_ConvertPixels(
|
||||
rect->w, rect->h,
|
||||
D3D11_DXGIFormatToSDLPixelFormat(stagingTextureDesc.Format),
|
||||
textureMemory.pData,
|
||||
textureMemory.RowPitch,
|
||||
format,
|
||||
pixels,
|
||||
pitch) != 0) {
|
||||
/* When SDL_ConvertPixels fails, it'll have already set the format.
|
||||
* Get the error message, and attach some extra data to it.
|
||||
*/
|
||||
char errorMessage[1024];
|
||||
SDL_snprintf(errorMessage, sizeof(errorMessage), "%s, Convert Pixels failed: %s", __FUNCTION__, SDL_GetError());
|
||||
SDL_SetError("%s", errorMessage);
|
||||
goto done;
|
||||
}
|
||||
pitch);
|
||||
|
||||
/* Unmap the texture: */
|
||||
ID3D11DeviceContext_Unmap(data->d3dContext,
|
||||
(ID3D11Resource *)stagingTexture,
|
||||
0);
|
||||
|
||||
status = 0;
|
||||
|
||||
done:
|
||||
SAFE_RELEASE(backBuffer);
|
||||
SAFE_RELEASE(stagingTexture);
|
||||
|
|
Loading…
Reference in New Issue