libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.55k stars 1.77k forks source link

Add SDL_AcquireCameraFrame as SDL_Texture 0-copy texture. #9826

Open 1bsyl opened 4 months ago

1bsyl commented 4 months ago

Currently the Camera API grabs software frames, but it's possible to get 0-copy textures instead. Which is faster if you only want to render the frames.

suggestion is to add:

SDL_Texture * SDL_AcquireCameraFrame0Copy(
       SDL_Camera *camera, 
       Uint64 *timestampNS, 
       SDL_Renderer *renderer);

So that return value is a 0-copy texture for the SDL_Renderer. ( some example to use 0-copy textures with cameras: https://github.com/libsdl-org/SDL/pull/8565 testffmpeg.c also shows 0-copy textures creations and update. )

slouken commented 4 months ago

I would probably return properties that can be used to create a texture or interop with some other display mechanism, rather than tie it directly to an SDL renderer.