Re: reading pixels from a TARGET texture
Sanette <[email protected]>
| Newsgroups | gmane.comp.lib.sdl |
|---|---|
| Message-ID | <[email protected]> |
Le 05/08/2016 à 13:41, rtrussell a écrit :
> To work around the first issue, and to ameliorate the second, I use this slightly more complex method (when the rectangle you want to read is no larger than the window): > > > > > > > > > Code: > int 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.
this seems to be a nice trick for textures that fit the window. Thanks.
_______________________________________________
SDL mailing list
[email protected]
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org