"invalid context 0x0" from SDL_CreateRenderer() on Mojave?

Viewed 565

I've built a basic SDL 2 C++ program that creates a window and displays an image. I'm using Mac OS Mojave and Xcode. Everything works, but I get the following error messages:

2018-12-28 11:49:38.602582-0700 SDLTest[76555:7241475] [SDLTest]  
CGContextSetFillColorWithColor: invalid context 0x0. If you want to 
see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE 
environmental variable.
2018-12-28 11:49:38.602623-0700 SDLTest[76555:7241475] [SDLTest] 
CGContextGetCompositeOperation: invalid context 0x0. If you want to 
see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE 
environmental variable.
2018-12-28 11:49:38.602640-0700 SDLTest[76555:7241475] [SDLTest] 
CGContextSetCompositeOperation: invalid context 0x0. If you want to 
see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE  
environmental variable.
2018-12-28 11:49:38.602653-0700 SDLTest[76555:7241475] [SDLTest] 
CGContextFillRects: invalid context 0x0. If you want to see the 
backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental 
variable.
2018-12-28 11:49:38.602666-0700 SDLTest[76555:7241475] [SDLTest]
CGContextSetCompositeOperation: invalid context 0x0. If you want to
see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE  
environmental variable.

The errors are created when I add the call to SDL_CreateRenderer(). They are generated on startup, and again whenever I resize the window.

I haven't found any examples of SDL_CreateRenderer() resulting in these errors. I've heard that these errors can be ignored if everything works, but I'd rather deal with them now.

Any idea what is causing these errors, or how to deal with them?

My code:

//Initialize SDL
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
    cout << "SDL could not initialize: " << SDL_GetError();
}

//Create window
SDL_Window *window = NULL;
window = SDL_CreateWindow( "SDLTest", 
                           SDL_WINDOWPOS_CENTERED,  
                           SDL_WINDOWPOS_CENTERED,
                           640, 480,
                           SDL_WINDOW_RESIZABLE |  
                           SDL_WINDOW_ALLOW_HIGHDPI | 
                           SDL_WINDOW_SHOWN);
if( window == NULL 
{
    cout << "Window could not be created: " 
         << SDL_GetError() << endl;
}

//Create renderer - Errors appear after adding these lines
SDL_Renderer *renderer = NULL;
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if (renderer == NULL )
{
    cout << "Renderer could not be created: " 
         << SDL_GetError() << endl;
}
0 Answers
Related