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 - SDL_RenderReadPixels format = 0 does not work?
Summary: SDL_RenderReadPixels format = 0 does not work?
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.8
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-29 14:18 UTC by kulkanie
Modified: 2018-08-29 14:18 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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