c++ - Mojave 上 SDL_CreateRenderer() 的“无效上下文 0x0”?
问题描述
我已经构建了一个基本的 SDL 2 C++ 程序,它可以创建一个窗口并显示一个图像。我正在使用 Mac OS Mojave 和 Xcode。一切正常,但我收到以下错误消息:
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.
当我添加对 SDL_CreateRenderer() 的调用时会创建错误。它们是在启动时生成的,并且在我调整窗口大小时再次生成。
我没有找到任何导致这些错误的 SDL_CreateRenderer() 示例。我听说如果一切正常,可以忽略这些错误,但我宁愿现在处理它们。
知道是什么导致了这些错误,或者如何处理它们?
我的代码:
//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;
}
解决方案
推荐阅读
- neo4j - Neo4j 从图中获取嵌套对象数组的响应
- elixir - 为什么 Ecto.Repo 进程不需要`send/receive`?
- javascript - 如何在nestjs中使用自定义类文件维护nestjs的规则
- file - NetSuite:读取文件柜中的csv类型文件时出现乱码
- gcc - 使用 ARM GCC 时,什么是“nosys”、“nano”、“rdimon”术语?
- machine-learning - 确定梯度下降的起点
- c - .pxd 文件中的 Cython 构造函数重载错误:工厂函数的“C 方法的自参数与父类型不匹配”
- python-3.x - Pandas 跨行的最小值和最大值
- java - Android:如何在 MapBox 中添加自定义标记?
- elixir - 我如何知道 Phoenix 和 Absinthe 在进程生成和消息发送方面正在做什么?