SDL2_gfx not working with multiple windows?

Hi guys,

I’m trying to use SDL2_gfx to render two texts to two separate windows but it gives me “Texture was not created with this renderer”. Does anybody know why? Is there a specific thing that I didn’t do right?

I have a minimal example here:


I’m wondering if it’s to do with the way SDL2_gfx caches the character textures. If it is, you may find that clearing the cache between the two calls to stringRGBA will help; you can do that as follows:

if (stringRGBA(r1, 0, 0, "testing", 255, 255, 255, 255) != 0)
    goto error;

gfxPrimitivesSetFontZoom(1, 1); // clear character texture cache

if (stringRGBA(r2, 0, 0, "testing", 255, 255, 255, 255) != 0)
    goto error;

Obviously clearing the cache too often will hit performance so if this works you may want to avoid switching between the windows as far as possible.

Oh wow, you’re right. I don’t have gfxPrimitivesSetFontZoom for some reason but using gfxPrimitivesSetFont(NULL, 0, 0) instead does solve the problem. Thank you! I’ll keep in mind about the performance.