Пример #1
0
func loadShader(shaderType gl.Enum, src string) (gl.Shader, error) {
	shader := gl.CreateShader(shaderType)
	if shader.Value == 0 {
		return gl.Shader{}, fmt.Errorf("glutil: could not create shader (type %v)", shaderType)
	}
	gl.ShaderSource(shader, src)
	gl.CompileShader(shader)
	if gl.GetShaderi(shader, gl.COMPILE_STATUS) == 0 {
		defer gl.DeleteShader(shader)
		return gl.Shader{}, fmt.Errorf("shader compile: %s", gl.GetShaderInfoLog(shader))
	}
	return shader, nil
}
Пример #2
0
func loadShader(shaderType gl.Enum, source string) gl.Shader {
	log.Print("Creating shader")
	handle := gl.CreateShader(shaderType)

	log.Print("Created shader")
	gl.ShaderSource(handle, source)
	gl.CompileShader(handle)

	log.Print("Compiled shader")
	log.Print(handle)
	// TODO: Was GetShaderiv
	gl.GetShaderi(handle, gl.COMPILE_STATUS)

	log.Print("Got shader")
	return handle
}