コード例 #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
ファイル: game.go プロジェクト: Congenital/goandroid
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
ファイル: opengles2.go プロジェクト: remogatto/opengles2
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)
}