示例#1
0
func (unif *UniformsLocInstanced) SetUp(program gl.Program) {
	const L = len(unif.ubis)
	ubiNames := [L]string{"GlobalMatrices", "GlobalLights"}
	ubiPoints := [L]uint{CameraUboBindingPoint, LightUboBindingPoint}

	for i := 0; i < L; i++ {
		unif.ubis[i] = program.GetUniformBlockIndex(ubiNames[i])
		if err := CheckGlError(); err != nil {
			err.Description = fmt.Sprintf("GetUniformBlockIndex(%#v)", ubiNames[i])
			panic(err)
		}
		if unif.ubis[i] == gl.INVALID_INDEX {
			panic(fmt.Sprintf("GetUniformBlockIndex(%#v) returned INVALID_INDEX", ubiNames[i]))
		}

		program.UniformBlockBinding(unif.ubis[i], ubiPoints[i])
		if err := CheckGlError(); err != nil {
			err.Description = "UniformBlockBinding"
			panic(err)
		}
	}

	unif.textureLoc = program.GetUniformLocation("environment_map")
	if err := CheckGlError(); err != nil {
		err.Description = "GetUniformLocation(environment)"
		panic(err)
	}
	if unif.textureLoc == -1 {
		panic("environment uniform not found")
	}
}
示例#2
0
func (unif *UniformsLoc) SetUp(program gl.Program) {
	const modelLocName = "model_to_eye"
	const matricesUbiName = "GlobalMatrices"

	unif.modelLoc = program.GetUniformLocation(modelLocName)
	if err := CheckGlError(); err != nil {
		err.Description = fmt.Sprintf("program.GetUniformLocation(%#v)", modelLocName)
		panic(err)
	}
	if unif.modelLoc == -1 {
		panic(fmt.Sprintf("uniform %#v not found", modelLocName))
	}

	unif.globalMatricesUbi = program.GetUniformBlockIndex(matricesUbiName)
	if err := CheckGlError(); err != nil {
		err.Description = fmt.Sprintf("GetUniformBlockIndex(%#v)", matricesUbiName)
		panic(err)
	}
	if unif.globalMatricesUbi == gl.INVALID_INDEX {
		panic(fmt.Sprintf("GetUniformBlockIndex(%#v) returned INVALID_INDEX", matricesUbiName))
	}
	program.UniformBlockBinding(unif.globalMatricesUbi, CameraUboBindingPoint)
	if err := CheckGlError(); err != nil {
		err.Description = "UniformBlockBinding"
		panic(err)
	}
}