func CreateShader(ty Enum) (r0 Shader) { defer func() { errstr := errDrain() log.Printf("gl.CreateShader(%v) %v%v", ty, r0, errstr) }() return Shader{Value: uint32(C.glCreateShader(ty.c()))} }
// NewShader creates a shader object of type typ, loads it with source code src and compiles it func NewShader(typ int, src string) (Shader, error) { var val C.GLint shad := C.glCreateShader(C.GLenum(typ)) s := (*C.GLchar)(C.CString(src)) C.glShaderSource(shad, 1, &s, nil) C.glCompileShader(shad) C.glGetShaderiv(shad, COMPILE_STATUS, &val) if val != TRUE { C.glGetShaderiv(shad, INFO_LOG_LENGTH, &val) buf := make([]C.GLchar, val+1) C.glGetShaderInfoLog(shad, C.GLsizei(val), nil, &buf[0]) C.glDeleteShader(shad) return Shader(0), errors.New(C.GoString((*C.char)(&buf[0]))) } return Shader(shad), nil }
func loadShader(shaderType C.GLenum, source string) C.GLuint { handle := C.glCreateShader(shaderType) if handle == 0 { panic(fmt.Errorf("Failed to create shader of type %v", shaderType)) } sourceC := C.CString(source) defer C.free(unsafe.Pointer(sourceC)) C.glShaderSource(handle, 1, (**C.GLchar)(unsafe.Pointer(&sourceC)), (*C.GLint)(unsafe.Pointer(nil))) C.glCompileShader(handle) var compiled C.GLint C.glGetShaderiv(handle, C.GL_COMPILE_STATUS, &compiled) if compiled != C.GL_TRUE { log := GetShaderInfoLog(handle) panic(fmt.Errorf("Failed to compile shader: %v, shader: %v", log, source)) } return handle }
func CreateShader(ty Enum) Shader { return Shader{Value: uint32(C.glCreateShader(ty.c()))} }
func CreateShader(type_ Enum) uint32 { return uint32(C.glCreateShader( C.GLenum(type_))) }
func CreateShader(type_ GLenum) Shader { return Shader(C.glCreateShader(C.GLenum(type_))) }
func CreateShader(stype ShaderType) Shader { return Shader(C.glCreateShader(C.GLenum(stype))) }
// CreateShader creates a shader object. func CreateShader(kind ShaderKind) Shader { sh := C.glCreateShader(C.GLenum(kind)) return Shader(sh) }
func CreateShader(type_ uint) uint { return uint(C.glCreateShader(C.GLenum(type_))) }