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