Exemple #1
0
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()))}
}
Exemple #2
0
Fichier : gl.go Projet : 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
}
Exemple #3
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
}
Exemple #4
0
func CreateShader(ty Enum) Shader {
	return Shader{Value: uint32(C.glCreateShader(ty.c()))}
}
Exemple #5
0
func CreateShader(type_ Enum) uint32 {
	return uint32(C.glCreateShader(
		C.GLenum(type_)))
}
Exemple #6
0
func CreateShader(type_ GLenum) Shader { return Shader(C.glCreateShader(C.GLenum(type_))) }
Exemple #7
0
func CreateShader(stype ShaderType) Shader {
	return Shader(C.glCreateShader(C.GLenum(stype)))
}
Exemple #8
0
// CreateShader creates a shader object.
func CreateShader(kind ShaderKind) Shader {
	sh := C.glCreateShader(C.GLenum(kind))
	return Shader(sh)
}
Exemple #9
0
func CreateShader(type_ uint) uint {
	return uint(C.glCreateShader(C.GLenum(type_)))
}