Ejemplo n.º 1
0
func CompileShader(s Shader) {
	defer func() {
		errstr := errDrain()
		log.Printf("gl.CompileShader(%v) %v", s, errstr)
	}()
	C.glCompileShader(s.c())
}
Ejemplo n.º 2
0
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))))
	}
}
Ejemplo n.º 3
0
Archivo: gl.go Proyecto: extrame/gl
// 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
}
Ejemplo n.º 4
0
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
}
Ejemplo n.º 5
0
func CompileShader(s Shader) {
	C.glCompileShader(s.c())
}
Ejemplo n.º 6
0
func CompileShader(
	shader uint32) {
	C.glCompileShader(
		C.GLuint(shader))

}
Ejemplo n.º 7
0
Archivo: shader.go Proyecto: vivicai/gl
func (shader Shader) Compile() { C.glCompileShader(C.GLuint(shader)) }