func NewLightCullingShader() (*LightCullingShader, error) {
	program := gl.CreateProgram()

	// ComputeShader
	computeShader := gl.CreateShader(gl.COMPUTE_SHADER)
	computeSrc, freeComputeSrc := gl.Strs(lightCullingShaderComputeSrc)
	gl.ShaderSource(computeShader, 1, computeSrc, nil)
	freeComputeSrc()
	gl.CompileShader(computeShader)
	var status int32
	gl.GetShaderiv(computeShader, gl.COMPILE_STATUS, &status)
	if status == gl.FALSE {
		var logLength int32
		gl.GetShaderiv(computeShader, gl.INFO_LOG_LENGTH, &logLength)
		log := strings.Repeat("\x00", int(logLength+1))
		gl.GetShaderInfoLog(computeShader, logLength, nil, gl.Str(log))
		return nil, fmt.Errorf("failed to compile %v: %v", lightCullingShaderOriginalComputeSourceFile, log)
	}
	gl.AttachShader(program, computeShader)

	// 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", lightCullingShaderOriginalComputeSourceFile, log)
	}

	projectionLoc := gl.GetUniformLocation(program, gl.Str("projection\x00"))
	viewLoc := gl.GetUniformLocation(program, gl.Str("view\x00"))
	screenSizeLoc := gl.GetUniformLocation(program, gl.Str("screenSize\x00"))
	lightCountLoc := gl.GetUniformLocation(program, gl.Str("lightCount\x00"))
	depthMapLoc := gl.GetUniformLocation(program, gl.Str("depthMap\x00"))

	gl.DeleteShader(computeShader)

	return &LightCullingShader{
		shader:                    shader{program},
		DepthMap:                  uniforms.NewSampler2D(program, depthMapLoc),
		Projection:                uniforms.NewMatrix4(program, projectionLoc),
		View:                      uniforms.NewMatrix4(program, viewLoc),
		ScreenSize:                uniforms.NewUIVector2(program, screenSizeLoc),
		LightCount:                uniforms.NewUInt(program, lightCountLoc),
		LightBuffer:               buffers.NewBinding(0),
		VisibleLightIndicesBuffer: buffers.NewBinding(1),
	}, nil
}
// NewLightCullingShader instantiates and initializes a LightCullingShader object.
NewLightCullingShader instantiates and initializes a LightCullingShader object.
// NewLightCullingShader instantiates and initializes a LightCullingShader object .
func NewLightCullingShader() (*LightCullingShader, error) {
	program := gl.CreateProgram()
	computeShader := gl.CreateShader(gl.COMPUTE_SHADER)
	computeSrc, freeComputeSrc := gl.Strs(lightCullingShaderComputeSrc)
	gl.ShaderSource(computeShader, 1, computeSrc, nil)
	freeComputeSrc()
	gl.CompileShader(computeShader)
	var status int32
	gl.GetShaderiv(computeShader, gl.COMPILE_STATUS, &status)
	if status == gl.FALSE {
		var logLength int32
		gl.GetShaderiv(computeShader, gl.INFO_LOG_LENGTH, &logLength)
		log := strings.Repeat("\x00", int(logLength+1))
		gl.GetShaderInfoLog(computeShader, logLength, nil, gl.Str(log))
		return nil, fmt.Errorf("failed to compile %v: %v", lightCullingShaderOriginalComputeSourceFile, log)
	}
	gl.AttachShader(program, computeShader)
	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", lightCullingShaderOriginalComputeSourceFile, log)
	}
	projectionLoc := gl.GetUniformLocation(program, gl.Str("projection\x00"))
	viewLoc := gl.GetUniformLocation(program, gl.Str("view\x00"))
	screenSizeLoc := gl.GetUniformLocation(program, gl.Str("screenSize\x00"))
	lightCountLoc := gl.GetUniformLocation(program, gl.Str("lightCount\x00"))
	depthMapLoc := gl.GetUniformLocation(program, gl.Str("depthMap\x00"))
	gl.DeleteShader(computeShader)
	return &LightCullingShader{
		shader:                    shader{program},
		DepthMap:                  uniforms.NewSampler2D(program, depthMapLoc),
		Projection:                uniforms.NewMatrix4(program, projectionLoc),
		View:                      uniforms.NewMatrix4(program, viewLoc),
		ScreenSize:                uniforms.NewUIVector2(program, screenSizeLoc),
		LightCount:                uniforms.NewUInt(program, lightCountLoc),
		LightBuffer:               buffers.NewBinding(0),
		VisibleLightIndicesBuffer: buffers.NewBinding(1),
	}, nil
}
func NewLightCullingShader ( ) ( * LightCullingShader , error ) { program := gl . CreateProgram ( ) computeShader := gl . CreateShader ( gl . COMPUTE_SHADER ) computeSrc , freeComputeSrc := gl . Strs ( lightCullingShaderComputeSrc ) gl . ShaderSource ( computeShader , 1 , computeSrc , nil ) freeComputeSrc ( ) gl . CompileShader ( computeShader ) var status int32 gl . GetShaderiv ( computeShader , gl . COMPILE_STATUS , & status ) if status == gl . FALSE { var logLength int32 gl . GetShaderiv ( computeShader , gl . INFO_LOG_LENGTH , & logLength ) log := strings . Repeat ( " \x00 " , int ( logLength + 1 ) ) gl . GetShaderInfoLog ( computeShader , logLength , nil , gl . Str ( log ) ) return nil , fmt . Errorf ( " " , lightCullingShaderOriginalComputeSourceFile , log ) } gl . AttachShader ( program , computeShader ) 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 ( " " , lightCullingShaderOriginalComputeSourceFile , log ) } projectionLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) viewLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) screenSizeLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) lightCountLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) depthMapLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) gl . DeleteShader ( computeShader ) return & LightCullingShader { shader : shader { program } , DepthMap : uniforms . NewSampler2D ( program , depthMapLoc ) , Projection : uniforms . NewMatrix4 ( program , projectionLoc ) , View : uniforms . NewMatrix4 ( program , viewLoc ) , ScreenSize : uniforms . NewUIVector2 ( program , screenSizeLoc ) , LightCount : uniforms . NewUInt ( program , lightCountLoc ) , LightBuffer : buffers . NewBinding ( 0 ) , VisibleLightIndicesBuffer : buffers . NewBinding ( 1 ) , } , nil }
NewLightCullingShader instantiates and initializes a LightCullingShader object.
NewLightCullingShader instantiates and initializes a LightCullingShader object .
// ComputeShader // Linking