-
Notifications
You must be signed in to change notification settings - Fork 52
/
uniformlocation.go
228 lines (190 loc) · 7.81 KB
/
uniformlocation.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
// Copyright 2012 The go-gl Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gl
// #include "gl.h"
import "C"
import "unsafe"
// UniformLocation
//TODO
type UniformLocation int
func (location UniformLocation) Uniform1f(x float32) {
C.glUniform1f(C.GLint(location), C.GLfloat(x))
}
func (location UniformLocation) Uniform2f(x float32, y float32) {
C.glUniform2f(C.GLint(location), C.GLfloat(x), C.GLfloat(y))
}
func (location UniformLocation) Uniform3f(x float32, y float32, z float32) {
C.glUniform3f(C.GLint(location), C.GLfloat(x), C.GLfloat(y), C.GLfloat(z))
}
func (location UniformLocation) Uniform1fv(count int, v []float32) {
if len(v) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniform1fv(C.GLint(location), C.GLsizei(count), (*C.GLfloat)(&v[0]))
}
func (location UniformLocation) Uniform1i(x int) {
C.glUniform1i(C.GLint(location), C.GLint(x))
}
func (location UniformLocation) Uniform1iv(count int, v []int32) {
if len(v) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniform1iv(C.GLint(location), C.GLsizei(count), (*C.GLint)(&v[0]))
}
func (location UniformLocation) Uniform2fv(count int, v []float32) {
if len(v) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniform2fv(C.GLint(location), C.GLsizei(count), (*C.GLfloat)(&v[0]))
}
func (location UniformLocation) Uniform2i(x int, y int) {
C.glUniform2i(C.GLint(location), C.GLint(x), C.GLint(y))
}
func (location UniformLocation) Uniform2iv(count int, v []int32) {
if len(v) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniform2iv(C.GLint(location), C.GLsizei(count), (*C.GLint)(&v[0]))
}
func (location UniformLocation) Uniform3fv(count int, v []float32) {
if len(v) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniform3fv(C.GLint(location), C.GLsizei(count), (*C.GLfloat)(&v[0]))
}
func (location UniformLocation) Uniform3i(x int, y int, z int) {
C.glUniform3i(C.GLint(location), C.GLint(x), C.GLint(y), C.GLint(z))
}
func (location UniformLocation) Uniform3iv(count int, v []int32) {
if len(v) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniform3iv(C.GLint(location), C.GLsizei(count), (*C.GLint)(&v[0]))
}
func (location UniformLocation) Uniform4f(x float32, y float32, z float32, w float32) {
C.glUniform4f(C.GLint(location), C.GLfloat(x), C.GLfloat(y), C.GLfloat(z), C.GLfloat(w))
}
func (location UniformLocation) Uniform4fv(count int, v []float32) {
if len(v) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniform4fv(C.GLint(location), C.GLsizei(count), (*C.GLfloat)(&v[0]))
}
func (location UniformLocation) Uniform4i(x int, y int, z int, w int) {
C.glUniform4i(C.GLint(location), C.GLint(x), C.GLint(y), C.GLint(z), C.GLint(w))
}
func (location UniformLocation) Uniform4iv(count int, v []int32) {
if len(v) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniform4iv(C.GLint(location), C.GLsizei(count), (*C.GLint)(&v[0]))
}
func (location UniformLocation) UniformMatrix2fv(transpose bool, list ...[4]float32) {
if len(list) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniformMatrix2fv(C.GLint(location), C.GLsizei(len(list)), glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&list[0]))))
}
func (location UniformLocation) UniformMatrix2f(transpose bool, matrix *[4]float32) {
if matrix == nil {
panic("Matrix is nil")
}
C.glUniformMatrix2fv(C.GLint(location), 1, glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&matrix[0]))))
}
func (location UniformLocation) UniformMatrix3fv(transpose bool, list ...[9]float32) {
if len(list) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniformMatrix3fv(C.GLint(location), C.GLsizei(len(list)), glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&list[0]))))
}
func (location UniformLocation) UniformMatrix3f(transpose bool, matrix *[9]float32) {
if matrix == nil {
panic("Matrix is nil")
}
C.glUniformMatrix3fv(C.GLint(location), 1, glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&matrix[0]))))
}
func (location UniformLocation) UniformMatrix4fv(transpose bool, list ...[16]float32) {
if len(list) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniformMatrix4fv(C.GLint(location), C.GLsizei(len(list)), glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&list[0]))))
}
func (location UniformLocation) UniformMatrix4f(transpose bool, matrix *[16]float32) {
if matrix == nil {
panic("Matrix is nil")
}
C.glUniformMatrix4fv(C.GLint(location), 1, glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&matrix[0]))))
}
func (location UniformLocation) UniformMatrix2x3fv(transpose bool, list ...[6]float32) {
if len(list) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniformMatrix2x3fv(C.GLint(location), C.GLsizei(len(list)), glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&list[0]))))
}
func (location UniformLocation) UniformMatrix2x3f(transpose bool, matrix *[6]float32) {
if matrix == nil {
panic("Matrix is nil")
}
C.glUniformMatrix2x3fv(C.GLint(location), 1, glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&matrix[0]))))
}
func (location UniformLocation) UniformMatrix3x2fv(transpose bool, list ...[6]float32) {
if len(list) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniformMatrix3x2fv(C.GLint(location), C.GLsizei(len(list)), glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&list[0]))))
}
func (location UniformLocation) UniformMatrix3x2f(transpose bool, matrix *[6]float32) {
if matrix == nil {
panic("Matrix is nil")
}
C.glUniformMatrix3x2fv(C.GLint(location), 1, glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&matrix[0]))))
}
func (location UniformLocation) UniformMatrix2x4fv(transpose bool, list ...[8]float32) {
if len(list) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniformMatrix2x4fv(C.GLint(location), C.GLsizei(len(list)), glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&list[0]))))
}
func (location UniformLocation) UniformMatrix2x4f(transpose bool, matrix *[8]float32) {
if matrix == nil {
panic("Matrix is nil")
}
C.glUniformMatrix2x4fv(C.GLint(location), 1, glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&matrix[0]))))
}
func (location UniformLocation) UniformMatrix4x2fv(transpose bool, list ...[8]float32) {
if len(list) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniformMatrix4x2fv(C.GLint(location), C.GLsizei(len(list)), glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&list[0]))))
}
func (location UniformLocation) UniformMatrix4x2f(transpose bool, matrix *[8]float32) {
if matrix == nil {
panic("Matrix is nil")
}
C.glUniformMatrix4x2fv(C.GLint(location), 1, glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&matrix[0]))))
}
func (location UniformLocation) UniformMatrix3x4fv(transpose bool, list ...[12]float32) {
if len(list) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniformMatrix3x4fv(C.GLint(location), C.GLsizei(len(list)), glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&list[0]))))
}
func (location UniformLocation) UniformMatrix3x4f(transpose bool, matrix *[12]float32) {
if matrix == nil {
panic("Matrix is nil")
}
C.glUniformMatrix3x4fv(C.GLint(location), 1, glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&matrix[0]))))
}
func (location UniformLocation) UniformMatrix4x3fv(transpose bool, list ...[12]float32) {
if len(list) < 1 {
panic("Invalid array length - must be at least 1")
}
C.glUniformMatrix4x3fv(C.GLint(location), C.GLsizei(len(list)), glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&list[0]))))
}
func (location UniformLocation) UniformMatrix4x3f(transpose bool, matrix *[12]float32) {
if matrix == nil {
panic("Matrix is nil")
}
C.glUniformMatrix4x3fv(C.GLint(location), 1, glBool(transpose), ((*C.GLfloat)((unsafe.Pointer)(&matrix[0]))))
}