由于 glGetString 应用程序崩溃

发布于 2024-11-29 15:08:39 字数 1493 浏览 1 评论 0原文

我正在运行 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_VENDORGL_VERSIONGL_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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烏雲後面有陽光 2024-12-06 15:08:39

注意:我对 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文