App crashing because of glGetString
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:
- (B开发者_运维技巧OOL) 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.
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.
精彩评论