Re: Change TEXTURE_ACCESS from TARGET to STREAMING
"rtrussell" <[email protected]>
| Newsgroups | gmane.comp.lib.sdl |
|---|---|
| Message-ID | <[email protected]> |
stewambo wrote:
> Any help is appreciated
This bug (https://bugzilla.libsdl.org/show_bug.cgi?id=2740) maybe? If it is, this is the workaround I use (it won't be a drop-in replacement for your code because it assumes a non-NULL rect):
Code:
// Bugfix version of SDL_RenderReadPixels (SDL Bugzilla 2740)
// Also much faster on some platforms because reading pixels from the
// default render target is faster than reading from a target texture.
// n.b. This bugfix routine cannot read a bigger rect than the window!
int Fix_RenderReadPixels(SDL_Renderer* renderer, const SDL_Rect* rect,
Uint32 format, void* pixels, int pitch)
{
int result;
SDL_Rect dst = {0, 0, rect->w, rect->h};
SDL_Texture *tex = SDL_GetRenderTarget (renderer);
SDL_SetRenderTarget(renderer, NULL);
SDL_RenderCopy(renderer, tex, rect, &dst);
result = SDL_RenderReadPixels(renderer, &dst, format, pixels, pitch);
SDL_SetRenderTarget(renderer, tex);
return result;
}
Richard.
_______________________________________________
SDL mailing list
[email protected]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org