Exemplo n.º 1
0
func compile(source string, ty int) gl.Shader {
	shader := gl.CreateShader(gl.Enum(ty))
	gl.ShaderSource(shader, source)

	gl.CompileShader(shader)
	if gl.GetShaderi(shader, gl.COMPILE_STATUS) != gl.TRUE {
		panic(gl.GetShaderInfoLog(shader))
	}
	checkError()

	return shader
}
Exemplo n.º 2
0
func loadShader(shaderType gl.Enum, src string) (gl.Shader, error) {
	shader := gl.CreateShader(shaderType)
	if !shader.Valid() {
		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
}
Exemplo n.º 3
0
func dumpShaderError(shader gl.Shader, name, typeName string) error {
	str := gl.GetShaderInfoLog(shader)
	msg := fmt.Sprintf("Shader %s/%s error:\n%s\n", name, typeName, str)
	dumpLog(msg)
	return errors.New(msg)
}