My app used to use OpenGL directly for rendering, but as of SDL3 is using the SDL renderers. Unfortunately, because each SDL window has a separate renderer, I don’t seem to be able to use the same texture on different windows.
What I’m attempting is to make a copy of a texture on the new renderer, and use that. But I’m bogging down trying to find an efficient way to make a copy of a texture for another renderer.
What I settled on is to, when I create a texture, save it in a global map, with structures that contain the Texture as well a Surface and the original pixels (so the Surface doesn’t get messed up).
Then I have a map in each window, which when I’m called upon to render a texture, I look to see if the texture is in my window map. If it is, great; I just use it.
If it isn’t, I look to see if the texture was created with the current renderer. If so, I stash it in the window map and use it.
Otherwise, I create a new texture from the surface etc in the global map structure, stash it in the window map, and return it.
I have the same problem, I have textures for font and icons that I want to use in multiple windows. My solution was the same as yours, check if I have a texture, otherwise create one from cache, if it isnt there I need to load/rebuild it