func GetShaderInfoLog(s Shader) string { infoLen := GetShaderi(s, INFO_LOG_LENGTH) buf := C.malloc(C.size_t(infoLen)) defer C.free(buf) C.glGetShaderInfoLog(s.c(), C.GLsizei(infoLen), nil, (*C.GLchar)(buf)) return C.GoString((*C.char)(buf)) }
// GetInfoLog returns the information log for a shader object. // This method makes two OpenGL calls: one to get the info log size, and one to get the info log. func (s Shader) GetInfoLog() string { sz := s.Get(ShaderInfoLogLength) cstr := (*C.char)(C.malloc(C.size_t(sz + 1))) defer C.free(unsafe.Pointer(cstr)) C.glGetShaderInfoLog(C.GLuint(s), C.GLsizei(sz), nil, (*C.GLchar)(cstr)) return C.GoString(cstr) }
func GetShaderInfoLog( shader uint32, bufsize Sizei, length *Sizei, infolog *string) { s := glString(*infolog) C.glGetShaderInfoLog( C.GLuint(shader), C.GLsizei(bufsize), (*C.GLsizei)(length), s) infolog = goString(s) }
func GetShaderInfoLog(s Shader) (r0 string) { defer func() { errstr := errDrain() log.Printf("gl.GetShaderInfoLog(%v) %v%v", s, r0, errstr) }() infoLen := GetShaderi(s, INFO_LOG_LENGTH) buf := C.malloc(C.size_t(infoLen)) defer C.free(buf) C.glGetShaderInfoLog(s.c(), C.GLsizei(infoLen), nil, (*C.GLchar)(buf)) return C.GoString((*C.char)(buf)) }
func (shader Shader) GetInfoLog() string { var length C.GLint C.glGetShaderiv(C.GLuint(shader), C.GLenum(INFO_LOG_LENGTH), &length) // length is buffer size including null character if length > 1 { log := C.malloc(C.size_t(length)) defer C.free(log) C.glGetShaderInfoLog(C.GLuint(shader), C.GLsizei(length), nil, (*C.GLchar)(log)) return C.GoString((*C.char)(log)) } return "" }
func GetShaderInfoLog(shader C.GLuint) string { var logLen C.GLint C.glGetShaderiv(shader, C.GL_INFO_LOG_LENGTH, &logLen) var c C.GLchar logLenBytes := int(logLen) * int(unsafe.Sizeof(c)) log := C.malloc(C.size_t(logLenBytes)) if log == nil { panic("Failed to allocate shader log buffer") } defer C.free(log) C.glGetShaderInfoLog(C.GLuint(shader), C.GLsizei(logLen), (*C.GLsizei)(unsafe.Pointer(nil)), (*C.GLchar)(log)) return string(C.GoBytes(log, C.int(logLenBytes))) }
func (shader Shader) Compile() { C.glCompileShader(C.GLuint(shader)) status := C.GLint(0) C.glGetShaderiv(C.GLuint(shader), C.GL_COMPILE_STATUS, &status) if status != C.GL_TRUE { loglen := C.GLint(0) C.glGetShaderiv(C.GLuint(shader), C.GL_INFO_LOG_LENGTH, &loglen) log := (*C.GLchar)(C.malloc(C.size_t(loglen))) defer C.free(unsafe.Pointer(log)) C.glGetShaderInfoLog(C.GLuint(shader), C.GLsizei(loglen), nil, log) panic(fmt.Errorf("Failed to compile %s: %s", shader.Type(), C.GoString((*C.char)(log)))) } }
func GetShaderInfoLog( shader uint32, bufsize Sizei, length *Sizei) string { buffer := (*C.GLchar)(C.malloc(C.size_t(bufsize))) defer C.free(unsafe.Pointer(buffer)) C.glGetShaderInfoLog( C.GLuint(shader), C.GLsizei(bufsize), (*C.GLsizei)(length), buffer) return *goString(buffer) }
// 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 GetShaderInfoLog(shader uint, bufsize int) string { cs := CString("") //defer C.free(unsafe.Pointer(cs)) C.glGetShaderInfoLog(C.GLuint(shader), C.GLsizei(bufsize), nil, cs) return GoString(cs) }