예제 #1
0
파일: gl_opengles.go 프로젝트: tanema/amore
func GetProgramInfoLog(p Program) string {
	infoLen := GetProgrami(p, INFO_LOG_LENGTH)
	buf := C.malloc(C.size_t(infoLen))
	C.free(buf)
	C.glGetProgramInfoLog(p.c(), C.GLsizei(infoLen), nil, (*C.GLchar)(buf))
	return C.GoString((*C.char)(buf))
}
예제 #2
0
파일: gl.go 프로젝트: extrame/gl
// Link links the attached shader objects
func (p *Program) Link() error {
	var val, val2 C.GLint
	C.glLinkProgram(p.i)
	C.glGetProgramiv(p.i, LINK_STATUS, &val)
	if val != TRUE {
		C.glGetProgramiv(p.i, INFO_LOG_LENGTH, &val)
		buf := make([]C.GLchar, val+1)
		C.glGetProgramInfoLog(p.i, C.GLsizei(val), nil, &buf[0])
		return errors.New(C.GoString((*C.char)(&buf[0])))
	}
	p.attr = make(map[string]C.GLuint)
	C.glGetProgramiv(p.i, ACTIVE_ATTRIBUTES, &val)
	C.glGetProgramiv(p.i, ACTIVE_ATTRIBUTE_MAX_LENGTH, &val2)
	buf := make([]C.char, val2)
	for i := C.GLuint(0); i < C.GLuint(val); i++ {
		C.glGetActiveAttrib(p.i, i, C.GLsizei(val2), nil, nil, nil, (*C.GLchar)(&buf[0]))
		p.attr[C.GoString(&buf[0])] = C.GLuint(C.glGetAttribLocation(p.i, (*C.GLchar)(&buf[0])))
	}
	p.uni = make(map[string]C.GLint)
	C.glGetProgramiv(p.i, ACTIVE_UNIFORMS, &val)
	C.glGetProgramiv(p.i, ACTIVE_UNIFORM_MAX_LENGTH, &val2)
	buf = make([]C.char, val2)
	for i := C.GLuint(0); i < C.GLuint(val); i++ {
		C.glGetActiveUniform(p.i, i, C.GLsizei(val2), nil, nil, nil, (*C.GLchar)(&buf[0]))
		p.uni[C.GoString(&buf[0])] = C.glGetUniformLocation(p.i, (*C.GLchar)(&buf[0]))
	}
	return nil
}
예제 #3
0
파일: shader.go 프로젝트: eaburns/gl
// GetInfoLog returns the information log for a program object.
// This method makes two OpenGL calls: one to get the info log size, and one to get the info log.
func (p Program) GetInfoLog() string {
	sz := p.Get(ProgramInfoLogLength)
	cstr := (*C.char)(C.malloc(C.size_t(sz + 1)))
	defer C.free(unsafe.Pointer(cstr))
	C.glGetProgramInfoLog(C.GLuint(p), C.GLsizei(sz), nil, (*C.GLchar)(cstr))
	return C.GoString(cstr)
}
예제 #4
0
파일: es2.go 프로젝트: nick-fedesna/egles
func GetProgramInfoLog(program uint, bufsize int) string {
	cs := CString("")
	//defer C.free(unsafe.Pointer(cs))
	C.glGetProgramInfoLog(C.GLuint(program), C.GLsizei(bufsize), nil, cs)
	return GoString(cs)

}
예제 #5
0
파일: gles2.go 프로젝트: remogatto/egles
func GetProgramInfoLog(
	program uint32, bufsize Sizei,
	length *Sizei, infolog *string) {
	s := glString(*infolog)
	C.glGetProgramInfoLog(
		C.GLuint(program),
		C.GLsizei(bufsize),
		(*C.GLsizei)(length),
		s)
	infolog = goString(s)
}
예제 #6
0
파일: gldebug.go 프로젝트: Miaque/mojo
func GetProgramInfoLog(p Program) (r0 string) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.GetProgramInfoLog(%v) %v%v", p, r0, errstr)
	}()
	infoLen := GetProgrami(p, INFO_LOG_LENGTH)
	buf := C.malloc(C.size_t(infoLen))
	C.free(buf)
	C.glGetProgramInfoLog(p.c(), C.GLsizei(infoLen), nil, (*C.GLchar)(buf))
	return C.GoString((*C.char)(buf))
}
예제 #7
0
func GetProgramInfoLog(program C.GLuint) string {
	var logLen C.GLint
	C.glGetProgramiv(program, 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.glGetProgramInfoLog(C.GLuint(program), C.GLsizei(logLen), (*C.GLsizei)(unsafe.Pointer(nil)), (*C.GLchar)(log))
	return string(C.GoBytes(log, C.int(logLenBytes)))
}
예제 #8
0
파일: program.go 프로젝트: kanelbulle/gl
func (program Program) GetInfoLog() string {
	var length C.GLint
	C.glGetProgramiv(C.GLuint(program), 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.glGetProgramInfoLog(C.GLuint(program), C.GLsizei(length), nil, (*C.GLchar)(log))
		return C.GoString((*C.char)(log))
	}
	return ""

}
예제 #9
0
파일: shader.go 프로젝트: jackscan/go-gles3
func (program *Program) Link() {
	C.glLinkProgram(program.id)

	status := C.GLint(0)
	C.glGetProgramiv(program.id, C.GL_LINK_STATUS, &status)

	if status != C.GL_TRUE {
		loglen := C.GLint(0)
		C.glGetProgramiv(program.id, C.GL_INFO_LOG_LENGTH, &loglen)
		log := (*C.GLchar)(C.malloc(C.size_t(loglen)))
		defer C.free(unsafe.Pointer(log))
		C.glGetProgramInfoLog(program.id, C.GLsizei(loglen), nil, log)
		panic(fmt.Errorf("Failed to link shader: %s", C.GoString((*C.char)(log))))
	}
}
예제 #10
0
func GetProgramInfoLog(
	program uint32, bufsize Sizei,
	length *Sizei) string {

	buffer := (*C.GLchar)(C.malloc(C.size_t(bufsize)))
	defer C.free(unsafe.Pointer(buffer))

	C.glGetProgramInfoLog(
		C.GLuint(program),
		C.GLsizei(bufsize),
		(*C.GLsizei)(length),
		buffer)

	return *goString(buffer)
}