-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathattribute.go
42 lines (33 loc) · 849 Bytes
/
attribute.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package three
import (
gl "github.com/go-gl/gl"
)
// Attribute describes an attribute which is passed to
// a shader program.
type Attribute struct {
index int
size uint
buffer gl.Buffer
location gl.AttribLocation
}
// NewAttribute creates a new attribute for a shader program.
func NewAttribute(index int, size uint, buffer gl.Buffer) Attribute {
return Attribute{index: index, size: size, buffer: buffer}
}
func (a *Attribute) enable() {
location := gl.AttribLocation(a.index)
location.EnableArray()
a.location = location
}
func (a *Attribute) pointer() {
a.location.AttribPointer(a.size, gl.FLOAT, false, 0, nil)
}
func (a *Attribute) bindBuffer() {
a.buffer.Bind(gl.ARRAY_BUFFER)
}
func (a *Attribute) unbindBuffer() {
a.buffer.Unbind(gl.ARRAY_BUFFER)
}
func (a *Attribute) disable() {
a.location.DisableArray()
}