-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathblend.go
132 lines (109 loc) · 2.9 KB
/
blend.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package glitch
import "github.com/unitoftime/glitch/internal/gl"
// Note: These are all packed into uint8s to reduce size of the Material object
type BlendMode uint8
const (
BlendModeNone BlendMode = iota
BlendModeNormal
BlendModeMultiply
)
type blendModeData struct {
src, dst gl.Enum
}
var blendModeLut []blendModeData = []blendModeData{
// Note: This is what I used before premult: gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA
BlendModeNormal: {gl.ONE, gl.ONE_MINUS_SRC_ALPHA},
// BlendModeNormal: {gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA},
// BlendModeNormal: {gl.SRC_ALPHA, gl.ONE},
BlendModeMultiply: {gl.DST_COLOR, gl.ZERO},
}
type DepthMode uint8
const (
DepthModeNone DepthMode = iota
DepthModeLess
DepthModeLequal
)
type depthModeData struct {
mode gl.Enum
}
var depthModeLut []depthModeData = []depthModeData{
DepthModeNone: {},
DepthModeLess: {gl.LESS},
DepthModeLequal: {gl.LEQUAL},
}
type CullMode uint8
const (
CullModeNone CullMode = iota
CullModeNormal
)
type cullModeData struct {
face, dir gl.Enum
}
var cullModeLut []cullModeData = []cullModeData{
CullModeNone: {},
CullModeNormal: {gl.BACK, gl.CCW},
}
// // https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBlendFunc.xhtml
// type BlendMode struct {
// src, dst gl.Enum
// }
// var BlendModeNormal = BlendMode{
// // Note: This is what I used before premult: gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA
// gl.ONE,
// gl.ONE_MINUS_SRC_ALPHA,
// }
// // // TODO: Untested
// // var BlendModeAdd = BlendMode{
// // gl.SRC_ALPHA, gl.ONE
// // }
// var BlendModeMultiply = BlendMode{
// gl.DST_COLOR, gl.ZERO,
// }
// type DepthMode struct {
// mode gl.Enum
// }
// var ( // TODO: Can these be constants? Will that break wasm?
// DepthModeNone = DepthMode{}
// DepthModeLess = DepthMode{gl.LESS}
// DepthModeLequal = DepthMode{gl.LEQUAL}
// )
// type CullMode struct {
// face gl.Enum
// dir gl.Enum
// }
// var ( // TODO: Can these be constants? Will that break wasm?
// CullModeNone = CullMode{}
// CullModeNormal = CullMode{gl.BACK, gl.CCW}
// )
// // https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBlendFunc.xhtml
// type BlendMode struct {
// src, dst gl.Enum
// }
// var BlendModeNormal = BlendMode{
// // Note: This is what I used before premult: gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA
// gl.ONE,
// gl.ONE_MINUS_SRC_ALPHA,
// }
// // // TODO: Untested
// // var BlendModeAdd = BlendMode{
// // gl.SRC_ALPHA, gl.ONE
// // }
// var BlendModeMultiply = BlendMode{
// gl.DST_COLOR, gl.ZERO,
// }
// type DepthMode struct {
// mode gl.Enum
// }
// var ( // TODO: Can these be constants? Will that break wasm?
// DepthModeNone = DepthMode{}
// DepthModeLess = DepthMode{gl.LESS}
// DepthModeLequal = DepthMode{gl.LEQUAL}
// )
// type CullMode struct {
// face gl.Enum
// dir gl.Enum
// }
// var ( // TODO: Can these be constants? Will that break wasm?
// CullModeNone = CullMode{}
// CullModeNormal = CullMode{gl.BACK, gl.CCW}
// )