Created
April 24, 2015 15:47
-
-
Save kreshikhin/b9c950b9ca982b7303f7 to your computer and use it in GitHub Desktop.
method compiled a shader code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func compileShader(code: String, shaderType: GLenum) -> GLuint { | |
var shader = glCreateShader(shaderType) | |
var cStringSource = (code as NSString).UTF8String | |
let stringfromutf8string = String.fromCString(cStringSource) | |
glShaderSource(shader, GLsizei(1), &cStringSource, nil) | |
glCompileShader(shader); | |
var isCompiled: GLint = 0 | |
glGetShaderiv(shader, GLenum(GL_COMPILE_STATUS), &isCompiled) | |
//NSLog(" is compiled : %i ", isCompiled) | |
if isCompiled == 0 { | |
var infolen: GLsizei = 0 | |
var stringLen: GLsizei = 1024 | |
glGetShaderiv(shader, GLenum(GL_INFO_LOG_LENGTH), &infolen) | |
var info: [GLchar] = Array(count: Int(stringLen), repeatedValue: GLchar(0)) | |
var lenActual: GLsizei = 0 | |
glGetShaderInfoLog(shader, stringLen, &lenActual, UnsafeMutablePointer(info)) | |
NSLog(String(UTF8String:info)!) | |
} | |
return shader | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment