Re: Change TEXTURE_ACCESS from TARGET to STREAMING
Sam Lantinga <[email protected]>
| Newsgroups | gmane.comp.lib.sdl |
|---|---|
| Message-ID | <CACC3sbGK41s0jeFe6u5rghWKFa2j9O_VT0MNvCGediRqjL7AwQ@mail.gmail.com> |
Can you try the latest SDL snapshot? I think this is fixed: http://www.libsdl.org/tmp/SDL-2.0.zip On Sun, Oct 9, 2016 at 12:54 PM, stewambo <[email protected]> wrote: > Hey, > I need to change the TEXTURE_ACCESS of some textures from TARGET to > STREAMING, because i want to access and change individual pixels. My best > guess was to use SDL_RenderReadPixels of my TARGET-texture and write the > pixel data into a new STREAMING-texture, but the resulting > STREAMING-texture is flipped upside-down and i don't really know why that > happens (maybe because open_gl has it's origin in the bottom-left and not > top-left?) and how to fix it... > My code looks like this: > > > > Code: > > > SDL_Texture* targetTexture = SDL_CreateTexture(renderer, > SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, width, height); > SDL_SetRenderTarget(renderer, targetTexture); > //render some things onto targetTexture > SDL_Texture* streamingTexture = SDL_CreateTexture( renderer, > SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, width, height ); > void* streamingPixels; > int streamingPitch; > SDL_LockTexture( streamingTexture, NULL, &streamingPixels, &streamingPitch > ); > SDL_RenderReadPixels(renderer, NULL, SDL_PIXELFORMAT_RGBA8888, > streamingPixels, streamingPitch); > SDL_UnlockTexture( streamingTexture ); > SDL_SetRenderTarget(renderer, NULL); > > > > > Any help is appreciated [image: Smile] > > _______________________________________________ > SDL mailing list > [email protected] > http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org > > _______________________________________________ SDL mailing list [email protected] http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org