2016-12-14 09:24:31 -06:00
|
|
|
package pixelgl
|
|
|
|
|
|
|
|
import "github.com/go-gl/gl/v3.3-core/gl"
|
|
|
|
|
|
|
|
type binder struct {
|
|
|
|
restoreLoc uint32
|
|
|
|
bindFunc func(uint32)
|
|
|
|
|
|
|
|
obj uint32
|
|
|
|
|
|
|
|
prev []uint32
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *binder) bind() *binder {
|
|
|
|
var prev int32
|
|
|
|
gl.GetIntegerv(b.restoreLoc, &prev)
|
|
|
|
b.prev = append(b.prev, uint32(prev))
|
|
|
|
|
2016-12-15 07:31:10 -06:00
|
|
|
if b.prev[len(b.prev)-1] != b.obj {
|
|
|
|
b.bindFunc(b.obj)
|
|
|
|
}
|
2016-12-14 09:24:31 -06:00
|
|
|
return b
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *binder) restore() *binder {
|
2016-12-15 07:31:10 -06:00
|
|
|
if b.prev[len(b.prev)-1] != b.obj {
|
|
|
|
b.bindFunc(b.prev[len(b.prev)-1])
|
|
|
|
}
|
2016-12-14 09:24:31 -06:00
|
|
|
b.prev = b.prev[:len(b.prev)-1]
|
|
|
|
return b
|
|
|
|
}
|