github.com/as/shiny@v0.8.2/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 darwin 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, 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(format), 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 ctx.enqueue(call{ 1287 args: fnargs{ 1288 fn: glfnTexSubImage2D, 1289 // TODO(crawshaw): GLES3 offset for PIXEL_UNPACK_BUFFER and PIXEL_PACK_BUFFER. 1290 a0: target.c(), 1291 a1: uintptr(level), 1292 a2: uintptr(x), 1293 a3: uintptr(y), 1294 a4: uintptr(width), 1295 a5: uintptr(height), 1296 a6: format.c(), 1297 a7: ty.c(), 1298 }, 1299 parg: unsafe.Pointer(&data[0]), 1300 blocking: true, 1301 }) 1302 } 1303 1304 func (ctx *context) TexParameterf(target, pname Enum, param float32) { 1305 ctx.enqueue(call{ 1306 args: fnargs{ 1307 fn: glfnTexParameterf, 1308 a0: target.c(), 1309 a1: pname.c(), 1310 a2: uintptr(math.Float32bits(param)), 1311 }, 1312 }) 1313 } 1314 1315 func (ctx *context) TexParameterfv(target, pname Enum, params []float32) { 1316 ctx.enqueue(call{ 1317 args: fnargs{ 1318 fn: glfnTexParameterfv, 1319 a0: target.c(), 1320 a1: pname.c(), 1321 }, 1322 parg: unsafe.Pointer(¶ms[0]), 1323 blocking: true, 1324 }) 1325 } 1326 1327 func (ctx *context) TexParameteri(target, pname Enum, param int) { 1328 ctx.enqueue(call{ 1329 args: fnargs{ 1330 fn: glfnTexParameteri, 1331 a0: target.c(), 1332 a1: pname.c(), 1333 a2: uintptr(param), 1334 }, 1335 }) 1336 } 1337 1338 func (ctx *context) TexParameteriv(target, pname Enum, params []int32) { 1339 ctx.enqueue(call{ 1340 args: fnargs{ 1341 fn: glfnTexParameteriv, 1342 a0: target.c(), 1343 a1: pname.c(), 1344 }, 1345 parg: unsafe.Pointer(¶ms[0]), 1346 blocking: true, 1347 }) 1348 } 1349 1350 func (ctx *context) Uniform1f(dst Uniform, v float32) { 1351 ctx.enqueue(call{ 1352 args: fnargs{ 1353 fn: glfnUniform1f, 1354 a0: dst.c(), 1355 a1: uintptr(math.Float32bits(v)), 1356 }, 1357 }) 1358 } 1359 1360 func (ctx *context) Uniform1fv(dst Uniform, src []float32) { 1361 ctx.enqueue(call{ 1362 args: fnargs{ 1363 fn: glfnUniform1fv, 1364 a0: dst.c(), 1365 a1: uintptr(len(src)), 1366 }, 1367 parg: unsafe.Pointer(&src[0]), 1368 blocking: true, 1369 }) 1370 } 1371 1372 func (ctx *context) Uniform1i(dst Uniform, v int) { 1373 ctx.enqueue(call{ 1374 args: fnargs{ 1375 fn: glfnUniform1i, 1376 a0: dst.c(), 1377 a1: uintptr(v), 1378 }, 1379 }) 1380 } 1381 1382 func (ctx *context) Uniform1iv(dst Uniform, src []int32) { 1383 ctx.enqueue(call{ 1384 args: fnargs{ 1385 fn: glfnUniform1iv, 1386 a0: dst.c(), 1387 a1: uintptr(len(src)), 1388 }, 1389 parg: unsafe.Pointer(&src[0]), 1390 blocking: true, 1391 }) 1392 } 1393 1394 func (ctx *context) Uniform2f(dst Uniform, v0, v1 float32) { 1395 ctx.enqueue(call{ 1396 args: fnargs{ 1397 fn: glfnUniform2f, 1398 a0: dst.c(), 1399 a1: uintptr(math.Float32bits(v0)), 1400 a2: uintptr(math.Float32bits(v1)), 1401 }, 1402 }) 1403 } 1404 1405 func (ctx *context) Uniform2fv(dst Uniform, src []float32) { 1406 ctx.enqueue(call{ 1407 args: fnargs{ 1408 fn: glfnUniform2fv, 1409 a0: dst.c(), 1410 a1: uintptr(len(src) / 2), 1411 }, 1412 parg: unsafe.Pointer(&src[0]), 1413 blocking: true, 1414 }) 1415 } 1416 1417 func (ctx *context) Uniform2i(dst Uniform, v0, v1 int) { 1418 ctx.enqueue(call{ 1419 args: fnargs{ 1420 fn: glfnUniform2i, 1421 a0: dst.c(), 1422 a1: uintptr(v0), 1423 a2: uintptr(v1), 1424 }, 1425 }) 1426 } 1427 1428 func (ctx *context) Uniform2iv(dst Uniform, src []int32) { 1429 ctx.enqueue(call{ 1430 args: fnargs{ 1431 fn: glfnUniform2iv, 1432 a0: dst.c(), 1433 a1: uintptr(len(src) / 2), 1434 }, 1435 parg: unsafe.Pointer(&src[0]), 1436 blocking: true, 1437 }) 1438 } 1439 1440 func (ctx *context) Uniform3f(dst Uniform, v0, v1, v2 float32) { 1441 ctx.enqueue(call{ 1442 args: fnargs{ 1443 fn: glfnUniform3f, 1444 a0: dst.c(), 1445 a1: uintptr(math.Float32bits(v0)), 1446 a2: uintptr(math.Float32bits(v1)), 1447 a3: uintptr(math.Float32bits(v2)), 1448 }, 1449 }) 1450 } 1451 1452 func (ctx *context) Uniform3fv(dst Uniform, src []float32) { 1453 ctx.enqueue(call{ 1454 args: fnargs{ 1455 fn: glfnUniform3fv, 1456 a0: dst.c(), 1457 a1: uintptr(len(src) / 3), 1458 }, 1459 parg: unsafe.Pointer(&src[0]), 1460 blocking: true, 1461 }) 1462 } 1463 1464 func (ctx *context) Uniform3i(dst Uniform, v0, v1, v2 int32) { 1465 ctx.enqueue(call{ 1466 args: fnargs{ 1467 fn: glfnUniform3i, 1468 a0: dst.c(), 1469 a1: uintptr(v0), 1470 a2: uintptr(v1), 1471 a3: uintptr(v2), 1472 }, 1473 }) 1474 } 1475 1476 func (ctx *context) Uniform3iv(dst Uniform, src []int32) { 1477 ctx.enqueue(call{ 1478 args: fnargs{ 1479 fn: glfnUniform3iv, 1480 a0: dst.c(), 1481 a1: uintptr(len(src) / 3), 1482 }, 1483 parg: unsafe.Pointer(&src[0]), 1484 blocking: true, 1485 }) 1486 } 1487 1488 func (ctx *context) Uniform4f(dst Uniform, v0, v1, v2, v3 float32) { 1489 ctx.enqueue(call{ 1490 args: fnargs{ 1491 fn: glfnUniform4f, 1492 a0: dst.c(), 1493 a1: uintptr(math.Float32bits(v0)), 1494 a2: uintptr(math.Float32bits(v1)), 1495 a3: uintptr(math.Float32bits(v2)), 1496 a4: uintptr(math.Float32bits(v3)), 1497 }, 1498 }) 1499 } 1500 1501 func (ctx *context) Uniform4fv(dst Uniform, src []float32) { 1502 ctx.enqueue(call{ 1503 args: fnargs{ 1504 fn: glfnUniform4fv, 1505 a0: dst.c(), 1506 a1: uintptr(len(src) / 4), 1507 }, 1508 parg: unsafe.Pointer(&src[0]), 1509 blocking: true, 1510 }) 1511 } 1512 1513 func (ctx *context) Uniform4i(dst Uniform, v0, v1, v2, v3 int32) { 1514 ctx.enqueue(call{ 1515 args: fnargs{ 1516 fn: glfnUniform4i, 1517 a0: dst.c(), 1518 a1: uintptr(v0), 1519 a2: uintptr(v1), 1520 a3: uintptr(v2), 1521 a4: uintptr(v3), 1522 }, 1523 }) 1524 } 1525 1526 func (ctx *context) Uniform4iv(dst Uniform, src []int32) { 1527 ctx.enqueue(call{ 1528 args: fnargs{ 1529 fn: glfnUniform4iv, 1530 a0: dst.c(), 1531 a1: uintptr(len(src) / 4), 1532 }, 1533 parg: unsafe.Pointer(&src[0]), 1534 blocking: true, 1535 }) 1536 } 1537 1538 func (ctx *context) UniformMatrix2fv(dst Uniform, src []float32) { 1539 ctx.enqueue(call{ 1540 args: fnargs{ 1541 fn: glfnUniformMatrix2fv, 1542 // OpenGL ES 2 does not support transpose. 1543 a0: dst.c(), 1544 a1: uintptr(len(src) / 4), 1545 }, 1546 parg: unsafe.Pointer(&src[0]), 1547 blocking: true, 1548 }) 1549 } 1550 1551 func (ctx *context) UniformMatrix3fv(dst Uniform, src []float32) { 1552 ctx.enqueue(call{ 1553 args: fnargs{ 1554 fn: glfnUniformMatrix3fv, 1555 a0: dst.c(), 1556 a1: uintptr(len(src) / 9), 1557 }, 1558 parg: unsafe.Pointer(&src[0]), 1559 blocking: true, 1560 }) 1561 } 1562 1563 func (ctx *context) UniformMatrix4fv(dst Uniform, src []float32) { 1564 ctx.enqueue(call{ 1565 args: fnargs{ 1566 fn: glfnUniformMatrix4fv, 1567 a0: dst.c(), 1568 a1: uintptr(len(src) / 16), 1569 }, 1570 parg: unsafe.Pointer(&src[0]), 1571 blocking: true, 1572 }) 1573 } 1574 1575 func (ctx *context) UseProgram(p Program) { 1576 ctx.enqueue(call{ 1577 args: fnargs{ 1578 fn: glfnUseProgram, 1579 a0: p.c(), 1580 }, 1581 }) 1582 } 1583 1584 func (ctx *context) ValidateProgram(p Program) { 1585 ctx.enqueue(call{ 1586 args: fnargs{ 1587 fn: glfnValidateProgram, 1588 a0: p.c(), 1589 }, 1590 }) 1591 } 1592 1593 func (ctx *context) VertexAttrib1f(dst Attrib, x float32) { 1594 ctx.enqueue(call{ 1595 args: fnargs{ 1596 fn: glfnVertexAttrib1f, 1597 a0: dst.c(), 1598 a1: uintptr(math.Float32bits(x)), 1599 }, 1600 }) 1601 } 1602 1603 func (ctx *context) VertexAttrib1fv(dst Attrib, src []float32) { 1604 ctx.enqueue(call{ 1605 args: fnargs{ 1606 fn: glfnVertexAttrib1fv, 1607 a0: dst.c(), 1608 }, 1609 parg: unsafe.Pointer(&src[0]), 1610 blocking: true, 1611 }) 1612 } 1613 1614 func (ctx *context) VertexAttrib2f(dst Attrib, x, y float32) { 1615 ctx.enqueue(call{ 1616 args: fnargs{ 1617 fn: glfnVertexAttrib2f, 1618 a0: dst.c(), 1619 a1: uintptr(math.Float32bits(x)), 1620 a2: uintptr(math.Float32bits(y)), 1621 }, 1622 }) 1623 } 1624 1625 func (ctx *context) VertexAttrib2fv(dst Attrib, src []float32) { 1626 ctx.enqueue(call{ 1627 args: fnargs{ 1628 fn: glfnVertexAttrib2fv, 1629 a0: dst.c(), 1630 }, 1631 parg: unsafe.Pointer(&src[0]), 1632 blocking: true, 1633 }) 1634 } 1635 1636 func (ctx *context) VertexAttrib3f(dst Attrib, x, y, z float32) { 1637 ctx.enqueue(call{ 1638 args: fnargs{ 1639 fn: glfnVertexAttrib3f, 1640 a0: dst.c(), 1641 a1: uintptr(math.Float32bits(x)), 1642 a2: uintptr(math.Float32bits(y)), 1643 a3: uintptr(math.Float32bits(z)), 1644 }, 1645 }) 1646 } 1647 1648 func (ctx *context) VertexAttrib3fv(dst Attrib, src []float32) { 1649 ctx.enqueue(call{ 1650 args: fnargs{ 1651 fn: glfnVertexAttrib3fv, 1652 a0: dst.c(), 1653 }, 1654 parg: unsafe.Pointer(&src[0]), 1655 blocking: true, 1656 }) 1657 } 1658 1659 func (ctx *context) VertexAttrib4f(dst Attrib, x, y, z, w float32) { 1660 ctx.enqueue(call{ 1661 args: fnargs{ 1662 fn: glfnVertexAttrib4f, 1663 a0: dst.c(), 1664 a1: uintptr(math.Float32bits(x)), 1665 a2: uintptr(math.Float32bits(y)), 1666 a3: uintptr(math.Float32bits(z)), 1667 a4: uintptr(math.Float32bits(w)), 1668 }, 1669 }) 1670 } 1671 1672 func (ctx *context) VertexAttrib4fv(dst Attrib, src []float32) { 1673 ctx.enqueue(call{ 1674 args: fnargs{ 1675 fn: glfnVertexAttrib4fv, 1676 a0: dst.c(), 1677 }, 1678 parg: unsafe.Pointer(&src[0]), 1679 blocking: true, 1680 }) 1681 } 1682 1683 func (ctx *context) VertexAttribPointer(dst Attrib, size int, ty Enum, normalized bool, stride, offset int) { 1684 ctx.enqueue(call{ 1685 args: fnargs{ 1686 fn: glfnVertexAttribPointer, 1687 a0: dst.c(), 1688 a1: uintptr(size), 1689 a2: ty.c(), 1690 a3: glBoolean(normalized), 1691 a4: uintptr(stride), 1692 a5: uintptr(offset), 1693 }, 1694 }) 1695 } 1696 1697 func (ctx *context) Viewport(x, y, width, height int) { 1698 ctx.enqueue(call{ 1699 args: fnargs{ 1700 fn: glfnViewport, 1701 a0: uintptr(x), 1702 a1: uintptr(y), 1703 a2: uintptr(width), 1704 a3: uintptr(height), 1705 }, 1706 }) 1707 } 1708 1709 func (ctx context3) UniformMatrix2x3fv(dst Uniform, src []float32) { 1710 ctx.enqueue(call{ 1711 args: fnargs{ 1712 fn: glfnUniformMatrix2x3fv, 1713 a0: dst.c(), 1714 a1: uintptr(len(src) / 6), 1715 }, 1716 parg: unsafe.Pointer(&src[0]), 1717 blocking: true, 1718 }) 1719 } 1720 1721 func (ctx context3) UniformMatrix3x2fv(dst Uniform, src []float32) { 1722 ctx.enqueue(call{ 1723 args: fnargs{ 1724 fn: glfnUniformMatrix3x2fv, 1725 a0: dst.c(), 1726 a1: uintptr(len(src) / 6), 1727 }, 1728 parg: unsafe.Pointer(&src[0]), 1729 blocking: true, 1730 }) 1731 } 1732 1733 func (ctx context3) UniformMatrix2x4fv(dst Uniform, src []float32) { 1734 ctx.enqueue(call{ 1735 args: fnargs{ 1736 fn: glfnUniformMatrix2x4fv, 1737 a0: dst.c(), 1738 a1: uintptr(len(src) / 8), 1739 }, 1740 parg: unsafe.Pointer(&src[0]), 1741 blocking: true, 1742 }) 1743 } 1744 1745 func (ctx context3) UniformMatrix4x2fv(dst Uniform, src []float32) { 1746 ctx.enqueue(call{ 1747 args: fnargs{ 1748 fn: glfnUniformMatrix4x2fv, 1749 a0: dst.c(), 1750 a1: uintptr(len(src) / 8), 1751 }, 1752 parg: unsafe.Pointer(&src[0]), 1753 blocking: true, 1754 }) 1755 } 1756 1757 func (ctx context3) UniformMatrix3x4fv(dst Uniform, src []float32) { 1758 ctx.enqueue(call{ 1759 args: fnargs{ 1760 fn: glfnUniformMatrix3x4fv, 1761 a0: dst.c(), 1762 a1: uintptr(len(src) / 12), 1763 }, 1764 parg: unsafe.Pointer(&src[0]), 1765 blocking: true, 1766 }) 1767 } 1768 1769 func (ctx context3) UniformMatrix4x3fv(dst Uniform, src []float32) { 1770 ctx.enqueue(call{ 1771 args: fnargs{ 1772 fn: glfnUniformMatrix4x3fv, 1773 a0: dst.c(), 1774 a1: uintptr(len(src) / 12), 1775 }, 1776 parg: unsafe.Pointer(&src[0]), 1777 blocking: true, 1778 }) 1779 } 1780 1781 func (ctx context3) BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1 int, mask uint, filter Enum) { 1782 ctx.enqueue(call{ 1783 args: fnargs{ 1784 fn: glfnBlitFramebuffer, 1785 a0: uintptr(srcX0), 1786 a1: uintptr(srcY0), 1787 a2: uintptr(srcX1), 1788 a3: uintptr(srcY1), 1789 a4: uintptr(dstX0), 1790 a5: uintptr(dstY0), 1791 a6: uintptr(dstX1), 1792 a7: uintptr(dstY1), 1793 a8: uintptr(mask), 1794 a9: filter.c(), 1795 }, 1796 }) 1797 } 1798 1799 func (ctx context3) Uniform1ui(dst Uniform, v uint32) { 1800 ctx.enqueue(call{ 1801 args: fnargs{ 1802 fn: glfnUniform1ui, 1803 a0: dst.c(), 1804 a1: uintptr(v), 1805 }, 1806 }) 1807 } 1808 1809 func (ctx context3) Uniform2ui(dst Uniform, v0, v1 uint32) { 1810 ctx.enqueue(call{ 1811 args: fnargs{ 1812 fn: glfnUniform2ui, 1813 a0: dst.c(), 1814 a1: uintptr(v0), 1815 a2: uintptr(v1), 1816 }, 1817 }) 1818 } 1819 1820 func (ctx context3) Uniform3ui(dst Uniform, v0, v1, v2 uint) { 1821 ctx.enqueue(call{ 1822 args: fnargs{ 1823 fn: glfnUniform3ui, 1824 a0: dst.c(), 1825 a1: uintptr(v0), 1826 a2: uintptr(v1), 1827 a3: uintptr(v2), 1828 }, 1829 }) 1830 } 1831 1832 func (ctx context3) Uniform4ui(dst Uniform, v0, v1, v2, v3 uint32) { 1833 ctx.enqueue(call{ 1834 args: fnargs{ 1835 fn: glfnUniform4ui, 1836 a0: dst.c(), 1837 a1: uintptr(v0), 1838 a2: uintptr(v1), 1839 a3: uintptr(v2), 1840 a4: uintptr(v3), 1841 }, 1842 }) 1843 }