#define EXTENSION_STRING "#extension GL_OES_standard_derivatives : enable"
static NSString * g_extensionStr = @EXTENSION_STRING;
- (BOOL)compileShader:(GLuint *)shader type:(GLenum)type byteArray:(const GLchar *)source
{
GLint status;
if (!source)
return NO;
// BEGIN workaround for Xcode 7 bug
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];
}
const GLchar *sources[] = {
(hasExtension ? EXTENSION_STRING "\n" : ""),
#ifdef __CC_PLATFORM_IOS
(type == GL_VERTEX_SHADER ? "precision highp float;\n" : "precision mediump float;\n"),
#endif
"uniform mat4 CC_PMatrix;\n"
"uniform mat4 CC_MVMatrix;\n"
"uniform mat4 CC_MVPMatrix;\n"
"uniform vec4 CC_Time;\n"
"uniform vec4 CC_SinTime;\n"
"uniform vec4 CC_CosTime;\n"
"uniform vec4 CC_Random01;\n"
"//CC INCLUDES END\n\n",
source,
};
// END workaround for Xcode 7 bug