Link log: ERROR: Compiled vertex shader was corrupt.
ERROR: Compiled fragment shader was corrupt.
经过排查,是swift中的String 转为 UnsafePointer<GLchar>? 过程,出现了未知问题。
作者原方法(OpenGLRendering.swift文件中的String扩展):
func withGLChar(_ operation:(UnsafePointer<GLchar>) -> ()) {
if let value = self.cString(using:String.Encoding.utf8) {
operation(UnsafePointer<GLchar>(value))
} else {
fatalError("Could not convert this string to UTF8: \(self)")
}
}
修改为:
func withGLChar(_ operation:(UnsafePointer<GLchar>) -> ()) {
if let value = NSString.init(string: self).utf8String {
operation(value)
} else {
fatalError("Could not convert this string to UTF8: \(self)")
}
}
使用NSString 即可,原因未知
参考提交:https://github.com/liuqiaohong0515/GPUImage2/commit/5a3c23a30b54d459488da351c8e6133cfa0baf75