I recently started messing around with the standard SDL2 rendering calls now that a metal backend has been added to the macOS version. I set up a basic SDL2 app, load up an image using SDL_Image, and use SDL_RenderCopy() to put it on the screen.
So far so good. Now I enable the metal backend by calling:
Before SDL_Init() (I’ve tried doing it before creating a renderer as well, no luck). Now the image doesn’t appear. The screen clears to whatever color I tell it via SDL_RenderClear(), but no mater what I’ve tried I can’t seem to get the image to render.
If I comment out “SDL_SetHintWithPriority()” SDL loads up the standard OpenGL backend and everything appears as expected.
Has anyone encountered this issue before? Am I missing something? Is there a good example somewhere of setting up metal rendering with SDL2 2.0.8?
Ok after doing a bit more digging I came across this thread:
I’m guessing this is a known bug. I wrote this little workaround that seems to get metal rendering up and running. Hope someone in the future finds it useful until it’s hopefully fixed in the next release:
// After creating window and renderer (i.e. gCurrentWindow, gCurrentRenderer), do this.
// HACK: This is a work around for a bug in SDL2.
int w, h;
SDL_GetWindowSize(gCurrentWindow, &w, &h);
SDL_SetWindowSize(gCurrentWindow, w, h);