環境
cocos2d for iPhone 2.1Xcode 7.3
状況
実行時にクラッシュします。cocos2d: ERROR: Failed to compile shader cocos2d: ERROR: 0:12: '' : syntax error: #extension must always be before any non-preprocessor tokens
対応
CCGLProgram.m の (BOOL)compileShader メソッドを編集します。// ADD Start #define EXTENSION_STRING "#extension GL_OES_standard_derivatives : enable" static NSString * g_extensionStr = @EXTENSION_STRING; // ADD End- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type byteArray:(const GLchar *)source { GLint status; if (!source) return NO;// ADD Start BOOL hasExtension = NO; NSString *sourceStr = [NSString stringWithUTF8String:source]; if([sourceStr rangeOfString:g_extensionStr].location != NSNotFound) { hasExtension = YES; NSArray *strs = [sourceStr componentsSeparatedByString:g_extensionStr]; assert(strs.count == 2); sourceStr = [strs componentsJoinedByString:@"\n"]; source = (GLchar *)[sourceStr UTF8String]; } // ADD Endconst GLchar *sources[] = {// ADD Start (hasExtension ? EXTENSION_STRING "\n" : ""), // ADD End#ifdef __CC_PLATFORM_IOS