-
Notifications
You must be signed in to change notification settings - Fork 1
/
post.go
39 lines (31 loc) · 898 Bytes
/
post.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
package ui
import "github.com/axe/axe-go/pkg/util"
type PostProcess func(b *Base, ctx *RenderContext, out *VertexBuffers)
func PostProcessVertex(modify VertexModifier) PostProcess {
return func(b *Base, ctx *RenderContext, out *VertexBuffers) {
vertices := NewVertexIterator(out, true)
for vertices.HasNext() {
modify(vertices.Next())
}
}
}
func (pp PostProcess) Run(b *Base, ctx *RenderContext, out *VertexBuffers) {
if pp != nil {
pp(b, ctx, out)
}
}
func postProcessNil(a PostProcess) bool {
return a == nil
}
func postProcessJoin(first, second PostProcess) PostProcess {
return func(b *Base, ctx *RenderContext, out *VertexBuffers) {
first(b, ctx, out)
second(b, ctx, out)
}
}
func (pp *PostProcess) Add(other PostProcess, before bool) {
*pp = util.CoalesceJoin(*pp, other, before, postProcessNil, postProcessJoin)
}
func (pp *PostProcess) Clear() {
*pp = nil
}