我正在制作一个小型 SDL/OpenGL 游戏,用户可以在其中使用可可打开文件对话框 (NSOpenPanel) 选择地图/关卡。但是,这样做时,每次 glClear 都会收到错误“帧缓冲区操作无效”。当我获得帧缓冲区的状态(使用 glCheckFramebufferStatus)时,它是 GL_FRAMEBUFFER_UNDEFINED (0x8219)。我还注意到我不需要显示打开的面板(使用 runModal),而只需创建它,就会发生错误。可以在 SDL_SetVideoMode 之前创建它,但不能在之后创建。奇怪的是,NSSavePanel 根本不会引起这些问题。有任何想法吗?
编辑:添加了一些代码来显示一个精简的 test-init 方法:
SDL_Init( SDL_INIT_VIDEO );
m_pScreen = SDL_SetVideoMode( 800, 600, 32, SDL_OPENGL );
// this section causes the problem. Works well if I change the NSOpenPanel to a NSSavePanel
@autoreleasepool {
NSOpenPanel *openPanel = [[NSOpenPanel openPanel] retain];
[openPanel runModal];
[openPanel release];
}
int number = glCheckFramebufferStatus(GL_FRAMEBUFFER);
assert(number == GL_FRAMEBUFFER_COMPLETE); // crash here