Reputation: 2873
Is there anyway (besides the documented slow method) to get access to the texture pixels from an SDL2 texture? SDL_RenderReadPixels
says Warning: this is a very slow method and should not be used frequently.
I want to point an ffmpeg AVFrame->data over to the texture pixels and have it encode what's in the texture. Basically, screen grab a texture after rendering and blending several textures together.
SDL_LockTexture() gives write-only access to the pixels. The docs also say not to expect pixel data to be present in the pointer returned to you.
Is it possible with av_hwframe_map
in ffmpeg?
I see lots of examples of decoding video to a texture, but I want to screen grab and encode an SDL2 texture without copying GPU data back to CPU memory.
If this is not possible in SDL2, I'm open to switching to SDL3, raylib, opengl or nearly anything else. After researching this for a few days, I'm getting the sense that OpenGL and/or Metal are the interop frameworks I should be looking at. Am I looking in the completely wrong direction trying to get SDL2/3 to allow me to interop with texture pixel data?
Upvotes: 0
Views: 106