Hello,
Recently there was a renderer change Make it clear that you can't mix 2D rendering and the window surface API · libsdl-org/SDL@36033e3 · GitHub which seemed to make renderer creation fail in case software renderer was created earlier. I wonder now should this be fixed on application side by checking and destroying potential window surface, or should SDL_DestroyRenderer remove window surface as well?
Example code (tested on Linux Mint 64-bit). It should print:
Failed to create 2nd renderer: Surface already associated with window
#include <SDL.h>
int main()
{
if (SDL_Init(SDL_INIT_VIDEO) == 0) {
SDL_Window* w = SDL_CreateWindow("test", 100, 100, 100, 100, 0);
if (w) {
SDL_Renderer* r = SDL_CreateRenderer(w, -1, SDL_RENDERER_SOFTWARE);
if (r) {
SDL_DestroyRenderer(r);
//SDL_DestroyWindowSurface(w);
r = SDL_CreateRenderer(w, -1, 0);
if (r) {
printf("Created both renderers\n");
} else {
printf("Failed to create 2nd renderer: %s\n", SDL_GetError());
}
SDL_DestroyRenderer(r);
} else {
printf("Failed to create 1st renderer: %s\n", SDL_GetError());
}
SDL_DestroyWindow(w);
}
SDL_Quit();
}
return 0;
}