I have a situation where i use a texture to render an image on the screen with HW accel to consume few CPUs.
The problem is if i draw some objects, it will be drawn on the screen and i want to have the image data (“imageData”) with the object drawn on it and be able to send, save, or manipulate it.
The first thing that comes to my mind is to use texture created with the flag SDL_TEXTUREACCESS_TARGET, according to the documentation i can render it to texture instead of the screen, and then i can have the final image with a rectangle drawn.
If i create texture with SDL_TEXTUREACCESS_TARGET, SDL3 crash (core dump) here:
I haven’t found a way to make this work, using SDL_SetRenderTarget still crashes.
The second situation is if “imageData” is a dma buf, isn’t there a way to pass fd to it so there is 0-copy involved?
Regarding the first situation (SDL_TEXTUREACCESS_TARGET), drawing on the texture, i was thinking something like this:
SDL_LockTexture(texture, 0, (void **)&texture_data, &texture_pitch); memcpy(texture_data, (void *)imageData, frameSize_texture); SDL_UnlockTexture(texture); . . Draw objects on texture . . Render it on screen . // // copy the texture data back to my imageData // SDL_LockTexture(texture, 0, (void **)&texture_data, &texture_pitch); memcpy((void *)imageData, texture_data, frameSize_texture); SDL_UnlockTexture(texture);
The left image is the “imageData”, and the right one is the objects drawn on screen.
“imageData” in the link is not dma buf but the NEW updated version is.
“imageData” is RGB24 , dma buf.