Debian Codegraph @

gl/gl.go

raw symbols SCIP
1 // Copyright 2014 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //go:build (darwin || linux || openbsd || windows) && !gldebug
6
7 package gl
8
9 // TODO(crawshaw): should functions on specific types become methods? E.g.
10 // func (t Texture) Bind(target Enum)
11 // this seems natural in Go, but moves us slightly
12 // further away from the underlying OpenGL spec.
13
14 import (
15 "math"
16 "unsafe"
17 )
18
19 func (ctx *context) ActiveTexture(texture Enum) {
20 ctx.enqueue(call{
21 args: fnargs{
22 fn: glfnActiveTexture,
23 a0: texture.c(),
24 },
25 })
26 }
27
28 func (ctx *context) AttachShader(p Program, s Shader) {
29 ctx.enqueue(call{
30 args: fnargs{
31 fn: glfnAttachShader,
32 a0: p.c(),
33 a1: s.c(),
34 },
35 })
36 }
37
38 func (ctx *context) BindAttribLocation(p Program, a Attrib, name string) {
39 s, free := ctx.cString(name)
40 defer free()
41 ctx.enqueue(call{
42 args: fnargs{
43 fn: glfnBindAttribLocation,
44 a0: p.c(),
45 a1: a.c(),
46 a2: s,
47 },
48 blocking: true,
49 })
50 }
51
52 func (ctx *context) BindBuffer(target Enum, b Buffer) {
53 ctx.enqueue(call{
54 args: fnargs{
55 fn: glfnBindBuffer,
56 a0: target.c(),
57 a1: b.c(),
58 },
59 })
60 }
61
62 func (ctx *context) BindFramebuffer(target Enum, fb Framebuffer) {
63 ctx.enqueue(call{
64 args: fnargs{
65 fn: glfnBindFramebuffer,
66 a0: target.c(),
67 a1: fb.c(),
68 },
69 })
70 }
71
72 func (ctx *context) BindRenderbuffer(target Enum, rb Renderbuffer) {
73 ctx.enqueue(call{
74 args: fnargs{
75 fn: glfnBindRenderbuffer,
76 a0: target.c(),
77 a1: rb.c(),
78 },
79 })
80 }
81
82 func (ctx *context) BindTexture(target Enum, t Texture) {
83 ctx.enqueue(call{
84 args: fnargs{
85 fn: glfnBindTexture,
86 a0: target.c(),
87 a1: t.c(),
88 },
89 })
90 }
91
92 func (ctx *context) BindVertexArray(va VertexArray) {
93 ctx.enqueue(call{
94 args: fnargs{
95 fn: glfnBindVertexArray,
96 a0: va.c(),
97 },
98 })
99 }
100
101 func (ctx *context) BlendColor(red, green, blue, alpha float32) {
102 ctx.enqueue(call{
103 args: fnargs{
104 fn: glfnBlendColor,
105 a0: uintptr(math.Float32bits(red)),
106 a1: uintptr(math.Float32bits(green)),
107 a2: uintptr(math.Float32bits(blue)),
108 a3: uintptr(math.Float32bits(alpha)),
109 },
110 })
111 }
112
113 func (ctx *context) BlendEquation(mode Enum) {
114 ctx.enqueue(call{
115 args: fnargs{
116 fn: glfnBlendEquation,
117 a0: mode.c(),
118 },
119 })
120 }
121
122 func (ctx *context) BlendEquationSeparate(modeRGB, modeAlpha Enum) {
123 ctx.enqueue(call{
124 args: fnargs{
125 fn: glfnBlendEquationSeparate,
126 a0: modeRGB.c(),
127 a1: modeAlpha.c(),
128 },
129 })
130 }
131
132 func (ctx *context) BlendFunc(sfactor, dfactor Enum) {
133 ctx.enqueue(call{
134 args: fnargs{
135 fn: glfnBlendFunc,
136 a0: sfactor.c(),
137 a1: dfactor.c(),
138 },
139 })
140 }
141
142 func (ctx *context) BlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha Enum) {
143 ctx.enqueue(call{
144 args: fnargs{
145 fn: glfnBlendFuncSeparate,
146 a0: sfactorRGB.c(),
147 a1: dfactorRGB.c(),
148 a2: sfactorAlpha.c(),
149 a3: dfactorAlpha.c(),
150 },
151 })
152 }
153
154 func (ctx *context) BufferData(target Enum, src []byte, usage Enum) {
155 parg := unsafe.Pointer(nil)
156 if len(src) > 0 {
157 parg = unsafe.Pointer(&src[0])
158 }
159 ctx.enqueue(call{
160 args: fnargs{
161 fn: glfnBufferData,
162 a0: target.c(),
163 a1: uintptr(len(src)),
164 a2: usage.c(),
165 },
166 parg: parg,
167 blocking: true,
168 })
169 }
170
171 func (ctx *context) BufferInit(target Enum, size int, usage Enum) {
172 ctx.enqueue(call{
173 args: fnargs{
174 fn: glfnBufferData,
175 a0: target.c(),
176 a1: uintptr(size),
177 a2: usage.c(),
178 },
179 parg: unsafe.Pointer(nil),
180 })
181 }
182
183 func (ctx *context) BufferSubData(target Enum, offset int, data []byte) {
184 ctx.enqueue(call{
185 args: fnargs{
186 fn: glfnBufferSubData,
187 a0: target.c(),
188 a1: uintptr(offset),
189 a2: uintptr(len(data)),
190 },
191 parg: unsafe.Pointer(&data[0]),
192 blocking: true,
193 })
194 }
195
196 func (ctx *context) CheckFramebufferStatus(target Enum) Enum {
197 return Enum(ctx.enqueue(call{
198 args: fnargs{
199 fn: glfnCheckFramebufferStatus,
200 a0: target.c(),
201 },
202 blocking: true,
203 }))
204 }
205
206 func (ctx *context) Clear(mask Enum) {
207 ctx.enqueue(call{
208 args: fnargs{
209 fn: glfnClear,
210 a0: uintptr(mask),
211 },
212 })
213 }
214
215 func (ctx *context) ClearColor(red, green, blue, alpha float32) {
216 ctx.enqueue(call{
217 args: fnargs{
218 fn: glfnClearColor,
219 a0: uintptr(math.Float32bits(red)),
220 a1: uintptr(math.Float32bits(green)),
221 a2: uintptr(math.Float32bits(blue)),
222 a3: uintptr(math.Float32bits(alpha)),
223 },
224 })
225 }
226
227 func (ctx *context) ClearDepthf(d float32) {
228 ctx.enqueue(call{
229 args: fnargs{
230 fn: glfnClearDepthf,
231 a0: uintptr(math.Float32bits(d)),
232 },
233 })
234 }
235
236 func (ctx *context) ClearStencil(s int) {
237 ctx.enqueue(call{
238 args: fnargs{
239 fn: glfnClearStencil,
240 a0: uintptr(s),
241 },
242 })
243 }
244
245 func (ctx *context) ColorMask(red, green, blue, alpha bool) {
246 ctx.enqueue(call{
247 args: fnargs{
248 fn: glfnColorMask,
249 a0: glBoolean(red),
250 a1: glBoolean(green),
251 a2: glBoolean(blue),
252 a3: glBoolean(alpha),
253 },
254 })
255 }
256
257 func (ctx *context) CompileShader(s Shader) {
258 ctx.enqueue(call{
259 args: fnargs{
260 fn: glfnCompileShader,
261 a0: s.c(),
262 },
263 })
264 }
265
266 func (ctx *context) CompressedTexImage2D(target Enum, level int, internalformat Enum, width, height, border int, data []byte) {
267 ctx.enqueue(call{
268 args: fnargs{
269 fn: glfnCompressedTexImage2D,
270 a0: target.c(),
271 a1: uintptr(level),
272 a2: internalformat.c(),
273 a3: uintptr(width),
274 a4: uintptr(height),
275 a5: uintptr(border),
276 a6: uintptr(len(data)),
277 },
278 parg: unsafe.Pointer(&data[0]),
279 blocking: true,
280 })
281 }
282
283 func (ctx *context) CompressedTexSubImage2D(target Enum, level, xoffset, yoffset, width, height int, format Enum, data []byte) {
284 ctx.enqueue(call{
285 args: fnargs{
286 fn: glfnCompressedTexSubImage2D,
287 a0: target.c(),
288 a1: uintptr(level),
289 a2: uintptr(xoffset),
290 a3: uintptr(yoffset),
291 a4: uintptr(width),
292 a5: uintptr(height),
293 a6: format.c(),
294 a7: uintptr(len(data)),
295 },
296 parg: unsafe.Pointer(&data[0]),
297 blocking: true,
298 })
299 }
300
301 func (ctx *context) CopyTexImage2D(target Enum, level int, internalformat Enum, x, y, width, height, border int) {
302 ctx.enqueue(call{
303 args: fnargs{
304 fn: glfnCopyTexImage2D,
305 a0: target.c(),
306 a1: uintptr(level),
307 a2: internalformat.c(),
308 a3: uintptr(x),
309 a4: uintptr(y),
310 a5: uintptr(width),
311 a6: uintptr(height),
312 a7: uintptr(border),
313 },
314 })
315 }
316
317 func (ctx *context) CopyTexSubImage2D(target Enum, level, xoffset, yoffset, x, y, width, height int) {
318 ctx.enqueue(call{
319 args: fnargs{
320 fn: glfnCopyTexSubImage2D,
321 a0: target.c(),
322 a1: uintptr(level),
323 a2: uintptr(xoffset),
324 a3: uintptr(yoffset),
325 a4: uintptr(x),
326 a5: uintptr(y),
327 a6: uintptr(width),
328 a7: uintptr(height),
329 },
330 })
331 }
332
333 func (ctx *context) CreateBuffer() Buffer {
334 return Buffer{Value: uint32(ctx.enqueue(call{
335 args: fnargs{
336 fn: glfnGenBuffer,
337 },
338 blocking: true,
339 }))}
340 }
341
342 func (ctx *context) CreateFramebuffer() Framebuffer {
343 return Framebuffer{Value: uint32(ctx.enqueue(call{
344 args: fnargs{
345 fn: glfnGenFramebuffer,
346 },
347 blocking: true,
348 }))}
349 }
350
351 func (ctx *context) CreateProgram() Program {
352 return Program{
353 Init: true,
354 Value: uint32(ctx.enqueue(call{
355 args: fnargs{
356 fn: glfnCreateProgram,
357 },
358 blocking: true,
359 },
360 ))}
361 }
362
363 func (ctx *context) CreateRenderbuffer() Renderbuffer {
364 return Renderbuffer{Value: uint32(ctx.enqueue(call{
365 args: fnargs{
366 fn: glfnGenRenderbuffer,
367 },
368 blocking: true,
369 }))}
370 }
371
372 func (ctx *context) CreateShader(ty Enum) Shader {
373 return Shader{Value: uint32(ctx.enqueue(call{
374 args: fnargs{
375 fn: glfnCreateShader,
376 a0: uintptr(ty),
377 },
378 blocking: true,
379 }))}
380 }
381
382 func (ctx *context) CreateTexture() Texture {
383 return Texture{Value: uint32(ctx.enqueue(call{
384 args: fnargs{
385 fn: glfnGenTexture,
386 },
387 blocking: true,
388 }))}
389 }
390
391 func (ctx *context) CreateVertexArray() VertexArray {
392 return VertexArray{Value: uint32(ctx.enqueue(call{
393 args: fnargs{
394 fn: glfnGenVertexArray,
395 },
396 blocking: true,
397 }))}
398 }
399
400 func (ctx *context) CullFace(mode Enum) {
401 ctx.enqueue(call{
402 args: fnargs{
403 fn: glfnCullFace,
404 a0: mode.c(),
405 },
406 })
407 }
408
409 func (ctx *context) DeleteBuffer(v Buffer) {
410 ctx.enqueue(call{
411 args: fnargs{
412 fn: glfnDeleteBuffer,
413 a0: v.c(),
414 },
415 })
416 }
417
418 func (ctx *context) DeleteFramebuffer(v Framebuffer) {
419 ctx.enqueue(call{
420 args: fnargs{
421 fn: glfnDeleteFramebuffer,
422 a0: v.c(),
423 },
424 })
425 }
426
427 func (ctx *context) DeleteProgram(p Program) {
428 ctx.enqueue(call{
429 args: fnargs{
430 fn: glfnDeleteProgram,
431 a0: p.c(),
432 },
433 })
434 }
435
436 func (ctx *context) DeleteRenderbuffer(v Renderbuffer) {
437 ctx.enqueue(call{
438 args: fnargs{
439 fn: glfnDeleteRenderbuffer,
440 a0: v.c(),
441 },
442 })
443 }
444
445 func (ctx *context) DeleteShader(s Shader) {
446 ctx.enqueue(call{
447 args: fnargs{
448 fn: glfnDeleteShader,
449 a0: s.c(),
450 },
451 })
452 }
453
454 func (ctx *context) DeleteTexture(v Texture) {
455 ctx.enqueue(call{
456 args: fnargs{
457 fn: glfnDeleteTexture,
458 a0: v.c(),
459 },
460 })
461 }
462
463 func (ctx *context) DeleteVertexArray(v VertexArray) {
464 ctx.enqueue(call{
465 args: fnargs{
466 fn: glfnDeleteVertexArray,
467 a0: v.c(),
468 },
469 })
470 }
471
472 func (ctx *context) DepthFunc(fn Enum) {
473 ctx.enqueue(call{
474 args: fnargs{
475 fn: glfnDepthFunc,
476 a0: fn.c(),
477 },
478 })
479 }
480
481 func (ctx *context) DepthMask(flag bool) {
482 ctx.enqueue(call{
483 args: fnargs{
484 fn: glfnDepthMask,
485 a0: glBoolean(flag),
486 },
487 })
488 }
489
490 func (ctx *context) DepthRangef(n, f float32) {
491 ctx.enqueue(call{
492 args: fnargs{
493 fn: glfnDepthRangef,
494 a0: uintptr(math.Float32bits(n)),
495 a1: uintptr(math.Float32bits(f)),
496 },
497 })
498 }
499
500 func (ctx *context) DetachShader(p Program, s Shader) {
501 ctx.enqueue(call{
502 args: fnargs{
503 fn: glfnDetachShader,
504 a0: p.c(),
505 a1: s.c(),
506 },
507 })
508 }
509
510 func (ctx *context) Disable(cap Enum) {
511 ctx.enqueue(call{
512 args: fnargs{
513 fn: glfnDisable,
514 a0: cap.c(),
515 },
516 })
517 }
518
519 func (ctx *context) DisableVertexAttribArray(a Attrib) {
520 ctx.enqueue(call{
521 args: fnargs{
522 fn: glfnDisableVertexAttribArray,
523 a0: a.c(),
524 },
525 })
526 }
527
528 func (ctx *context) DrawArrays(mode Enum, first, count int) {
529 ctx.enqueue(call{
530 args: fnargs{
531 fn: glfnDrawArrays,
532 a0: mode.c(),
533 a1: uintptr(first),
534 a2: uintptr(count),
535 },
536 })
537 }
538
539 func (ctx *context) DrawElements(mode Enum, count int, ty Enum, offset int) {
540 ctx.enqueue(call{
541 args: fnargs{
542 fn: glfnDrawElements,
543 a0: mode.c(),
544 a1: uintptr(count),
545 a2: ty.c(),
546 a3: uintptr(offset),
547 },
548 })
549 }
550
551 func (ctx *context) Enable(cap Enum) {
552 ctx.enqueue(call{
553 args: fnargs{
554 fn: glfnEnable,
555 a0: cap.c(),
556 },
557 })
558 }
559
560 func (ctx *context) EnableVertexAttribArray(a Attrib) {
561 ctx.enqueue(call{
562 args: fnargs{
563 fn: glfnEnableVertexAttribArray,
564 a0: a.c(),
565 },
566 })
567 }
568
569 func (ctx *context) Finish() {
570 ctx.enqueue(call{
571 args: fnargs{
572 fn: glfnFinish,
573 },
574 blocking: true,
575 })
576 }
577
578 func (ctx *context) Flush() {
579 ctx.enqueue(call{
580 args: fnargs{
581 fn: glfnFlush,
582 },
583 blocking: true,
584 })
585 }
586
587 func (ctx *context) FramebufferRenderbuffer(target, attachment, rbTarget Enum, rb Renderbuffer) {
588 ctx.enqueue(call{
589 args: fnargs{
590 fn: glfnFramebufferRenderbuffer,
591 a0: target.c(),
592 a1: attachment.c(),
593 a2: rbTarget.c(),
594 a3: rb.c(),
595 },
596 })
597 }
598
599 func (ctx *context) FramebufferTexture2D(target, attachment, texTarget Enum, t Texture, level int) {
600 ctx.enqueue(call{
601 args: fnargs{
602 fn: glfnFramebufferTexture2D,
603 a0: target.c(),
604 a1: attachment.c(),
605 a2: texTarget.c(),
606 a3: t.c(),
607 a4: uintptr(level),
608 },
609 })
610 }
611
612 func (ctx *context) FrontFace(mode Enum) {
613 ctx.enqueue(call{
614 args: fnargs{
615 fn: glfnFrontFace,
616 a0: mode.c(),
617 },
618 })
619 }
620
621 func (ctx *context) GenerateMipmap(target Enum) {
622 ctx.enqueue(call{
623 args: fnargs{
624 fn: glfnGenerateMipmap,
625 a0: target.c(),
626 },
627 })
628 }
629
630 func (ctx *context) GetActiveAttrib(p Program, index uint32) (name string, size int, ty Enum) {
631 bufSize := ctx.GetProgrami(p, ACTIVE_ATTRIBUTE_MAX_LENGTH)
632 buf := make([]byte, bufSize)
633 var cType int
634
635 cSize := ctx.enqueue(call{
636 args: fnargs{
637 fn: glfnGetActiveAttrib,
638 a0: p.c(),
639 a1: uintptr(index),
640 a2: uintptr(bufSize),
641 a3: uintptr(unsafe.Pointer(&cType)), // TODO(crawshaw): not safe for a moving collector
642 },
643 parg: unsafe.Pointer(&buf[0]),
644 blocking: true,
645 })
646
647 return goString(buf), int(cSize), Enum(cType)
648 }
649
650 func (ctx *context) GetActiveUniform(p Program, index uint32) (name string, size int, ty Enum) {
651 bufSize := ctx.GetProgrami(p, ACTIVE_UNIFORM_MAX_LENGTH)
652 buf := make([]byte, bufSize+8) // extra space for cType
653 var cType int
654
655 cSize := ctx.enqueue(call{
656 args: fnargs{
657 fn: glfnGetActiveUniform,
658 a0: p.c(),
659 a1: uintptr(index),
660 a2: uintptr(bufSize),
661 a3: uintptr(unsafe.Pointer(&cType)), // TODO(crawshaw): not safe for a moving collector
662 },
663 parg: unsafe.Pointer(&buf[0]),
664 blocking: true,
665 })
666
667 return goString(buf), int(cSize), Enum(cType)
668 }
669
670 func (ctx *context) GetAttachedShaders(p Program) []Shader {
671 shadersLen := ctx.GetProgrami(p, ATTACHED_SHADERS)
672 if shadersLen == 0 {
673 return nil
674 }
675 buf := make([]uint32, shadersLen)
676
677 n := int(ctx.enqueue(call{
678 args: fnargs{
679 fn: glfnGetAttachedShaders,
680 a0: p.c(),
681 a1: uintptr(shadersLen),
682 },
683 parg: unsafe.Pointer(&buf[0]),
684 blocking: true,
685 }))
686
687 buf = buf[:int(n)]
688 shaders := make([]Shader, len(buf))
689 for i, s := range buf {
690 shaders[i] = Shader{Value: uint32(s)}
691 }
692 return shaders
693 }
694
695 func (ctx *context) GetAttribLocation(p Program, name string) Attrib {
696 s, free := ctx.cString(name)
697 defer free()
698 return Attrib{Value: uint(ctx.enqueue(call{
699 args: fnargs{
700 fn: glfnGetAttribLocation,
701 a0: p.c(),
702 a1: s,
703 },
704 blocking: true,
705 }))}
706 }
707
708 func (ctx *context) GetBooleanv(dst []bool, pname Enum) {
709 buf := make([]int32, len(dst))
710
711 ctx.enqueue(call{
712 args: fnargs{
713 fn: glfnGetBooleanv,
714 a0: pname.c(),
715 },
716 parg: unsafe.Pointer(&buf[0]),
717 blocking: true,
718 })
719
720 for i, v := range buf {
721 dst[i] = v != 0
722 }
723 }
724
725 func (ctx *context) GetFloatv(dst []float32, pname Enum) {
726 ctx.enqueue(call{
727 args: fnargs{
728 fn: glfnGetFloatv,
729 a0: pname.c(),
730 },
731 parg: unsafe.Pointer(&dst[0]),
732 blocking: true,
733 })
734 }
735
736 func (ctx *context) GetIntegerv(dst []int32, pname Enum) {
737 ctx.enqueue(call{
738 args: fnargs{
739 fn: glfnGetIntegerv,
740 a0: pname.c(),
741 },
742 parg: unsafe.Pointer(&dst[0]),
743 blocking: true,
744 })
745 }
746
747 func (ctx *context) GetInteger(pname Enum) int {
748 var v [1]int32
749 ctx.GetIntegerv(v[:], pname)
750 return int(v[0])
751 }
752
753 func (ctx *context) GetBufferParameteri(target, value Enum) int {
754 return int(ctx.enqueue(call{
755 args: fnargs{
756 fn: glfnGetBufferParameteri,
757 a0: target.c(),
758 a1: value.c(),
759 },
760 blocking: true,
761 }))
762 }
763
764 func (ctx *context) GetError() Enum {
765 return Enum(ctx.enqueue(call{
766 args: fnargs{
767 fn: glfnGetError,
768 },
769 blocking: true,
770 }))
771 }
772
773 func (ctx *context) GetFramebufferAttachmentParameteri(target, attachment, pname Enum) int {
774 return int(ctx.enqueue(call{
775 args: fnargs{
776 fn: glfnGetFramebufferAttachmentParameteriv,
777 a0: target.c(),
778 a1: attachment.c(),
779 a2: pname.c(),
780 },
781 blocking: true,
782 }))
783 }
784
785 func (ctx *context) GetProgrami(p Program, pname Enum) int {
786 return int(ctx.enqueue(call{
787 args: fnargs{
788 fn: glfnGetProgramiv,
789 a0: p.c(),
790 a1: pname.c(),
791 },
792 blocking: true,
793 }))
794 }
795
796 func (ctx *context) GetProgramInfoLog(p Program) string {
797 infoLen := ctx.GetProgrami(p, INFO_LOG_LENGTH)
798 if infoLen == 0 {
799 return ""
800 }
801 buf := make([]byte, infoLen)
802
803 ctx.enqueue(call{
804 args: fnargs{
805 fn: glfnGetProgramInfoLog,
806 a0: p.c(),
807 a1: uintptr(infoLen),
808 },
809 parg: unsafe.Pointer(&buf[0]),
810 blocking: true,
811 })
812
813 return goString(buf)
814 }
815
816 func (ctx *context) GetRenderbufferParameteri(target, pname Enum) int {
817 return int(ctx.enqueue(call{
818 args: fnargs{
819 fn: glfnGetRenderbufferParameteriv,
820 a0: target.c(),
821 a1: pname.c(),
822 },
823 blocking: true,
824 }))
825 }
826
827 func (ctx *context) GetShaderi(s Shader, pname Enum) int {
828 return int(ctx.enqueue(call{
829 args: fnargs{
830 fn: glfnGetShaderiv,
831 a0: s.c(),
832 a1: pname.c(),
833 },
834 blocking: true,
835 }))
836 }
837
838 func (ctx *context) GetShaderInfoLog(s Shader) string {
839 infoLen := ctx.GetShaderi(s, INFO_LOG_LENGTH)
840 if infoLen == 0 {
841 return ""
842 }
843 buf := make([]byte, infoLen)
844
845 ctx.enqueue(call{
846 args: fnargs{
847 fn: glfnGetShaderInfoLog,
848 a0: s.c(),
849 a1: uintptr(infoLen),
850 },
851 parg: unsafe.Pointer(&buf[0]),
852 blocking: true,
853 })
854
855 return goString(buf)
856 }
857
858 func (ctx *context) GetShaderPrecisionFormat(shadertype, precisiontype Enum) (rangeLow, rangeHigh, precision int) {
859 var rangeAndPrec [3]int32
860
861 ctx.enqueue(call{
862 args: fnargs{
863 fn: glfnGetShaderPrecisionFormat,
864 a0: shadertype.c(),
865 a1: precisiontype.c(),
866 },
867 parg: unsafe.Pointer(&rangeAndPrec[0]),
868 blocking: true,
869 })
870
871 return int(rangeAndPrec[0]), int(rangeAndPrec[1]), int(rangeAndPrec[2])
872 }
873
874 func (ctx *context) GetShaderSource(s Shader) string {
875 sourceLen := ctx.GetShaderi(s, SHADER_SOURCE_LENGTH)
876 if sourceLen == 0 {
877 return ""
878 }
879 buf := make([]byte, sourceLen)
880
881 ctx.enqueue(call{
882 args: fnargs{
883 fn: glfnGetShaderSource,
884 a0: s.c(),
885 a1: uintptr(sourceLen),
886 },
887 parg: unsafe.Pointer(&buf[0]),
888 blocking: true,
889 })
890
891 return goString(buf)
892 }
893
894 func (ctx *context) GetString(pname Enum) string {
895 ret := ctx.enqueue(call{
896 args: fnargs{
897 fn: glfnGetString,
898 a0: pname.c(),
899 },
900 blocking: true,
901 })
902 retp := unsafe.Pointer(ret)
903 buf := (*[1 << 24]byte)(retp)[:]
904 return goString(buf)
905 }
906
907 func (ctx *context) GetTexParameterfv(dst []float32, target, pname Enum) {
908 ctx.enqueue(call{
909 args: fnargs{
910 fn: glfnGetTexParameterfv,
911 a0: target.c(),
912 a1: pname.c(),
913 },
914 parg: unsafe.Pointer(&dst[0]),
915 blocking: true,
916 })
917 }
918
919 func (ctx *context) GetTexParameteriv(dst []int32, target, pname Enum) {
920 ctx.enqueue(call{
921 args: fnargs{
922 fn: glfnGetTexParameteriv,
923 a0: target.c(),
924 a1: pname.c(),
925 },
926 blocking: true,
927 })
928 }
929
930 func (ctx *context) GetUniformfv(dst []float32, src Uniform, p Program) {
931 ctx.enqueue(call{
932 args: fnargs{
933 fn: glfnGetUniformfv,
934 a0: p.c(),
935 a1: src.c(),
936 },
937 parg: unsafe.Pointer(&dst[0]),
938 blocking: true,
939 })
940 }
941
942 func (ctx *context) GetUniformiv(dst []int32, src Uniform, p Program) {
943 ctx.enqueue(call{
944 args: fnargs{
945 fn: glfnGetUniformiv,
946 a0: p.c(),
947 a1: src.c(),
948 },
949 parg: unsafe.Pointer(&dst[0]),
950 blocking: true,
951 })
952 }
953
954 func (ctx *context) GetUniformLocation(p Program, name string) Uniform {
955 s, free := ctx.cString(name)
956 defer free()
957 return Uniform{Value: int32(ctx.enqueue(call{
958 args: fnargs{
959 fn: glfnGetUniformLocation,
960 a0: p.c(),
961 a1: s,
962 },
963 blocking: true,
964 }))}
965 }
966
967 func (ctx *context) GetVertexAttribf(src Attrib, pname Enum) float32 {
968 var params [1]float32
969 ctx.GetVertexAttribfv(params[:], src, pname)
970 return params[0]
971 }
972
973 func (ctx *context) GetVertexAttribfv(dst []float32, src Attrib, pname Enum) {
974 ctx.enqueue(call{
975 args: fnargs{
976 fn: glfnGetVertexAttribfv,
977 a0: src.c(),
978 a1: pname.c(),
979 },
980 parg: unsafe.Pointer(&dst[0]),
981 blocking: true,
982 })
983 }
984
985 func (ctx *context) GetVertexAttribi(src Attrib, pname Enum) int32 {
986 var params [1]int32
987 ctx.GetVertexAttribiv(params[:], src, pname)
988 return params[0]
989 }
990
991 func (ctx *context) GetVertexAttribiv(dst []int32, src Attrib, pname Enum) {
992 ctx.enqueue(call{
993 args: fnargs{
994 fn: glfnGetVertexAttribiv,
995 a0: src.c(),
996 a1: pname.c(),
997 },
998 parg: unsafe.Pointer(&dst[0]),
999 blocking: true,
1000 })
1001 }
1002
1003 func (ctx *context) Hint(target, mode Enum) {
1004 ctx.enqueue(call{
1005 args: fnargs{
1006 fn: glfnHint,
1007 a0: target.c(),
1008 a1: mode.c(),
1009 },
1010 })
1011 }
1012
1013 func (ctx *context) IsBuffer(b Buffer) bool {
1014 return 0 != ctx.enqueue(call{
1015 args: fnargs{
1016 fn: glfnIsBuffer,
1017 a0: b.c(),
1018 },
1019 blocking: true,
1020 })
1021 }
1022
1023 func (ctx *context) IsEnabled(cap Enum) bool {
1024 return 0 != ctx.enqueue(call{
1025 args: fnargs{
1026 fn: glfnIsEnabled,
1027 a0: cap.c(),
1028 },
1029 blocking: true,
1030 })
1031 }
1032
1033 func (ctx *context) IsFramebuffer(fb Framebuffer) bool {
1034 return 0 != ctx.enqueue(call{
1035 args: fnargs{
1036 fn: glfnIsFramebuffer,
1037 a0: fb.c(),
1038 },
1039 blocking: true,
1040 })
1041 }
1042
1043 func (ctx *context) IsProgram(p Program) bool {
1044 return 0 != ctx.enqueue(call{
1045 args: fnargs{
1046 fn: glfnIsProgram,
1047 a0: p.c(),
1048 },
1049 blocking: true,
1050 })
1051 }
1052
1053 func (ctx *context) IsRenderbuffer(rb Renderbuffer) bool {
1054 return 0 != ctx.enqueue(call{
1055 args: fnargs{
1056 fn: glfnIsRenderbuffer,
1057 a0: rb.c(),
1058 },
1059 blocking: true,
1060 })
1061 }
1062
1063 func (ctx *context) IsShader(s Shader) bool {
1064 return 0 != ctx.enqueue(call{
1065 args: fnargs{
1066 fn: glfnIsShader,
1067 a0: s.c(),
1068 },
1069 blocking: true,
1070 })
1071 }
1072
1073 func (ctx *context) IsTexture(t Texture) bool {
1074 return 0 != ctx.enqueue(call{
1075 args: fnargs{
1076 fn: glfnIsTexture,
1077 a0: t.c(),
1078 },
1079 blocking: true,
1080 })
1081 }
1082
1083 func (ctx *context) LineWidth(width float32) {
1084 ctx.enqueue(call{
1085 args: fnargs{
1086 fn: glfnLineWidth,
1087 a0: uintptr(math.Float32bits(width)),
1088 },
1089 })
1090 }
1091
1092 func (ctx *context) LinkProgram(p Program) {
1093 ctx.enqueue(call{
1094 args: fnargs{
1095 fn: glfnLinkProgram,
1096 a0: p.c(),
1097 },
1098 })
1099 }
1100
1101 func (ctx *context) PixelStorei(pname Enum, param int32) {
1102 ctx.enqueue(call{
1103 args: fnargs{
1104 fn: glfnPixelStorei,
1105 a0: pname.c(),
1106 a1: uintptr(param),
1107 },
1108 })
1109 }
1110
1111 func (ctx *context) PolygonOffset(factor, units float32) {
1112 ctx.enqueue(call{
1113 args: fnargs{
1114 fn: glfnPolygonOffset,
1115 a0: uintptr(math.Float32bits(factor)),
1116 a1: uintptr(math.Float32bits(units)),
1117 },
1118 })
1119 }
1120
1121 func (ctx *context) ReadPixels(dst []byte, x, y, width, height int, format, ty Enum) {
1122 ctx.enqueue(call{
1123 args: fnargs{
1124 fn: glfnReadPixels,
1125 // TODO(crawshaw): support PIXEL_PACK_BUFFER in GLES3, uses offset.
1126 a0: uintptr(x),
1127 a1: uintptr(y),
1128 a2: uintptr(width),
1129 a3: uintptr(height),
1130 a4: format.c(),
1131 a5: ty.c(),
1132 },
1133 parg: unsafe.Pointer(&dst[0]),
1134 blocking: true,
1135 })
1136 }
1137
1138 func (ctx *context) ReleaseShaderCompiler() {
1139 ctx.enqueue(call{
1140 args: fnargs{
1141 fn: glfnReleaseShaderCompiler,
1142 },
1143 })
1144 }
1145
1146 func (ctx *context) RenderbufferStorage(target, internalFormat Enum, width, height int) {
1147 ctx.enqueue(call{
1148 args: fnargs{
1149 fn: glfnRenderbufferStorage,
1150 a0: target.c(),
1151 a1: internalFormat.c(),
1152 a2: uintptr(width),
1153 a3: uintptr(height),
1154 },
1155 })
1156 }
1157
1158 func (ctx *context) SampleCoverage(value float32, invert bool) {
1159 ctx.enqueue(call{
1160 args: fnargs{
1161 fn: glfnSampleCoverage,
1162 a0: uintptr(math.Float32bits(value)),
1163 a1: glBoolean(invert),
1164 },
1165 })
1166 }
1167
1168 func (ctx *context) Scissor(x, y, width, height int32) {
1169 ctx.enqueue(call{
1170 args: fnargs{
1171 fn: glfnScissor,
1172 a0: uintptr(x),
1173 a1: uintptr(y),
1174 a2: uintptr(width),
1175 a3: uintptr(height),
1176 },
1177 })
1178 }
1179
1180 func (ctx *context) ShaderSource(s Shader, src string) {
1181 strp, free := ctx.cStringPtr(src)
1182 defer free()
1183 ctx.enqueue(call{
1184 args: fnargs{
1185 fn: glfnShaderSource,
1186 a0: s.c(),
1187 a1: 1,
1188 a2: strp,
1189 },
1190 blocking: true,
1191 })
1192 }
1193
1194 func (ctx *context) StencilFunc(fn Enum, ref int, mask uint32) {
1195 ctx.enqueue(call{
1196 args: fnargs{
1197 fn: glfnStencilFunc,
1198 a0: fn.c(),
1199 a1: uintptr(ref),
1200 a2: uintptr(mask),
1201 },
1202 })
1203 }
1204
1205 func (ctx *context) StencilFuncSeparate(face, fn Enum, ref int, mask uint32) {
1206 ctx.enqueue(call{
1207 args: fnargs{
1208 fn: glfnStencilFuncSeparate,
1209 a0: face.c(),
1210 a1: fn.c(),
1211 a2: uintptr(ref),
1212 a3: uintptr(mask),
1213 },
1214 })
1215 }
1216
1217 func (ctx *context) StencilMask(mask uint32) {
1218 ctx.enqueue(call{
1219 args: fnargs{
1220 fn: glfnStencilMask,
1221 a0: uintptr(mask),
1222 },
1223 })
1224 }
1225
1226 func (ctx *context) StencilMaskSeparate(face Enum, mask uint32) {
1227 ctx.enqueue(call{
1228 args: fnargs{
1229 fn: glfnStencilMaskSeparate,
1230 a0: face.c(),
1231 a1: uintptr(mask),
1232 },
1233 })
1234 }
1235
1236 func (ctx *context) StencilOp(fail, zfail, zpass Enum) {
1237 ctx.enqueue(call{
1238 args: fnargs{
1239 fn: glfnStencilOp,
1240 a0: fail.c(),
1241 a1: zfail.c(),
1242 a2: zpass.c(),
1243 },
1244 })
1245 }
1246
1247 func (ctx *context) StencilOpSeparate(face, sfail, dpfail, dppass Enum) {
1248 ctx.enqueue(call{
1249 args: fnargs{
1250 fn: glfnStencilOpSeparate,
1251 a0: face.c(),
1252 a1: sfail.c(),
1253 a2: dpfail.c(),
1254 a3: dppass.c(),
1255 },
1256 })
1257 }
1258
1259 func (ctx *context) TexImage2D(target Enum, level int, internalFormat int, width, height int, format Enum, ty Enum, data []byte) {
1260 // It is common to pass TexImage2D a nil data, indicating that a
1261 // bound GL buffer is being used as the source. In that case, it
1262 // is not necessary to block.
1263 parg := unsafe.Pointer(nil)
1264 if len(data) > 0 {
1265 parg = unsafe.Pointer(&data[0])
1266 }
1267
1268 ctx.enqueue(call{
1269 args: fnargs{
1270 fn: glfnTexImage2D,
1271 // TODO(crawshaw): GLES3 offset for PIXEL_UNPACK_BUFFER and PIXEL_PACK_BUFFER.
1272 a0: target.c(),
1273 a1: uintptr(level),
1274 a2: uintptr(internalFormat),
1275 a3: uintptr(width),
1276 a4: uintptr(height),
1277 a5: format.c(),
1278 a6: ty.c(),
1279 },
1280 parg: parg,
1281 blocking: parg != nil,
1282 })
1283 }
1284
1285 func (ctx *context) TexSubImage2D(target Enum, level int, x, y, width, height int, format, ty Enum, data []byte) {
1286 // It is common to pass TexSubImage2D a nil data, indicating that a
1287 // bound GL buffer is being used as the source. In that case, it
1288 // is not necessary to block.
1289 parg := unsafe.Pointer(nil)
1290 if len(data) > 0 {
1291 parg = unsafe.Pointer(&data[0])
1292 }
1293
1294 ctx.enqueue(call{
1295 args: fnargs{
1296 fn: glfnTexSubImage2D,
1297 // TODO(crawshaw): GLES3 offset for PIXEL_UNPACK_BUFFER and PIXEL_PACK_BUFFER.
1298 a0: target.c(),
1299 a1: uintptr(level),
1300 a2: uintptr(x),
1301 a3: uintptr(y),
1302 a4: uintptr(width),
1303 a5: uintptr(height),
1304 a6: format.c(),
1305 a7: ty.c(),
1306 },
1307 parg: parg,
1308 blocking: parg != nil,
1309 })
1310 }
1311
1312 func (ctx *context) TexParameterf(target, pname Enum, param float32) {
1313 ctx.enqueue(call{
1314 args: fnargs{
1315 fn: glfnTexParameterf,
1316 a0: target.c(),
1317 a1: pname.c(),
1318 a2: uintptr(math.Float32bits(param)),
1319 },
1320 })
1321 }
1322
1323 func (ctx *context) TexParameterfv(target, pname Enum, params []float32) {
1324 ctx.enqueue(call{
1325 args: fnargs{
1326 fn: glfnTexParameterfv,
1327 a0: target.c(),
1328 a1: pname.c(),
1329 },
1330 parg: unsafe.Pointer(&params[0]),
1331 blocking: true,
1332 })
1333 }
1334
1335 func (ctx *context) TexParameteri(target, pname Enum, param int) {
1336 ctx.enqueue(call{
1337 args: fnargs{
1338 fn: glfnTexParameteri,
1339 a0: target.c(),
1340 a1: pname.c(),
1341 a2: uintptr(param),
1342 },
1343 })
1344 }
1345
1346 func (ctx *context) TexParameteriv(target, pname Enum, params []int32) {
1347 ctx.enqueue(call{
1348 args: fnargs{
1349 fn: glfnTexParameteriv,
1350 a0: target.c(),
1351 a1: pname.c(),
1352 },
1353 parg: unsafe.Pointer(&params[0]),
1354 blocking: true,
1355 })
1356 }
1357
1358 func (ctx *context) Uniform1f(dst Uniform, v float32) {
1359 ctx.enqueue(call{
1360 args: fnargs{
1361 fn: glfnUniform1f,
1362 a0: dst.c(),
1363 a1: uintptr(math.Float32bits(v)),
1364 },
1365 })
1366 }
1367
1368 func (ctx *context) Uniform1fv(dst Uniform, src []float32) {
1369 ctx.enqueue(call{
1370 args: fnargs{
1371 fn: glfnUniform1fv,
1372 a0: dst.c(),
1373 a1: uintptr(len(src)),
1374 },
1375 parg: unsafe.Pointer(&src[0]),
1376 blocking: true,
1377 })
1378 }
1379
1380 func (ctx *context) Uniform1i(dst Uniform, v int) {
1381 ctx.enqueue(call{
1382 args: fnargs{
1383 fn: glfnUniform1i,
1384 a0: dst.c(),
1385 a1: uintptr(v),
1386 },
1387 })
1388 }
1389
1390 func (ctx *context) Uniform1iv(dst Uniform, src []int32) {
1391 ctx.enqueue(call{
1392 args: fnargs{
1393 fn: glfnUniform1iv,
1394 a0: dst.c(),
1395 a1: uintptr(len(src)),
1396 },
1397 parg: unsafe.Pointer(&src[0]),
1398 blocking: true,
1399 })
1400 }
1401
1402 func (ctx *context) Uniform2f(dst Uniform, v0, v1 float32) {
1403 ctx.enqueue(call{
1404 args: fnargs{
1405 fn: glfnUniform2f,
1406 a0: dst.c(),
1407 a1: uintptr(math.Float32bits(v0)),
1408 a2: uintptr(math.Float32bits(v1)),
1409 },
1410 })
1411 }
1412
1413 func (ctx *context) Uniform2fv(dst Uniform, src []float32) {
1414 ctx.enqueue(call{
1415 args: fnargs{
1416 fn: glfnUniform2fv,
1417 a0: dst.c(),
1418 a1: uintptr(len(src) / 2),
1419 },
1420 parg: unsafe.Pointer(&src[0]),
1421 blocking: true,
1422 })
1423 }
1424
1425 func (ctx *context) Uniform2i(dst Uniform, v0, v1 int) {
1426 ctx.enqueue(call{
1427 args: fnargs{
1428 fn: glfnUniform2i,
1429 a0: dst.c(),
1430 a1: uintptr(v0),
1431 a2: uintptr(v1),
1432 },
1433 })
1434 }
1435
1436 func (ctx *context) Uniform2iv(dst Uniform, src []int32) {
1437 ctx.enqueue(call{
1438 args: fnargs{
1439 fn: glfnUniform2iv,
1440 a0: dst.c(),
1441 a1: uintptr(len(src) / 2),
1442 },
1443 parg: unsafe.Pointer(&src[0]),
1444 blocking: true,
1445 })
1446 }
1447
1448 func (ctx *context) Uniform3f(dst Uniform, v0, v1, v2 float32) {
1449 ctx.enqueue(call{
1450 args: fnargs{
1451 fn: glfnUniform3f,
1452 a0: dst.c(),
1453 a1: uintptr(math.Float32bits(v0)),
1454 a2: uintptr(math.Float32bits(v1)),
1455 a3: uintptr(math.Float32bits(v2)),
1456 },
1457 })
1458 }
1459
1460 func (ctx *context) Uniform3fv(dst Uniform, src []float32) {
1461 ctx.enqueue(call{
1462 args: fnargs{
1463 fn: glfnUniform3fv,
1464 a0: dst.c(),
1465 a1: uintptr(len(src) / 3),
1466 },
1467 parg: unsafe.Pointer(&src[0]),
1468 blocking: true,
1469 })
1470 }
1471
1472 func (ctx *context) Uniform3i(dst Uniform, v0, v1, v2 int32) {
1473 ctx.enqueue(call{
1474 args: fnargs{
1475 fn: glfnUniform3i,
1476 a0: dst.c(),
1477 a1: uintptr(v0),
1478 a2: uintptr(v1),
1479 a3: uintptr(v2),
1480 },
1481 })
1482 }
1483
1484 func (ctx *context) Uniform3iv(dst Uniform, src []int32) {
1485 ctx.enqueue(call{
1486 args: fnargs{
1487 fn: glfnUniform3iv,
1488 a0: dst.c(),
1489 a1: uintptr(len(src) / 3),
1490 },
1491 parg: unsafe.Pointer(&src[0]),
1492 blocking: true,
1493 })
1494 }
1495
1496 func (ctx *context) Uniform4f(dst Uniform, v0, v1, v2, v3 float32) {
1497 ctx.enqueue(call{
1498 args: fnargs{
1499 fn: glfnUniform4f,
1500 a0: dst.c(),
1501 a1: uintptr(math.Float32bits(v0)),
1502 a2: uintptr(math.Float32bits(v1)),
1503 a3: uintptr(math.Float32bits(v2)),
1504 a4: uintptr(math.Float32bits(v3)),
1505 },
1506 })
1507 }
1508
1509 func (ctx *context) Uniform4fv(dst Uniform, src []float32) {
1510 ctx.enqueue(call{
1511 args: fnargs{
1512 fn: glfnUniform4fv,
1513 a0: dst.c(),
1514 a1: uintptr(len(src) / 4),
1515 },
1516 parg: unsafe.Pointer(&src[0]),
1517 blocking: true,
1518 })
1519 }
1520
1521 func (ctx *context) Uniform4i(dst Uniform, v0, v1, v2, v3 int32) {
1522 ctx.enqueue(call{
1523 args: fnargs{
1524 fn: glfnUniform4i,
1525 a0: dst.c(),
1526 a1: uintptr(v0),
1527 a2: uintptr(v1),
1528 a3: uintptr(v2),
1529 a4: uintptr(v3),
1530 },
1531 })
1532 }
1533
1534 func (ctx *context) Uniform4iv(dst Uniform, src []int32) {
1535 ctx.enqueue(call{
1536 args: fnargs{
1537 fn: glfnUniform4iv,
1538 a0: dst.c(),
1539 a1: uintptr(len(src) / 4),
1540 },
1541 parg: unsafe.Pointer(&src[0]),
1542 blocking: true,
1543 })
1544 }
1545
1546 func (ctx *context) UniformMatrix2fv(dst Uniform, src []float32) {
1547 ctx.enqueue(call{
1548 args: fnargs{
1549 fn: glfnUniformMatrix2fv,
1550 // OpenGL ES 2 does not support transpose.
1551 a0: dst.c(),
1552 a1: uintptr(len(src) / 4),
1553 },
1554 parg: unsafe.Pointer(&src[0]),
1555 blocking: true,
1556 })
1557 }
1558
1559 func (ctx *context) UniformMatrix3fv(dst Uniform, src []float32) {
1560 ctx.enqueue(call{
1561 args: fnargs{
1562 fn: glfnUniformMatrix3fv,
1563 a0: dst.c(),
1564 a1: uintptr(len(src) / 9),
1565 },
1566 parg: unsafe.Pointer(&src[0]),
1567 blocking: true,
1568 })
1569 }
1570
1571 func (ctx *context) UniformMatrix4fv(dst Uniform, src []float32) {
1572 ctx.enqueue(call{
1573 args: fnargs{
1574 fn: glfnUniformMatrix4fv,
1575 a0: dst.c(),
1576 a1: uintptr(len(src) / 16),
1577 },
1578 parg: unsafe.Pointer(&src[0]),
1579 blocking: true,
1580 })
1581 }
1582
1583 func (ctx *context) UseProgram(p Program) {
1584 ctx.enqueue(call{
1585 args: fnargs{
1586 fn: glfnUseProgram,
1587 a0: p.c(),
1588 },
1589 })
1590 }
1591
1592 func (ctx *context) ValidateProgram(p Program) {
1593 ctx.enqueue(call{
1594 args: fnargs{
1595 fn: glfnValidateProgram,
1596 a0: p.c(),
1597 },
1598 })
1599 }
1600
1601 func (ctx *context) VertexAttrib1f(dst Attrib, x float32) {
1602 ctx.enqueue(call{
1603 args: fnargs{
1604 fn: glfnVertexAttrib1f,
1605 a0: dst.c(),
1606 a1: uintptr(math.Float32bits(x)),
1607 },
1608 })
1609 }
1610
1611 func (ctx *context) VertexAttrib1fv(dst Attrib, src []float32) {
1612 ctx.enqueue(call{
1613 args: fnargs{
1614 fn: glfnVertexAttrib1fv,
1615 a0: dst.c(),
1616 },
1617 parg: unsafe.Pointer(&src[0]),
1618 blocking: true,
1619 })
1620 }
1621
1622 func (ctx *context) VertexAttrib2f(dst Attrib, x, y float32) {
1623 ctx.enqueue(call{
1624 args: fnargs{
1625 fn: glfnVertexAttrib2f,
1626 a0: dst.c(),
1627 a1: uintptr(math.Float32bits(x)),
1628 a2: uintptr(math.Float32bits(y)),
1629 },
1630 })
1631 }
1632
1633 func (ctx *context) VertexAttrib2fv(dst Attrib, src []float32) {
1634 ctx.enqueue(call{
1635 args: fnargs{
1636 fn: glfnVertexAttrib2fv,
1637 a0: dst.c(),
1638 },
1639 parg: unsafe.Pointer(&src[0]),
1640 blocking: true,
1641 })
1642 }
1643
1644 func (ctx *context) VertexAttrib3f(dst Attrib, x, y, z float32) {
1645 ctx.enqueue(call{
1646 args: fnargs{
1647 fn: glfnVertexAttrib3f,
1648 a0: dst.c(),
1649 a1: uintptr(math.Float32bits(x)),
1650 a2: uintptr(math.Float32bits(y)),
1651 a3: uintptr(math.Float32bits(z)),
1652 },
1653 })
1654 }
1655
1656 func (ctx *context) VertexAttrib3fv(dst Attrib, src []float32) {
1657 ctx.enqueue(call{
1658 args: fnargs{
1659 fn: glfnVertexAttrib3fv,
1660 a0: dst.c(),
1661 },
1662 parg: unsafe.Pointer(&src[0]),
1663 blocking: true,
1664 })
1665 }
1666
1667 func (ctx *context) VertexAttrib4f(dst Attrib, x, y, z, w float32) {
1668 ctx.enqueue(call{
1669 args: fnargs{
1670 fn: glfnVertexAttrib4f,
1671 a0: dst.c(),
1672 a1: uintptr(math.Float32bits(x)),
1673 a2: uintptr(math.Float32bits(y)),
1674 a3: uintptr(math.Float32bits(z)),
1675 a4: uintptr(math.Float32bits(w)),
1676 },
1677 })
1678 }
1679
1680 func (ctx *context) VertexAttrib4fv(dst Attrib, src []float32) {
1681 ctx.enqueue(call{
1682 args: fnargs{
1683 fn: glfnVertexAttrib4fv,
1684 a0: dst.c(),
1685 },
1686 parg: unsafe.Pointer(&src[0]),
1687 blocking: true,
1688 })
1689 }
1690
1691 func (ctx *context) VertexAttribPointer(dst Attrib, size int, ty Enum, normalized bool, stride, offset int) {
1692 ctx.enqueue(call{
1693 args: fnargs{
1694 fn: glfnVertexAttribPointer,
1695 a0: dst.c(),
1696 a1: uintptr(size),
1697 a2: ty.c(),
1698 a3: glBoolean(normalized),
1699 a4: uintptr(stride),
1700 a5: uintptr(offset),
1701 },
1702 })
1703 }
1704
1705 func (ctx *context) Viewport(x, y, width, height int) {
1706 ctx.enqueue(call{
1707 args: fnargs{
1708 fn: glfnViewport,
1709 a0: uintptr(x),
1710 a1: uintptr(y),
1711 a2: uintptr(width),
1712 a3: uintptr(height),
1713 },
1714 })
1715 }
1716
1717 func (ctx context3) UniformMatrix2x3fv(dst Uniform, src []float32) {
1718 ctx.enqueue(call{
1719 args: fnargs{
1720 fn: glfnUniformMatrix2x3fv,
1721 a0: dst.c(),
1722 a1: uintptr(len(src) / 6),
1723 },
1724 parg: unsafe.Pointer(&src[0]),
1725 blocking: true,
1726 })
1727 }
1728
1729 func (ctx context3) UniformMatrix3x2fv(dst Uniform, src []float32) {
1730 ctx.enqueue(call{
1731 args: fnargs{
1732 fn: glfnUniformMatrix3x2fv,
1733 a0: dst.c(),
1734 a1: uintptr(len(src) / 6),
1735 },
1736 parg: unsafe.Pointer(&src[0]),
1737 blocking: true,
1738 })
1739 }
1740
1741 func (ctx context3) UniformMatrix2x4fv(dst Uniform, src []float32) {
1742 ctx.enqueue(call{
1743 args: fnargs{
1744 fn: glfnUniformMatrix2x4fv,
1745 a0: dst.c(),
1746 a1: uintptr(len(src) / 8),
1747 },
1748 parg: unsafe.Pointer(&src[0]),
1749 blocking: true,
1750 })
1751 }
1752
1753 func (ctx context3) UniformMatrix4x2fv(dst Uniform, src []float32) {
1754 ctx.enqueue(call{
1755 args: fnargs{
1756 fn: glfnUniformMatrix4x2fv,
1757 a0: dst.c(),
1758 a1: uintptr(len(src) / 8),
1759 },
1760 parg: unsafe.Pointer(&src[0]),
1761 blocking: true,
1762 })
1763 }
1764
1765 func (ctx context3) UniformMatrix3x4fv(dst Uniform, src []float32) {
1766 ctx.enqueue(call{
1767 args: fnargs{
1768 fn: glfnUniformMatrix3x4fv,
1769 a0: dst.c(),
1770 a1: uintptr(len(src) / 12),
1771 },
1772 parg: unsafe.Pointer(&src[0]),
1773 blocking: true,
1774 })
1775 }
1776
1777 func (ctx context3) UniformMatrix4x3fv(dst Uniform, src []float32) {
1778 ctx.enqueue(call{
1779 args: fnargs{
1780 fn: glfnUniformMatrix4x3fv,
1781 a0: dst.c(),
1782 a1: uintptr(len(src) / 12),
1783 },
1784 parg: unsafe.Pointer(&src[0]),
1785 blocking: true,
1786 })
1787 }
1788
1789 func (ctx context3) BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1 int, mask uint, filter Enum) {
1790 ctx.enqueue(call{
1791 args: fnargs{
1792 fn: glfnBlitFramebuffer,
1793 a0: uintptr(srcX0),
1794 a1: uintptr(srcY0),
1795 a2: uintptr(srcX1),
1796 a3: uintptr(srcY1),
1797 a4: uintptr(dstX0),
1798 a5: uintptr(dstY0),
1799 a6: uintptr(dstX1),
1800 a7: uintptr(dstY1),
1801 a8: uintptr(mask),
1802 a9: filter.c(),
1803 },
1804 })
1805 }
1806
1807 func (ctx context3) Uniform1ui(dst Uniform, v uint32) {
1808 ctx.enqueue(call{
1809 args: fnargs{
1810 fn: glfnUniform1ui,
1811 a0: dst.c(),
1812 a1: uintptr(v),
1813 },
1814 })
1815 }
1816
1817 func (ctx context3) Uniform2ui(dst Uniform, v0, v1 uint32) {
1818 ctx.enqueue(call{
1819 args: fnargs{
1820 fn: glfnUniform2ui,
1821 a0: dst.c(),
1822 a1: uintptr(v0),
1823 a2: uintptr(v1),
1824 },
1825 })
1826 }
1827
1828 func (ctx context3) Uniform3ui(dst Uniform, v0, v1, v2 uint) {
1829 ctx.enqueue(call{
1830 args: fnargs{
1831 fn: glfnUniform3ui,
1832 a0: dst.c(),
1833 a1: uintptr(v0),
1834 a2: uintptr(v1),
1835 a3: uintptr(v2),
1836 },
1837 })
1838 }
1839
1840 func (ctx context3) Uniform4ui(dst Uniform, v0, v1, v2, v3 uint32) {
1841 ctx.enqueue(call{
1842 args: fnargs{
1843 fn: glfnUniform4ui,
1844 a0: dst.c(),
1845 a1: uintptr(v0),
1846 a2: uintptr(v1),
1847 a3: uintptr(v2),
1848 a4: uintptr(v3),
1849 },
1850 })
1851 }