func NewSkyShader() (*SkyShader, error) {
	program := gl.CreateProgram()

	// VertexShader
	vertexShader := gl.CreateShader(gl.VERTEX_SHADER)
	vertexSrc, freeVertexSrc := gl.Strs(skyShaderVertSrc)
	gl.ShaderSource(vertexShader, 1, vertexSrc, nil)
	freeVertexSrc()
	gl.CompileShader(vertexShader)
	var status int32
	gl.GetShaderiv(vertexShader, gl.COMPILE_STATUS, &status)
	if status == gl.FALSE {
		var logLength int32
		gl.GetShaderiv(vertexShader, gl.INFO_LOG_LENGTH, &logLength)
		log := strings.Repeat("\x00", int(logLength+1))
		gl.GetShaderInfoLog(vertexShader, logLength, nil, gl.Str(log))
		return nil, fmt.Errorf("failed to compile %v: %v", skyShaderOriginalFragmentSourceFile, log)
	}
	gl.AttachShader(program, vertexShader)

	// FragmentShader
	fragmentShader := gl.CreateShader(gl.FRAGMENT_SHADER)
	fragmentSrc, freeFragmentSrc := gl.Strs(skyShaderFragSrc)
	gl.ShaderSource(fragmentShader, 1, fragmentSrc, nil)
	freeFragmentSrc()
	gl.CompileShader(fragmentShader)
	gl.GetShaderiv(fragmentShader, gl.COMPILE_STATUS, &status)
	if status == gl.FALSE {
		var logLength int32
		gl.GetShaderiv(fragmentShader, gl.INFO_LOG_LENGTH, &logLength)
		log := strings.Repeat("\x00", int(logLength+1))
		gl.GetShaderInfoLog(fragmentShader, logLength, nil, gl.Str(log))
		return nil, fmt.Errorf("failed to compile %v: %v", skyShaderOriginalFragmentSourceFile, log)
	}
	gl.AttachShader(program, fragmentShader)

	// Linking
	gl.LinkProgram(program)
	gl.GetProgramiv(program, gl.LINK_STATUS, &status)
	if status == gl.FALSE {
		var logLength int32
		gl.GetProgramiv(program, gl.INFO_LOG_LENGTH, &logLength)
		log := strings.Repeat("\x00", int(logLength+1))
		gl.GetProgramInfoLog(program, logLength, nil, gl.Str(log))
		return nil, fmt.Errorf("failed to link %v: %v", skyShaderOriginalVertexSourceFile, log)
	}

	projectionLoc := gl.GetUniformLocation(program, gl.Str("projection\x00"))
	viewLoc := gl.GetUniformLocation(program, gl.Str("view\x00"))

	gl.DeleteShader(vertexShader)
	gl.DeleteShader(fragmentShader)

	gl.BindFragDataLocation(program, 0, gl.Str("outputColor\x00"))

	return &SkyShader{
		shader:     shader{program},
		Projection: uniforms.NewMatrix4(program, projectionLoc),
		View:       uniforms.NewMatrix4(program, viewLoc),
		DirectionalLightBuffer: buffers.NewBinding(2),
	}, nil
}
// NewSkyShader instantiates and initializes a shader object.
NewSkyShader instantiates and initializes a shader object.
// NewSkyShader instantiates and initializes a shader object .
func NewSkyShader() (*SkyShader, error) {
	program := gl.CreateProgram()
	vertexShader := gl.CreateShader(gl.VERTEX_SHADER)
	vertexSrc, freeVertexSrc := gl.Strs(skyShaderVertSrc)
	gl.ShaderSource(vertexShader, 1, vertexSrc, nil)
	freeVertexSrc()
	gl.CompileShader(vertexShader)
	var status int32
	gl.GetShaderiv(vertexShader, gl.COMPILE_STATUS, &status)
	if status == gl.FALSE {
		var logLength int32
		gl.GetShaderiv(vertexShader, gl.INFO_LOG_LENGTH, &logLength)
		log := strings.Repeat("\x00", int(logLength+1))
		gl.GetShaderInfoLog(vertexShader, logLength, nil, gl.Str(log))
		return nil, fmt.Errorf("failed to compile %v: %v", skyShaderOriginalFragmentSourceFile, log)
	}
	gl.AttachShader(program, vertexShader)
	fragmentShader := gl.CreateShader(gl.FRAGMENT_SHADER)
	fragmentSrc, freeFragmentSrc := gl.Strs(skyShaderFragSrc)
	gl.ShaderSource(fragmentShader, 1, fragmentSrc, nil)
	freeFragmentSrc()
	gl.CompileShader(fragmentShader)
	gl.GetShaderiv(fragmentShader, gl.COMPILE_STATUS, &status)
	if status == gl.FALSE {
		var logLength int32
		gl.GetShaderiv(fragmentShader, gl.INFO_LOG_LENGTH, &logLength)
		log := strings.Repeat("\x00", int(logLength+1))
		gl.GetShaderInfoLog(fragmentShader, logLength, nil, gl.Str(log))
		return nil, fmt.Errorf("failed to compile %v: %v", skyShaderOriginalFragmentSourceFile, log)
	}
	gl.AttachShader(program, fragmentShader)
	gl.LinkProgram(program)
	gl.GetProgramiv(program, gl.LINK_STATUS, &status)
	if status == gl.FALSE {
		var logLength int32
		gl.GetProgramiv(program, gl.INFO_LOG_LENGTH, &logLength)
		log := strings.Repeat("\x00", int(logLength+1))
		gl.GetProgramInfoLog(program, logLength, nil, gl.Str(log))
		return nil, fmt.Errorf("failed to link %v: %v", skyShaderOriginalVertexSourceFile, log)
	}
	projectionLoc := gl.GetUniformLocation(program, gl.Str("projection\x00"))
	viewLoc := gl.GetUniformLocation(program, gl.Str("view\x00"))
	gl.DeleteShader(vertexShader)
	gl.DeleteShader(fragmentShader)
	gl.BindFragDataLocation(program, 0, gl.Str("outputColor\x00"))
	return &SkyShader{
		shader:     shader{program},
		Projection: uniforms.NewMatrix4(program, projectionLoc),
		View:       uniforms.NewMatrix4(program, viewLoc),
		DirectionalLightBuffer: buffers.NewBinding(2),
	}, nil
}
func NewSkyShader ( ) ( * SkyShader , error ) { program := gl . CreateProgram ( ) vertexShader := gl . CreateShader ( gl . VERTEX_SHADER ) vertexSrc , freeVertexSrc := gl . Strs ( skyShaderVertSrc ) gl . ShaderSource ( vertexShader , 1 , vertexSrc , nil ) freeVertexSrc ( ) gl . CompileShader ( vertexShader ) var status int32 gl . GetShaderiv ( vertexShader , gl . COMPILE_STATUS , & status ) if status == gl . FALSE { var logLength int32 gl . GetShaderiv ( vertexShader , gl . INFO_LOG_LENGTH , & logLength ) log := strings . Repeat ( " \x00 " , int ( logLength + 1 ) ) gl . GetShaderInfoLog ( vertexShader , logLength , nil , gl . Str ( log ) ) return nil , fmt . Errorf ( " " , skyShaderOriginalFragmentSourceFile , log ) } gl . AttachShader ( program , vertexShader ) fragmentShader := gl . CreateShader ( gl . FRAGMENT_SHADER ) fragmentSrc , freeFragmentSrc := gl . Strs ( skyShaderFragSrc ) gl . ShaderSource ( fragmentShader , 1 , fragmentSrc , nil ) freeFragmentSrc ( ) gl . CompileShader ( fragmentShader ) gl . GetShaderiv ( fragmentShader , gl . COMPILE_STATUS , & status ) if status == gl . FALSE { var logLength int32 gl . GetShaderiv ( fragmentShader , gl . INFO_LOG_LENGTH , & logLength ) log := strings . Repeat ( " \x00 " , int ( logLength + 1 ) ) gl . GetShaderInfoLog ( fragmentShader , logLength , nil , gl . Str ( log ) ) return nil , fmt . Errorf ( " " , skyShaderOriginalFragmentSourceFile , log ) } gl . AttachShader ( program , fragmentShader ) gl . LinkProgram ( program ) gl . GetProgramiv ( program , gl . LINK_STATUS , & status ) if status == gl . FALSE { var logLength int32 gl . GetProgramiv ( program , gl . INFO_LOG_LENGTH , & logLength ) log := strings . Repeat ( " \x00 " , int ( logLength + 1 ) ) gl . GetProgramInfoLog ( program , logLength , nil , gl . Str ( log ) ) return nil , fmt . Errorf ( " " , skyShaderOriginalVertexSourceFile , log ) } projectionLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) viewLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) gl . DeleteShader ( vertexShader ) gl . DeleteShader ( fragmentShader ) gl . BindFragDataLocation ( program , 0 , gl . Str ( " \x00 " ) ) return & SkyShader { shader : shader { program } , Projection : uniforms . NewMatrix4 ( program , projectionLoc ) , View : uniforms . NewMatrix4 ( program , viewLoc ) , DirectionalLightBuffer : buffers . NewBinding ( 2 ) , } , nil }
NewSkyShader instantiates and initializes a shader object.
NewSkyShader instantiates and initializes a shader object .
// VertexShader // FragmentShader // Linking