-
Notifications
You must be signed in to change notification settings - Fork 0
/
vertexarray.go
63 lines (56 loc) · 1.22 KB
/
vertexarray.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package gli
type VertexArray struct {
ctx *Context
id uint32
// attributes map[int]*vertexArrayAttribute
enabled map[int]struct{}
}
func (ctx *Context) NewVertexArray() *VertexArray {
vaoid := ctx.r.VertexArrayCreate()
return &VertexArray{
ctx: ctx,
id: vaoid,
enabled: make(map[int]struct{}),
}
}
func (vao *VertexArray) Delete() {
vao.ctx.r.VertexArrayDelete(vao.id)
}
func (vao *VertexArray) bind() {
if vao.ctx.currentVertexArray == vao {
return
}
vao.ctx.currentVertexArray = vao
vao.ctx.r.VertexArrayBind(vao.id)
}
func (vao *VertexArray) enable(idx int) {
vao.bind()
_, ok := vao.enabled[idx]
if ok {
return
}
vao.enabled[idx] = struct{}{}
vao.ctx.r.VertexArrayEnable(idx)
}
func (vao *VertexArray) disable(idx int) {
vao.bind()
_, ok := vao.enabled[idx]
if !ok {
return
}
delete(vao.enabled, idx)
vao.ctx.r.VertexArrayDisable(idx)
}
/*
func (vao *VertexArray) Attribute(name string, extent Extent, buffer *ArrayBuffer) {
attributeindex, ok := vao.ctx.attributeIndexMap[name]
if !ok {
panic(fmt.Errorf("Could not bind attribute '%s', as it has not been configured", name))
}
idx := attributeindex.index
typ := attributeindex.typ
vao.bind()
buffer.bind()
// TODO: Finish
}
*/