-
Notifications
You must be signed in to change notification settings - Fork 0
/
cull.go
45 lines (36 loc) · 891 Bytes
/
cull.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
package caps
import (
"errors"
"github.com/go-gl/gl/v2.1/gl"
)
// Capabilities related to Culling.
type CullCaps struct{}
var Cull = CullCaps{}
// Enable face culling.
func (_ CullCaps) Enable() {
gl.Enable(gl.CULL_FACE)
}
// Disable face culling.
func (_ CullCaps) Disable() {
gl.Disable(gl.CULL_FACE)
}
// Set which face to render; front, back, or both.
func (_ CullCaps) Face(front, back bool) {
if front && back {
gl.CullFace(gl.FRONT_AND_BACK)
} else if front {
gl.CullFace(gl.FRONT)
} else if back {
gl.CullFace(gl.BACK)
} else {
panic(errors.New("Invalid CullFace setting: no front and no back."))
}
}
// Set the orientation of front-facing polygons to be clockwise.
func (_ CullCaps) Clockwise() {
gl.FrontFace(gl.CW)
}
// Set the orientation of front-facing polygons to be counter-clockwise.
func (_ CullCaps) CounterClockwise() {
gl.FrontFace(gl.CCW)
}