We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4240

Summary: SDL_RenderReadPixels format = 0 does not work?
Product: SDL Reporter: kulkanie
Component: videoAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.8   
Hardware: x86_64   
OS: Linux   

Description kulkanie 2018-08-29 14:18:06 UTC
Hi,

there seems to be a 7 years old duplicate but I use a current version so I dare to submit this. I'm trying to create a simple shadow of a texture by setting r=g=b=0 and cutting alpha in half:

Uint32 pixels[w*h];
int pitch = w*sizeof(Uint32);
Uint8 r,g,b,a;
Uint32 pft = 0;

SDL_SetRenderTarget(mrc, tex); // holds a valid texture of type RGBA8888
SDL_QueryTexture(tex, &pft, 0, 0, 0); // needed for MapRGBA anyways
SDL_PixelFormat* pf = SDL_AllocFormat(pft); /* XXX free this later? */
SDL_RenderReadPixels(mrc, NULL, pft, pixels, pitch)

... doing my stuff ...

SDL_UpdateTexture(tex, NULL, pixels, pitch);

This works. But SDL_RenderReadPixels(mrc, NULL, 0, pixels, pitch) should work as well according to the docs but it does not. Even if I do not do anything in between reading and updating pixels. The pixels look greenish indicating a different pixel format although it should be the same like the one queried with SDL_QueryTexture as the texture is the current target as well.

Regards,
Michael Speck