func NewColorShader() (*ColorShader, error) {
	program := gl.CreateProgram()

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

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

	projectionLoc := gl.GetUniformLocation(program, gl.Str("projection\x00"))
	viewLoc := gl.GetUniformLocation(program, gl.Str("view\x00"))
	modelLoc := gl.GetUniformLocation(program, gl.Str("model\x00"))
	lightViewProjsLoc := gl.GetUniformLocation(program, gl.Str("lightViewProjs\x00"))
	renderModeLoc := gl.GetUniformLocation(program, gl.Str("renderMode\x00"))
	numTilesXLoc := gl.GetUniformLocation(program, gl.Str("numTilesX\x00"))
	zNearLoc := gl.GetUniformLocation(program, gl.Str("zNear\x00"))
	zFarLoc := gl.GetUniformLocation(program, gl.Str("zFar\x00"))
	shadowMapSizeLoc := gl.GetUniformLocation(program, gl.Str("shadowMapSize\x00"))
	ambientLightColorLoc := gl.GetUniformLocation(program, gl.Str("ambientLightColor\x00"))
	cascadeDepthLimitsLoc := gl.GetUniformLocation(program, gl.Str("cascadeDepthLimits\x00"))
	diffuseLoc := gl.GetUniformLocation(program, gl.Str("diffuse\x00"))
	shadowMap1Loc := gl.GetUniformLocation(program, gl.Str("shadowMap1\x00"))
	shadowMap2Loc := gl.GetUniformLocation(program, gl.Str("shadowMap2\x00"))
	shadowMap3Loc := gl.GetUniformLocation(program, gl.Str("shadowMap3\x00"))
	shadowMap4Loc := gl.GetUniformLocation(program, gl.Str("shadowMap4\x00"))

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

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

	return &ColorShader{
		shader:                    shader{program},
		Projection:                uniforms.NewMatrix4(program, projectionLoc),
		View:                      uniforms.NewMatrix4(program, viewLoc),
		Model:                     uniforms.NewMatrix4(program, modelLoc),
		LightViewProjs:            uniforms.NewMatrix4Array(program, lightViewProjsLoc),
		RenderMode:                uniforms.NewInt(program, renderModeLoc),
		NumTilesX:                 uniforms.NewUInt(program, numTilesXLoc),
		ZNear:                     uniforms.NewFloat(program, zNearLoc),
		ZFar:                      uniforms.NewFloat(program, zFarLoc),
		ShadowMapSize:             uniforms.NewFloat(program, shadowMapSizeLoc),
		AmbientLightColor:         uniforms.NewVector3(program, ambientLightColorLoc),
		CascadeDepthLimits:        uniforms.NewFloatArray(program, cascadeDepthLimitsLoc),
		Diffuse:                   uniforms.NewSampler2D(program, diffuseLoc),
		LightBuffer:               buffers.NewBinding(0),
		VisibleLightIndicesBuffer: buffers.NewBinding(1),
		DirectionalLightBuffer:    buffers.NewBinding(2),
		ShadowMap1:                uniforms.NewSampler2D(program, shadowMap1Loc),
		ShadowMap2:                uniforms.NewSampler2D(program, shadowMap2Loc),
		ShadowMap3:                uniforms.NewSampler2D(program, shadowMap3Loc),
		ShadowMap4:                uniforms.NewSampler2D(program, shadowMap4Loc),
	}, nil
}
// NewColorShader instantiates and initializes a shader object.
NewColorShader instantiates and initializes a shader object.
// NewColorShader instantiates and initializes a shader object .
func NewColorShader() (*ColorShader, error) {
	program := gl.CreateProgram()
	vertexShader := gl.CreateShader(gl.VERTEX_SHADER)
	vertexSrc, freeVertexSrc := gl.Strs(colorShaderVertSrc)
	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", colorShaderOriginalVertexSourceFile, log)
	}
	gl.AttachShader(program, vertexShader)
	fragmentShader := gl.CreateShader(gl.FRAGMENT_SHADER)
	fragmentSrc, freeFragmentSrc := gl.Strs(colorShaderFragSrc)
	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", colorShaderOriginalFragmentSourceFile, 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", colorShaderOriginalVertexSourceFile, log)
	}
	projectionLoc := gl.GetUniformLocation(program, gl.Str("projection\x00"))
	viewLoc := gl.GetUniformLocation(program, gl.Str("view\x00"))
	modelLoc := gl.GetUniformLocation(program, gl.Str("model\x00"))
	lightViewProjsLoc := gl.GetUniformLocation(program, gl.Str("lightViewProjs\x00"))
	renderModeLoc := gl.GetUniformLocation(program, gl.Str("renderMode\x00"))
	numTilesXLoc := gl.GetUniformLocation(program, gl.Str("numTilesX\x00"))
	zNearLoc := gl.GetUniformLocation(program, gl.Str("zNear\x00"))
	zFarLoc := gl.GetUniformLocation(program, gl.Str("zFar\x00"))
	shadowMapSizeLoc := gl.GetUniformLocation(program, gl.Str("shadowMapSize\x00"))
	ambientLightColorLoc := gl.GetUniformLocation(program, gl.Str("ambientLightColor\x00"))
	cascadeDepthLimitsLoc := gl.GetUniformLocation(program, gl.Str("cascadeDepthLimits\x00"))
	diffuseLoc := gl.GetUniformLocation(program, gl.Str("diffuse\x00"))
	shadowMap1Loc := gl.GetUniformLocation(program, gl.Str("shadowMap1\x00"))
	shadowMap2Loc := gl.GetUniformLocation(program, gl.Str("shadowMap2\x00"))
	shadowMap3Loc := gl.GetUniformLocation(program, gl.Str("shadowMap3\x00"))
	shadowMap4Loc := gl.GetUniformLocation(program, gl.Str("shadowMap4\x00"))
	gl.DeleteShader(vertexShader)
	gl.DeleteShader(fragmentShader)
	gl.BindFragDataLocation(program, 0, gl.Str("outputColor\x00"))
	return &ColorShader{
		shader:                    shader{program},
		Projection:                uniforms.NewMatrix4(program, projectionLoc),
		View:                      uniforms.NewMatrix4(program, viewLoc),
		Model:                     uniforms.NewMatrix4(program, modelLoc),
		LightViewProjs:            uniforms.NewMatrix4Array(program, lightViewProjsLoc),
		RenderMode:                uniforms.NewInt(program, renderModeLoc),
		NumTilesX:                 uniforms.NewUInt(program, numTilesXLoc),
		ZNear:                     uniforms.NewFloat(program, zNearLoc),
		ZFar:                      uniforms.NewFloat(program, zFarLoc),
		ShadowMapSize:             uniforms.NewFloat(program, shadowMapSizeLoc),
		AmbientLightColor:         uniforms.NewVector3(program, ambientLightColorLoc),
		CascadeDepthLimits:        uniforms.NewFloatArray(program, cascadeDepthLimitsLoc),
		Diffuse:                   uniforms.NewSampler2D(program, diffuseLoc),
		LightBuffer:               buffers.NewBinding(0),
		VisibleLightIndicesBuffer: buffers.NewBinding(1),
		DirectionalLightBuffer:    buffers.NewBinding(2),
		ShadowMap1:                uniforms.NewSampler2D(program, shadowMap1Loc),
		ShadowMap2:                uniforms.NewSampler2D(program, shadowMap2Loc),
		ShadowMap3:                uniforms.NewSampler2D(program, shadowMap3Loc),
		ShadowMap4:                uniforms.NewSampler2D(program, shadowMap4Loc),
	}, nil
}
func NewColorShader ( ) ( * ColorShader , error ) { program := gl . CreateProgram ( ) vertexShader := gl . CreateShader ( gl . VERTEX_SHADER ) vertexSrc , freeVertexSrc := gl . Strs ( colorShaderVertSrc ) 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 ( " " , colorShaderOriginalVertexSourceFile , log ) } gl . AttachShader ( program , vertexShader ) fragmentShader := gl . CreateShader ( gl . FRAGMENT_SHADER ) fragmentSrc , freeFragmentSrc := gl . Strs ( colorShaderFragSrc ) 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 ( " " , colorShaderOriginalFragmentSourceFile , 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 ( " " , colorShaderOriginalVertexSourceFile , log ) } projectionLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) viewLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) modelLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) lightViewProjsLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) renderModeLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) numTilesXLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) zNearLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) zFarLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) shadowMapSizeLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) ambientLightColorLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) cascadeDepthLimitsLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) diffuseLoc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) shadowMap1Loc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) shadowMap2Loc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) shadowMap3Loc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) shadowMap4Loc := gl . GetUniformLocation ( program , gl . Str ( " \x00 " ) ) gl . DeleteShader ( vertexShader ) gl . DeleteShader ( fragmentShader ) gl . BindFragDataLocation ( program , 0 , gl . Str ( " \x00 " ) ) return & ColorShader { shader : shader { program } , Projection : uniforms . NewMatrix4 ( program , projectionLoc ) , View : uniforms . NewMatrix4 ( program , viewLoc ) , Model : uniforms . NewMatrix4 ( program , modelLoc ) , LightViewProjs : uniforms . NewMatrix4Array ( program , lightViewProjsLoc ) , RenderMode : uniforms . NewInt ( program , renderModeLoc ) , NumTilesX : uniforms . NewUInt ( program , numTilesXLoc ) , ZNear : uniforms . NewFloat ( program , zNearLoc ) , ZFar : uniforms . NewFloat ( program , zFarLoc ) , ShadowMapSize : uniforms . NewFloat ( program , shadowMapSizeLoc ) , AmbientLightColor : uniforms . NewVector3 ( program , ambientLightColorLoc ) , CascadeDepthLimits : uniforms . NewFloatArray ( program , cascadeDepthLimitsLoc ) , Diffuse : uniforms . NewSampler2D ( program , diffuseLoc ) , LightBuffer : buffers . NewBinding ( 0 ) , VisibleLightIndicesBuffer : buffers . NewBinding ( 1 ) , DirectionalLightBuffer : buffers . NewBinding ( 2 ) , ShadowMap1 : uniforms . NewSampler2D ( program , shadowMap1Loc ) , ShadowMap2 : uniforms . NewSampler2D ( program , shadowMap2Loc ) , ShadowMap3 : uniforms . NewSampler2D ( program , shadowMap3Loc ) , ShadowMap4 : uniforms . NewSampler2D ( program , shadowMap4Loc ) , } , nil }
NewColorShader instantiates and initializes a shader object.
NewColorShader instantiates and initializes a shader object .
// VertexShader // FragmentShader // Linking