func NewPipShader() (*PipShader, error) {
	program := gl.CreateProgram()

	// VertexShader
	vertexShader := gl.CreateShader(gl.VERTEX_SHADER)
	vertexSrc, freeVertexSrc := gl.Strs(pipShaderVertSrc)
	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", pipShaderOriginalVertexSourceFile, log)
	}
	gl.AttachShader(program, vertexShader)

	// FragmentShader
	fragmentShader := gl.CreateShader(gl.FRAGMENT_SHADER)
	fragmentSrc, freeFragmentSrc := gl.Strs(pipShaderFragSrc)
	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", pipShaderOriginalFragmentSourceFile, 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", pipShaderOriginalVertexSourceFile, log)
	}

	projectionLoc := gl.GetUniformLocation(program, gl.Str("projection\x00"))
	depthMapLoc := gl.GetUniformLocation(program, gl.Str("textureSampler\x00"))
	nearFarLoc := gl.GetUniformLocation(program, gl.Str("nearFar\x00"))

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

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

	return &PipShader{
		shader:     shader{program},
		Projection: uniforms.NewMatrix4(program, projectionLoc),
		DepthMap:   uniforms.NewSampler2D(program, depthMapLoc),
		NearFar:    uniforms.NewVector2(program, nearFarLoc),
	}, nil
}
// NewPipShader instantiates and initializes a Shader object.
NewPipShader instantiates and initializes a Shader object.
// NewPipShader instantiates and initializes a Shader object .
func NewPipShader() (*PipShader, error) {
	program := gl.CreateProgram()
	vertexShader := gl.CreateShader(gl.VERTEX_SHADER)
	vertexSrc, freeVertexSrc := gl.Strs(pipShaderVertSrc)
	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", pipShaderOriginalVertexSourceFile, log)
	}
	gl.AttachShader(program, vertexShader)
	fragmentShader := gl.CreateShader(gl.FRAGMENT_SHADER)
	fragmentSrc, freeFragmentSrc := gl.Strs(pipShaderFragSrc)
	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", pipShaderOriginalFragmentSourceFile, 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", pipShaderOriginalVertexSourceFile, log)
	}
	projectionLoc := gl.GetUniformLocation(program, gl.Str("projection\x00"))
	depthMapLoc := gl.GetUniformLocation(program, gl.Str("textureSampler\x00"))
	nearFarLoc := gl.GetUniformLocation(program, gl.Str("nearFar\x00"))
	gl.DeleteShader(vertexShader)
	gl.DeleteShader(fragmentShader)
	gl.BindFragDataLocation(program, 0, gl.Str("outputColor\x00"))
	return &PipShader{
		shader:     shader{program},
		Projection: uniforms.NewMatrix4(program, projectionLoc),
		DepthMap:   uniforms.NewSampler2D(program, depthMapLoc),
		NearFar:    uniforms.NewVector2(program, nearFarLoc),
	}, nil
}
func NewPipShader ( ) ( * PipShader , error ) { program := gl . CreateProgram ( ) vertexShader := gl . CreateShader ( gl . VERTEX_SHADER ) vertexSrc , freeVertexSrc := gl . Strs ( pipShaderVertSrc ) 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 ( " " , pipShaderOriginalVertexSourceFile , log ) } gl . AttachShader ( program , vertexShader ) fragmentShader := gl . CreateShader ( gl . FRAGMENT_SHADER ) fragmentSrc , freeFragmentSrc := gl . Strs ( pipShaderFragSrc ) 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 ( " " , pipShaderOriginalFragmentSourceFile , 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 ( " " , pipShaderOriginalVertexSourceFile , log ) } projectionLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) depthMapLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) nearFarLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) gl . DeleteShader ( vertexShader ) gl . DeleteShader ( fragmentShader ) gl . BindFragDataLocation ( program , 0 , gl . Str ( " \x00 " ) ) return & PipShader { shader : shader { program } , Projection : uniforms . NewMatrix4 ( program , projectionLoc ) , DepthMap : uniforms . NewSampler2D ( program , depthMapLoc ) , NearFar : uniforms . NewVector2 ( program , nearFarLoc ) , } , nil }
NewPipShader instantiates and initializes a Shader object.
NewPipShader instantiates and initializes a Shader object .
// VertexShader // FragmentShader //Linking