imgui icon indicating copy to clipboard operation
imgui copied to clipboard

SDL3 SDL_Renderer multiviewport fix for non-shared textures (for fonts only)

Open HDAKFD opened this issue 1 year ago • 3 comments

Very nasty fix for SDL3 not being able to share fonts between renderers, but it works.

Though i think this needs better solution, pointer comparing isn't the best approach

SDL_Texture * tex = (SDL_Texture*)pcmd->GetTexID();

if (tex == bd->FontTexture)
{
    if (texture != nullptr)
    {
        tex = texture;
    }
}

HDAKFD avatar Jun 09 '24 10:06 HDAKFD

This is probably reliant on certain backend and os and is unlikely to work with all of them supported by SDL.

ocornut avatar Jun 09 '24 11:06 ocornut

This is probably reliant on certain backend and os and is unlikely to work with all of them supported by SDL.

It might be, also after doing some research i found out that there is ways to copy the textures between renderers rather than recreating them.

Though SDL3 still to this date does not support sharing textures between 2 different SDL_Renderer instances without any extra code. So something needs to be done about it.

HDAKFD avatar Jun 09 '24 11:06 HDAKFD

It’s well known what needs to be done, but SDL Renderer for some backends creates one device per renderer making the textures non sharable. See my link https://github.com/ocornut/imgui/issues/7675#issuecomment-2156454617 I can tell your PR isn’t going to work accross multiple renderers.

ocornut avatar Jun 09 '24 12:06 ocornut