Ejemplo n.º 1
0
func BindLocations(name string, prog gl.Program, locations interface{}) {
	value := reflect.ValueOf(locations).Elem()
	Type := reflect.TypeOf(locations).Elem()
	for i := 0; i < value.NumField(); i++ {
		fieldValue := value.Field(i)
		fieldType := Type.Field(i)
		fieldName := fieldType.Name

		switch fieldValue.Interface().(type) {
		case gl.AttribLocation:
			loc := prog.GetAttribLocation(fieldName)
			fieldValue.SetInt(int64(loc))
		case gl.UniformLocation:
			loc := prog.GetUniformLocation(fieldName)
			fieldValue.SetInt(int64(loc))
		default:
		}
	}
}
Ejemplo n.º 2
0
func BindAttribLocations(name string, prog gl.Program, locations map[string]gl.AttribLocation) {
	for name := range locations {
		locations[name] = prog.GetAttribLocation(name)
	}
}
Ejemplo n.º 3
0
func BindUniformLocations(name string, prog gl.Program, locations map[string]gl.UniformLocation) {
	for name := range locations {
		locations[name] = prog.GetUniformLocation(name)
	}
}