由于 glGetString 应用程序崩溃
我正在运行 cocos2d-iphone 1.0.0 并遵循 本教程将 cocos2d 与 ARC 结合使用。不幸的是,每当我尝试将 TMX 平铺地图添加到 CCLayer 时,都会收到“SIGABRT”崩溃错误。我已将此问题追溯到 -(BOOL)checkForGLExtension:(NSString *)searchName
,甚至在该函数中进一步追溯到 NSString *extensionsString = [NSString stringWithCString:glExtensions 编码: NSASCIIStringEncoding ];
这是 checkForGLExtension 函数:
- (BOOL) checkForGLExtension:(NSString *)searchName {
// For best results, extensionsNames should be stored in your renderer so that it does not
// need to be recreated on each invocation.
NSLog(@"%@", glExtensions);
NSString *extensionsString = [NSString stringWithCString:glExtensions encoding: NSASCIIStringEncoding];
NSLog(@"%@", extensionsString);
NSArray *extensionsNames = [extensionsString componentsSeparatedByString:@" "]; }
NSString *extensionsString = [NSString 的
可能会导致应用程序崩溃。我还在日志中收到 encoding:
部分stringWithCString:glExtensions 编码: NSASCIIStringEncoding];GL_VENDOR
、GL_VERSION
、GL_RENDERER
甚至 glExtensions
的 NULL。
回顾 OpenGLES.framework 中的 gl.h 向我展示了这一点:
/* StringName */
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
其中所有这些都是 NULL。
I am running cocos2d-iphone 1.0.0 and following this tutorial to use cocos2d with ARC. Unfortunately, I am getting a 'SIGABRT' crash error whenever I try to add a TMX Tiled Map to a CCLayer. I have traced this problem down to the -(BOOL)checkForGLExtension:(NSString *)searchName
, and even further to within this function to NSString *extensionsString = [NSString stringWithCString:glExtensions encoding: NSASCIIStringEncoding];
Here is the checkForGLExtension function:
- (BOOL) checkForGLExtension:(NSString *)searchName {
// For best results, extensionsNames should be stored in your renderer so that it does not
// need to be recreated on each invocation.
NSLog(@"%@", glExtensions);
NSString *extensionsString = [NSString stringWithCString:glExtensions encoding: NSASCIIStringEncoding];
NSLog(@"%@", extensionsString);
NSArray *extensionsNames = [extensionsString componentsSeparatedByString:@" "]; }
The encoding:
part of NSString *extensionsString = [NSString stringWithCString:glExtensions encoding: NSASCIIStringEncoding];
is probably making the application crash. I am also receiving NULL in my logs for GL_VENDOR
, GL_VERSION
, GL_RENDERER
, and even glExtensions
.
Looking back at gl.h in the OpenGLES.framework shows me this:
/* StringName */
#define GL_VENDOR 0x1F00
#define GL_RENDERER 0x1F01
#define GL_VERSION 0x1F02
#define GL_EXTENSIONS 0x1F03
In which all of them are NULL.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
注意:我对 iOS 开发一无所知:)
从 glGetString 获取 NULL 通常意味着 OpenGL 上下文未绑定或创建不正确。你应该检查一下。还可以使用 glGetError 检查 GL 错误。
NOTE: I have no idea about iOS development :)
Getting NULL from glGetString usually means that the OpenGL context is not bound or was created incorrectly. You should check that. Also check for GL error with glGetError.