-
Notifications
You must be signed in to change notification settings - Fork 7
/
gl_opengles.go
718 lines (558 loc) · 19 KB
/
gl_opengles.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ios android
package gl
/*
#include <stdlib.h>
#ifdef os_ios
#include <OpenGLES/ES2/glext.h>
#endif
#ifdef os_android
#include <GLES2/gl2.h>
#endif
*/
import "C"
import "unsafe"
var ContextWatcher contextWatcher
type contextWatcher struct{}
func (contextWatcher) OnMakeCurrent(context interface{}) {}
func (contextWatcher) OnDetach() {}
func ActiveTexture(texture Enum) {
C.glActiveTexture(texture.c())
}
func AttachShader(p Program, s Shader) {
C.glAttachShader(p.c(), s.c())
}
func BindAttribLocation(p Program, a Attrib, name string) {
str := unsafe.Pointer(C.CString(name))
defer C.free(str)
C.glBindAttribLocation(p.c(), a.c(), (*C.GLchar)(str))
}
func BindBuffer(target Enum, b Buffer) {
C.glBindBuffer(target.c(), b.c())
}
func BindFramebuffer(target Enum, fb Framebuffer) {
C.glBindFramebuffer(target.c(), fb.c())
}
func BindRenderbuffer(target Enum, rb Renderbuffer) {
C.glBindRenderbuffer(target.c(), rb.c())
}
func BindTexture(target Enum, t Texture) {
C.glBindTexture(target.c(), t.c())
}
func BlendColor(red, green, blue, alpha float32) {
blendColor(red, green, blue, alpha)
}
func BlendEquation(mode Enum) {
C.glBlendEquation(mode.c())
}
func BlendEquationSeparate(modeRGB, modeAlpha Enum) {
C.glBlendEquationSeparate(modeRGB.c(), modeAlpha.c())
}
func BlendFunc(sfactor, dfactor Enum) {
C.glBlendFunc(sfactor.c(), dfactor.c())
}
func BlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha Enum) {
C.glBlendFuncSeparate(sfactorRGB.c(), dfactorRGB.c(), sfactorAlpha.c(), dfactorAlpha.c())
}
func BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1 int, mask, filter Enum) {
C.glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, C.GLbitfield(mask), filter.c())
}
func BufferData(target Enum, src []byte, usage Enum) {
C.glBufferData(target.c(), C.GLsizeiptr(len(src)), unsafe.Pointer(&src[0]), usage.c())
}
func BufferInit(target Enum, size int, usage Enum) {
C.glBufferData(target.c(), C.GLsizeiptr(size), nil, usage.c())
}
func BufferSubData(target Enum, offset int, data []byte) {
C.glBufferSubData(target.c(), C.GLintptr(offset), C.GLsizeiptr(len(data)), unsafe.Pointer(&data[0]))
}
func CheckFramebufferStatus(target Enum) Enum {
return Enum(C.glCheckFramebufferStatus(target.c()))
}
func Clear(mask Enum) {
C.glClear(C.GLbitfield(mask))
}
func ClearColor(red, green, blue, alpha float32) {
clearColor(red, green, blue, alpha)
}
func ClearDepthf(d float32) {
clearDepthf(d)
}
func ClearStencil(s int) {
C.glClearStencil(C.GLint(s))
}
func ColorMask(red, green, blue, alpha bool) {
C.glColorMask(glBoolean(red), glBoolean(green), glBoolean(blue), glBoolean(alpha))
}
func CompileShader(s Shader) {
C.glCompileShader(s.c())
}
func CompressedTexImage2D(target Enum, level int, internalformat Enum, width, height, border int, data []byte) {
C.glCompressedTexImage2D(target.c(), C.GLint(level), internalformat.c(), C.GLsizei(width), C.GLsizei(height), C.GLint(border), C.GLsizei(len(data)), unsafe.Pointer(&data[0]))
}
func CompressedTexSubImage2D(target Enum, level, xoffset, yoffset, width, height int, format Enum, data []byte) {
C.glCompressedTexSubImage2D(target.c(), C.GLint(level), C.GLint(xoffset), C.GLint(yoffset), C.GLsizei(width), C.GLsizei(height), format.c(), C.GLsizei(len(data)), unsafe.Pointer(&data[0]))
}
func CopyTexImage2D(target Enum, level int, internalformat Enum, x, y, width, height, border int) {
C.glCopyTexImage2D(target.c(), C.GLint(level), internalformat.c(), C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height), C.GLint(border))
}
func CopyTexSubImage2D(target Enum, level, xoffset, yoffset, x, y, width, height int) {
C.glCopyTexSubImage2D(target.c(), C.GLint(level), C.GLint(xoffset), C.GLint(yoffset), C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height))
}
func CreateBuffer() Buffer {
var b Buffer
C.glGenBuffers(1, (*C.GLuint)(&b.Value))
return b
}
func CreateFramebuffer() Framebuffer {
var b Framebuffer
C.glGenFramebuffers(1, (*C.GLuint)(&b.Value))
return b
}
func CreateProgram() Program {
return Program{Value: uint32(C.glCreateProgram())}
}
func CreateRenderbuffer() Renderbuffer {
var b Renderbuffer
C.glGenRenderbuffers(1, (*C.GLuint)(&b.Value))
return b
}
func CreateShader(ty Enum) Shader {
return Shader{Value: uint32(C.glCreateShader(ty.c()))}
}
func CreateTexture() Texture {
var t Texture
C.glGenTextures(1, (*C.GLuint)(&t.Value))
return t
}
func CullFace(mode Enum) {
C.glCullFace(mode.c())
}
func DeleteBuffer(v Buffer) {
C.glDeleteBuffers(1, (*C.GLuint)(&v.Value))
}
func DeleteFramebuffer(v Framebuffer) {
C.glDeleteFramebuffers(1, (*C.GLuint)(&v.Value))
}
func DeleteProgram(p Program) {
C.glDeleteProgram(p.c())
}
func DeleteRenderbuffer(v Renderbuffer) {
C.glDeleteRenderbuffers(1, (*C.GLuint)(&v.Value))
}
func DeleteShader(s Shader) {
C.glDeleteShader(s.c())
}
func DeleteTexture(v Texture) {
C.glDeleteTextures(1, (*C.GLuint)(&v.Value))
}
func DepthFunc(fn Enum) {
C.glDepthFunc(fn.c())
}
func DepthMask(flag bool) {
C.glDepthMask(glBoolean(flag))
}
func DepthRangef(n, f float32) {
depthRangef(n, f)
}
func DetachShader(p Program, s Shader) {
C.glDetachShader(p.c(), s.c())
}
func Disable(cap Enum) {
C.glDisable(cap.c())
}
func DisableVertexAttribArray(a Attrib) {
C.glDisableVertexAttribArray(a.c())
}
func DrawArrays(mode Enum, first, count int) {
C.glDrawArrays(mode.c(), C.GLint(first), C.GLsizei(count))
}
func DrawElements(mode Enum, count int, ty Enum, offset int) {
C.glDrawElements(mode.c(), C.GLsizei(count), ty.c(), unsafe.Pointer(uintptr(offset)))
}
func Enable(cap Enum) {
C.glEnable(cap.c())
}
func EnableVertexAttribArray(a Attrib) {
C.glEnableVertexAttribArray(a.c())
}
func Finish() {
C.glFinish()
}
func Flush() {
C.glFlush()
}
func FramebufferRenderbuffer(target, attachment, rbTarget Enum, rb Renderbuffer) {
C.glFramebufferRenderbuffer(target.c(), attachment.c(), rbTarget.c(), rb.c())
}
func FramebufferTexture2D(target, attachment, texTarget Enum, t Texture, level int) {
C.glFramebufferTexture2D(target.c(), attachment.c(), texTarget.c(), t.c(), C.GLint(level))
}
func FrontFace(mode Enum) {
C.glFrontFace(mode.c())
}
func GenerateMipmap(target Enum) {
C.glGenerateMipmap(target.c())
}
func GetActiveAttrib(p Program, index uint32) (name string, size int, ty Enum) {
bufSize := GetProgrami(p, ACTIVE_ATTRIBUTE_MAX_LENGTH)
buf := C.malloc(C.size_t(bufSize))
defer C.free(buf)
var cSize C.GLint
var cType C.GLenum
C.glGetActiveAttrib(p.c(), C.GLuint(index), C.GLsizei(bufSize), nil, &cSize, &cType, (*C.GLchar)(buf))
return C.GoString((*C.char)(buf)), int(cSize), Enum(cType)
}
func GetActiveUniform(p Program, index uint32) (name string, size int, ty Enum) {
bufSize := GetProgrami(p, ACTIVE_UNIFORM_MAX_LENGTH)
buf := C.malloc(C.size_t(bufSize))
defer C.free(buf)
var cSize C.GLint
var cType C.GLenum
C.glGetActiveUniform(p.c(), C.GLuint(index), C.GLsizei(bufSize), nil, &cSize, &cType, (*C.GLchar)(buf))
return C.GoString((*C.char)(buf)), int(cSize), Enum(cType)
}
func GetAttachedShaders(p Program) []Shader {
shadersLen := GetProgrami(p, ATTACHED_SHADERS)
var n C.GLsizei
buf := make([]C.GLuint, shadersLen)
C.glGetAttachedShaders(p.c(), C.GLsizei(shadersLen), &n, &buf[0])
buf = buf[:int(n)]
shaders := make([]Shader, len(buf))
for i, s := range buf {
shaders[i] = Shader{Value: uint32(s)}
}
return shaders
}
func GetAttribLocation(p Program, name string) Attrib {
str := unsafe.Pointer(C.CString(name))
defer C.free(str)
return Attrib{Value: uint(C.glGetAttribLocation(p.c(), (*C.GLchar)(str)))}
}
func GetBooleanv(dst []bool, pname Enum) {
buf := make([]C.GLboolean, len(dst))
C.glGetBooleanv(pname.c(), &buf[0])
for i, v := range buf {
dst[i] = v != 0
}
}
func GetFloatv(dst []float32, pname Enum) {
C.glGetFloatv(pname.c(), (*C.GLfloat)(&dst[0]))
}
func GetIntegerv(pname Enum, data []int32) {
buf := make([]C.GLint, len(data))
C.glGetIntegerv(pname.c(), &buf[0])
for i, v := range buf {
data[i] = int32(v)
}
}
func GetInteger(pname Enum) int {
var v C.GLint
C.glGetIntegerv(pname.c(), &v)
return int(v)
}
func GetBufferParameteri(target, pname Enum) int {
var params C.GLint
C.glGetBufferParameteriv(target.c(), pname.c(), ¶ms)
return int(params)
}
func GetError() Enum {
return Enum(C.glGetError())
}
func GetBoundFramebuffer() Framebuffer {
println("GetBoundFramebuffer: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
var b C.GLint
C.glGetIntegerv(FRAMEBUFFER_BINDING, &b)
return Framebuffer{Value: uint32(b)}
}
func GetFramebufferAttachmentParameteri(target, attachment, pname Enum) int {
var params C.GLint
C.glGetFramebufferAttachmentParameteriv(target.c(), attachment.c(), pname.c(), ¶ms)
return int(params)
}
func GetProgrami(p Program, pname Enum) int {
var params C.GLint
C.glGetProgramiv(p.c(), pname.c(), ¶ms)
return int(params)
}
func GetProgramInfoLog(p Program) string {
infoLen := GetProgrami(p, INFO_LOG_LENGTH)
buf := C.malloc(C.size_t(infoLen))
C.free(buf)
C.glGetProgramInfoLog(p.c(), C.GLsizei(infoLen), nil, (*C.GLchar)(buf))
return C.GoString((*C.char)(buf))
}
func GetRenderbufferParameteri(target, pname Enum) int {
var params C.GLint
C.glGetRenderbufferParameteriv(target.c(), pname.c(), ¶ms)
return int(params)
}
func GetShaderi(s Shader, pname Enum) int {
var params C.GLint
C.glGetShaderiv(s.c(), pname.c(), ¶ms)
return int(params)
}
func GetShaderInfoLog(s Shader) string {
infoLen := GetShaderi(s, INFO_LOG_LENGTH)
buf := C.malloc(C.size_t(infoLen))
defer C.free(buf)
C.glGetShaderInfoLog(s.c(), C.GLsizei(infoLen), nil, (*C.GLchar)(buf))
return C.GoString((*C.char)(buf))
}
func GetShaderPrecisionFormat(shadertype, precisiontype Enum) (rangeLow, rangeHigh, precision int) {
const glintSize = 4
var cRange [2]C.GLint
var cPrecision C.GLint
C.glGetShaderPrecisionFormat(shadertype.c(), precisiontype.c(), &cRange[0], &cPrecision)
return int(cRange[0]), int(cRange[1]), int(cPrecision)
}
func GetShaderSource(s Shader) string {
sourceLen := GetShaderi(s, SHADER_SOURCE_LENGTH)
if sourceLen == 0 {
return ""
}
buf := C.malloc(C.size_t(sourceLen))
defer C.free(buf)
C.glGetShaderSource(s.c(), C.GLsizei(sourceLen), nil, (*C.GLchar)(buf))
return C.GoString((*C.char)(buf))
}
func GetString(pname Enum) string {
// Bounce through unsafe.Pointer, because on some platforms
// GetString returns an *unsigned char which doesn't convert.
return C.GoString((*C.char)((unsafe.Pointer)(C.glGetString(pname.c()))))
}
func GetTexParameterfv(dst []float32, target, pname Enum) {
C.glGetTexParameterfv(target.c(), pname.c(), (*C.GLfloat)(&dst[0]))
}
func GetTexParameteriv(dst []int32, target, pname Enum) {
C.glGetTexParameteriv(target.c(), pname.c(), (*C.GLint)(&dst[0]))
}
func GetUniformfv(dst []float32, src Uniform, p Program) {
C.glGetUniformfv(p.c(), src.c(), (*C.GLfloat)(&dst[0]))
}
func GetUniformiv(dst []int32, src Uniform, p Program) {
C.glGetUniformiv(p.c(), src.c(), (*C.GLint)(&dst[0]))
}
func GetUniformLocation(p Program, name string) Uniform {
str := unsafe.Pointer(C.CString(name))
defer C.free(str)
return Uniform{Value: int32(C.glGetUniformLocation(p.c(), (*C.GLchar)(str)))}
}
func GetVertexAttribf(src Attrib, pname Enum) float32 {
var params C.GLfloat
C.glGetVertexAttribfv(src.c(), pname.c(), ¶ms)
return float32(params)
}
func GetVertexAttribfv(dst []float32, src Attrib, pname Enum) {
C.glGetVertexAttribfv(src.c(), pname.c(), (*C.GLfloat)(&dst[0]))
}
func GetVertexAttribi(src Attrib, pname Enum) int32 {
var params C.GLint
C.glGetVertexAttribiv(src.c(), pname.c(), ¶ms)
return int32(params)
}
func GetVertexAttribiv(dst []int32, src Attrib, pname Enum) {
C.glGetVertexAttribiv(src.c(), pname.c(), (*C.GLint)(&dst[0]))
}
func Hint(target, mode Enum) {
C.glHint(target.c(), mode.c())
}
func IsBuffer(b Buffer) bool {
return C.glIsBuffer(b.c()) != 0
}
func IsEnabled(cap Enum) bool {
return C.glIsEnabled(cap.c()) != 0
}
func IsFramebuffer(fb Framebuffer) bool {
return C.glIsFramebuffer(fb.c()) != 0
}
func IsProgram(p Program) bool {
return C.glIsProgram(p.c()) != 0
}
func IsRenderbuffer(rb Renderbuffer) bool {
return C.glIsRenderbuffer(rb.c()) != 0
}
func IsShader(s Shader) bool {
return C.glIsShader(s.c()) != 0
}
func IsTexture(t Texture) bool {
return C.glIsTexture(t.c()) != 0
}
func LineWidth(width float32) {
C.glLineWidth(C.GLfloat(width))
}
func LinkProgram(p Program) {
C.glLinkProgram(p.c())
}
func ObjectLabel(o Object, label string) {
str := unsafe.Pointer(C.CString(label))
defer C.free(str)
C.glObjectLabel(o.Identifier().c(), C.GLUint(o.Name()), -1, (*C.GLchar)(str))
}
func PixelStorei(pname Enum, param int32) {
C.glPixelStorei(pname.c(), C.GLint(param))
}
func PolygonOffset(factor, units float32) {
C.glPolygonOffset(C.GLfloat(factor), C.GLfloat(units))
}
func ReadPixels(dst []byte, x, y, width, height int, format, ty Enum) {
C.glReadPixels(C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height), format.c(), ty.c(), unsafe.Pointer(&dst[0]))
}
func ReleaseShaderCompiler() {
C.glReleaseShaderCompiler()
}
func RenderbufferStorage(target, internalFormat Enum, width, height int) {
C.glRenderbufferStorage(target.c(), internalFormat.c(), C.GLsizei(width), C.GLsizei(height))
}
func SampleCoverage(value float32, invert bool) {
sampleCoverage(value, invert)
}
func Scissor(x, y, width, height int32) {
C.glScissor(C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height))
}
func ShaderSource(s Shader, src string) {
str := (*C.GLchar)(C.CString(src))
defer C.free(unsafe.Pointer(str))
C.glShaderSource(s.c(), 1, &str, nil)
}
func StencilFunc(fn Enum, ref int, mask uint32) {
C.glStencilFunc(fn.c(), C.GLint(ref), C.GLuint(mask))
}
func StencilFuncSeparate(face, fn Enum, ref int, mask uint32) {
C.glStencilFuncSeparate(face.c(), fn.c(), C.GLint(ref), C.GLuint(mask))
}
func StencilMask(mask uint32) {
C.glStencilMask(C.GLuint(mask))
}
func StencilMaskSeparate(face Enum, mask uint32) {
C.glStencilMaskSeparate(face.c(), C.GLuint(mask))
}
func StencilOp(fail, zfail, zpass Enum) {
C.glStencilOp(fail.c(), zfail.c(), zpass.c())
}
func StencilOpSeparate(face, sfail, dpfail, dppass Enum) {
C.glStencilOpSeparate(face.c(), sfail.c(), dpfail.c(), dppass.c())
}
func TexImage2D(target Enum, level int, width, height int, format Enum, ty Enum, data []byte) {
p := unsafe.Pointer(nil)
if len(data) > 0 {
p = unsafe.Pointer(&data[0])
}
C.glTexImage2D(target.c(), C.GLint(level), C.GLint(format), C.GLsizei(width), C.GLsizei(height), 0, format.c(), ty.c(), p)
}
func TexImage2DMultisample(target Enum, samples int, internalformat Enum, width, height int, fixedsamplelocations bool) {
println("TexImage2DMultisample: not available on OpenGL ES.")
}
func TexSubImage2D(target Enum, level int, x, y, width, height int, format, ty Enum, data []byte) {
C.glTexSubImage2D(target.c(), C.GLint(level), C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height), format.c(), ty.c(), unsafe.Pointer(&data[0]))
}
func TexParameterf(target, pname Enum, param float32) {
C.glTexParameterf(target.c(), pname.c(), C.GLfloat(param))
}
func TexParameterfv(target, pname Enum, params []float32) {
C.glTexParameterfv(target.c(), pname.c(), (*C.GLfloat)(¶ms[0]))
}
func TexParameteri(target, pname Enum, param int) {
C.glTexParameteri(target.c(), pname.c(), C.GLint(param))
}
func TexParameteriv(target, pname Enum, params []int32) {
C.glTexParameteriv(target.c(), pname.c(), (*C.GLint)(¶ms[0]))
}
func Uniform1f(dst Uniform, v float32) {
C.glUniform1f(dst.c(), C.GLfloat(v))
}
func Uniform1fv(dst Uniform, src []float32) {
C.glUniform1fv(dst.c(), C.GLsizei(len(src)), (*C.GLfloat)(&src[0]))
}
func Uniform1i(dst Uniform, v int) {
C.glUniform1i(dst.c(), C.GLint(v))
}
func Uniform1iv(dst Uniform, src []int32) {
C.glUniform1iv(dst.c(), C.GLsizei(len(src)), (*C.GLint)(&src[0]))
}
func Uniform2f(dst Uniform, v0, v1 float32) {
C.glUniform2f(dst.c(), C.GLfloat(v0), C.GLfloat(v1))
}
func Uniform2fv(dst Uniform, src []float32) {
C.glUniform2fv(dst.c(), C.GLsizei(len(src)/2), (*C.GLfloat)(&src[0]))
}
func Uniform2i(dst Uniform, v0, v1 int) {
C.glUniform2i(dst.c(), C.GLint(v0), C.GLint(v1))
}
func Uniform2iv(dst Uniform, src []int32) {
C.glUniform2iv(dst.c(), C.GLsizei(len(src)/2), (*C.GLint)(&src[0]))
}
func Uniform3f(dst Uniform, v0, v1, v2 float32) {
C.glUniform3f(dst.c(), C.GLfloat(v0), C.GLfloat(v1), C.GLfloat(v2))
}
func Uniform3fv(dst Uniform, src []float32) {
C.glUniform3fv(dst.c(), C.GLsizei(len(src)/3), (*C.GLfloat)(&src[0]))
}
func Uniform3i(dst Uniform, v0, v1, v2 int32) {
C.glUniform3i(dst.c(), C.GLint(v0), C.GLint(v1), C.GLint(v2))
}
func Uniform3iv(dst Uniform, src []int32) {
C.glUniform3iv(dst.c(), C.GLsizei(len(src)/3), (*C.GLint)(&src[0]))
}
func Uniform4f(dst Uniform, v0, v1, v2, v3 float32) {
C.glUniform4f(dst.c(), C.GLfloat(v0), C.GLfloat(v1), C.GLfloat(v2), C.GLfloat(v3))
}
func Uniform4fv(dst Uniform, src []float32) {
C.glUniform4fv(dst.c(), C.GLsizei(len(src)/4), (*C.GLfloat)(&src[0]))
}
func Uniform4i(dst Uniform, v0, v1, v2, v3 int32) {
C.glUniform4i(dst.c(), C.GLint(v0), C.GLint(v1), C.GLint(v2), C.GLint(v3))
}
func Uniform4iv(dst Uniform, src []int32) {
C.glUniform4iv(dst.c(), C.GLsizei(len(src)/4), (*C.GLint)(&src[0]))
}
func UniformMatrix2fv(dst Uniform, src []float32) {
// OpenGL ES 2 does not support transpose.
C.glUniformMatrix2fv(dst.c(), C.GLsizei(len(src)/4), 0, (*C.GLfloat)(&src[0]))
}
func UniformMatrix3fv(dst Uniform, src []float32) {
C.glUniformMatrix3fv(dst.c(), C.GLsizei(len(src)/9), 0, (*C.GLfloat)(&src[0]))
}
func UniformMatrix4fv(dst Uniform, src []float32) {
C.glUniformMatrix4fv(dst.c(), C.GLsizei(len(src)/16), 0, (*C.GLfloat)(&src[0]))
}
func UseProgram(p Program) {
C.glUseProgram(p.c())
}
func ValidateProgram(p Program) {
C.glValidateProgram(p.c())
}
func VertexAttrib1f(dst Attrib, x float32) {
C.glVertexAttrib1f(dst.c(), C.GLfloat(x))
}
func VertexAttrib1fv(dst Attrib, src []float32) {
C.glVertexAttrib1fv(dst.c(), (*C.GLfloat)(&src[0]))
}
func VertexAttrib2f(dst Attrib, x, y float32) {
C.glVertexAttrib2f(dst.c(), C.GLfloat(x), C.GLfloat(y))
}
func VertexAttrib2fv(dst Attrib, src []float32) {
C.glVertexAttrib2fv(dst.c(), (*C.GLfloat)(&src[0]))
}
func VertexAttrib3f(dst Attrib, x, y, z float32) {
C.glVertexAttrib3f(dst.c(), C.GLfloat(x), C.GLfloat(y), C.GLfloat(z))
}
func VertexAttrib3fv(dst Attrib, src []float32) {
C.glVertexAttrib3fv(dst.c(), (*C.GLfloat)(&src[0]))
}
func VertexAttrib4f(dst Attrib, x, y, z, w float32) {
C.glVertexAttrib4f(dst.c(), C.GLfloat(x), C.GLfloat(y), C.GLfloat(z), C.GLfloat(w))
}
func VertexAttrib4fv(dst Attrib, src []float32) {
C.glVertexAttrib4fv(dst.c(), (*C.GLfloat)(&src[0]))
}
func VertexAttribPointer(dst Attrib, size int, ty Enum, normalized bool, stride, offset int) {
n := glBoolean(normalized)
s := C.GLsizei(stride)
C.glVertexAttribPointer(dst.c(), C.GLint(size), ty.c(), n, s, unsafe.Pointer(uintptr(offset)))
}
func Viewport(x, y, width, height int) {
C.glViewport(C.GLint(x), C.GLint(y), C.GLsizei(width), C.GLsizei(height))
}