gl_webgl.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  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. // +build js,!wasm
  5. package gl
  6. import (
  7. "encoding/binary"
  8. "math"
  9. "github.com/gopherjs/gopherjs/js"
  10. )
  11. var ContextWatcher contextWatcher
  12. type contextWatcher struct{}
  13. func (contextWatcher) OnMakeCurrent(context interface{}) {
  14. // context must be a WebGLRenderingContext *js.Object.
  15. c = context.(*js.Object)
  16. }
  17. func (contextWatcher) OnDetach() {
  18. c = nil
  19. }
  20. // c is the current WebGL context, or nil if there is no current context.
  21. var c *js.Object
  22. func ActiveTexture(texture Enum) {
  23. c.Call("activeTexture", texture)
  24. }
  25. func AttachShader(p Program, s Shader) {
  26. c.Call("attachShader", p.Object, s.Object)
  27. }
  28. func BindAttribLocation(p Program, a Attrib, name string) {
  29. c.Call("bindAttribLocation", p.Object, a.Value, name)
  30. }
  31. func BindBuffer(target Enum, b Buffer) {
  32. c.Call("bindBuffer", target, b.Object)
  33. }
  34. func BindFramebuffer(target Enum, fb Framebuffer) {
  35. c.Call("bindFramebuffer", target, fb.Object)
  36. }
  37. func BindRenderbuffer(target Enum, rb Renderbuffer) {
  38. c.Call("bindRenderbuffer", target, rb.Object)
  39. }
  40. func BindTexture(target Enum, t Texture) {
  41. c.Call("bindTexture", target, t.Object)
  42. }
  43. func BlendColor(red, green, blue, alpha float32) {
  44. c.Call("blendColor", red, green, blue, alpha)
  45. }
  46. func BlendEquation(mode Enum) {
  47. c.Call("blendEquation", mode)
  48. }
  49. func BlendEquationSeparate(modeRGB, modeAlpha Enum) {
  50. c.Call("blendEquationSeparate", modeRGB, modeAlpha)
  51. }
  52. func BlendFunc(sfactor, dfactor Enum) {
  53. c.Call("blendFunc", sfactor, dfactor)
  54. }
  55. func BlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha Enum) {
  56. c.Call("blendFuncSeparate", sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha)
  57. }
  58. func BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1 int, mask, filter Enum) {
  59. println("BlitFramebuffer: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
  60. c.Call("blitFramebuffer", srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter)
  61. }
  62. func BufferData(target Enum, data interface{}, usage Enum) {
  63. c.Call("bufferData", target, data, usage)
  64. }
  65. func BufferInit(target Enum, size int, usage Enum) {
  66. c.Call("bufferData", target, size, usage)
  67. }
  68. func BufferSubData(target Enum, offset int, data []byte) {
  69. c.Call("bufferSubData", target, offset, data)
  70. }
  71. func CheckFramebufferStatus(target Enum) Enum {
  72. return Enum(c.Call("checkFramebufferStatus", target).Int())
  73. }
  74. func Clear(mask Enum) {
  75. c.Call("clear", mask)
  76. }
  77. func ClearColor(red, green, blue, alpha float32) {
  78. c.Call("clearColor", red, green, blue, alpha)
  79. }
  80. func ClearDepthf(d float32) {
  81. c.Call("clearDepth", d)
  82. }
  83. func ClearStencil(s int) {
  84. c.Call("clearStencil", s)
  85. }
  86. func ColorMask(red, green, blue, alpha bool) {
  87. c.Call("colorMask", red, green, blue, alpha)
  88. }
  89. func CompileShader(s Shader) {
  90. c.Call("compileShader", s.Object)
  91. }
  92. func CompressedTexImage2D(target Enum, level int, internalformat Enum, width, height, border int, data []byte) {
  93. c.Call("compressedTexImage2D", target, level, internalformat, width, height, border, data)
  94. }
  95. func CompressedTexSubImage2D(target Enum, level, xoffset, yoffset, width, height int, format Enum, data []byte) {
  96. c.Call("compressedTexSubImage2D", target, level, xoffset, yoffset, width, height, format, data)
  97. }
  98. func CopyTexImage2D(target Enum, level int, internalformat Enum, x, y, width, height, border int) {
  99. c.Call("copyTexImage2D", target, level, internalformat, x, y, width, height, border)
  100. }
  101. func CopyTexSubImage2D(target Enum, level, xoffset, yoffset, x, y, width, height int) {
  102. c.Call("copyTexSubImage2D", target, level, xoffset, yoffset, x, y, width, height)
  103. }
  104. func CreateBuffer() Buffer {
  105. return Buffer{Object: c.Call("createBuffer")}
  106. }
  107. func CreateFramebuffer() Framebuffer {
  108. return Framebuffer{Object: c.Call("createFramebuffer")}
  109. }
  110. func CreateProgram() Program {
  111. return Program{Object: c.Call("createProgram")}
  112. }
  113. func CreateRenderbuffer() Renderbuffer {
  114. return Renderbuffer{Object: c.Call("createRenderbuffer")}
  115. }
  116. func CreateShader(ty Enum) Shader {
  117. return Shader{Object: c.Call("createShader", ty)}
  118. }
  119. func CreateTexture() Texture {
  120. return Texture{Object: c.Call("createTexture")}
  121. }
  122. func CullFace(mode Enum) {
  123. c.Call("cullFace", mode)
  124. }
  125. func DeleteBuffer(v Buffer) {
  126. c.Call("deleteBuffer", v.Object)
  127. }
  128. func DeleteFramebuffer(v Framebuffer) {
  129. c.Call("deleteFramebuffer", v.Object)
  130. }
  131. func DeleteProgram(p Program) {
  132. c.Call("deleteProgram", p.Object)
  133. }
  134. func DeleteRenderbuffer(v Renderbuffer) {
  135. c.Call("deleteRenderbuffer", v.Object)
  136. }
  137. func DeleteShader(s Shader) {
  138. c.Call("deleteShader", s.Object)
  139. }
  140. func DeleteTexture(v Texture) {
  141. c.Call("deleteTexture", v.Object)
  142. }
  143. func DepthFunc(fn Enum) {
  144. c.Call("depthFunc", fn)
  145. }
  146. func DepthMask(flag bool) {
  147. c.Call("depthMask", flag)
  148. }
  149. func DepthRangef(n, f float32) {
  150. c.Call("depthRange", n, f)
  151. }
  152. func DetachShader(p Program, s Shader) {
  153. c.Call("detachShader", p.Object, s.Object)
  154. }
  155. func Disable(cap Enum) {
  156. c.Call("disable", cap)
  157. }
  158. func DisableVertexAttribArray(a Attrib) {
  159. c.Call("disableVertexAttribArray", a.Value)
  160. }
  161. func DrawArrays(mode Enum, first, count int) {
  162. c.Call("drawArrays", mode, first, count)
  163. }
  164. func DrawElements(mode Enum, count int, ty Enum, offset int) {
  165. c.Call("drawElements", mode, count, ty, offset)
  166. }
  167. func Enable(cap Enum) {
  168. c.Call("enable", cap)
  169. }
  170. func EnableVertexAttribArray(a Attrib) {
  171. c.Call("enableVertexAttribArray", a.Value)
  172. }
  173. func Finish() {
  174. c.Call("finish")
  175. }
  176. func Flush() {
  177. c.Call("flush")
  178. }
  179. func FramebufferRenderbuffer(target, attachment, rbTarget Enum, rb Renderbuffer) {
  180. c.Call("framebufferRenderbuffer", target, attachment, rbTarget, rb.Object)
  181. }
  182. func FramebufferTexture2D(target, attachment, texTarget Enum, t Texture, level int) {
  183. c.Call("framebufferTexture2D", target, attachment, texTarget, t.Object, level)
  184. }
  185. func FrontFace(mode Enum) {
  186. c.Call("frontFace", mode)
  187. }
  188. func GenerateMipmap(target Enum) {
  189. c.Call("generateMipmap", target)
  190. }
  191. type activeInfo struct {
  192. *js.Object
  193. Size int `js:"size"`
  194. Type int `js:"type"`
  195. Name string `js:"name"`
  196. }
  197. func GetActiveAttrib(p Program, index uint32) (name string, size int, ty Enum) {
  198. ai := activeInfo{Object: c.Call("getActiveAttrib", p.Object, index)}
  199. return ai.Name, ai.Size, Enum(ai.Type)
  200. }
  201. func GetActiveUniform(p Program, index uint32) (name string, size int, ty Enum) {
  202. ai := activeInfo{Object: c.Call("getActiveUniform", p.Object, index)}
  203. return ai.Name, ai.Size, Enum(ai.Type)
  204. }
  205. func GetAttachedShaders(p Program) []Shader {
  206. objs := c.Call("getAttachedShaders", p.Object)
  207. shaders := make([]Shader, objs.Length())
  208. for i := 0; i < objs.Length(); i++ {
  209. shaders[i] = Shader{Object: objs.Index(i)}
  210. }
  211. return shaders
  212. }
  213. func GetAttribLocation(p Program, name string) Attrib {
  214. return Attrib{Value: c.Call("getAttribLocation", p.Object, name).Int()}
  215. }
  216. func GetBooleanv(dst []bool, pname Enum) {
  217. println("GetBooleanv: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
  218. result := c.Call("getParameter", pname)
  219. length := result.Length()
  220. for i := 0; i < length; i++ {
  221. dst[i] = result.Index(i).Bool()
  222. }
  223. }
  224. func GetFloatv(dst []float32, pname Enum) {
  225. println("GetFloatv: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
  226. result := c.Call("getParameter", pname)
  227. length := result.Length()
  228. for i := 0; i < length; i++ {
  229. dst[i] = float32(result.Index(i).Float())
  230. }
  231. }
  232. func GetIntegerv(pname Enum, data []int32) {
  233. result := c.Call("getParameter", pname)
  234. length := result.Length()
  235. for i := 0; i < length; i++ {
  236. data[i] = int32(result.Index(i).Int())
  237. }
  238. }
  239. func GetInteger(pname Enum) int {
  240. return c.Call("getParameter", pname).Int()
  241. }
  242. func GetBufferParameteri(target, pname Enum) int {
  243. return c.Call("getBufferParameter", target, pname).Int()
  244. }
  245. func GetError() Enum {
  246. return Enum(c.Call("getError").Int())
  247. }
  248. func GetBoundFramebuffer() Framebuffer {
  249. return Framebuffer{Object: c.Call("getParameter", FRAMEBUFFER_BINDING)}
  250. }
  251. func GetFramebufferAttachmentParameteri(target, attachment, pname Enum) int {
  252. return c.Call("getFramebufferAttachmentParameter", target, attachment, pname).Int()
  253. }
  254. func GetProgrami(p Program, pname Enum) int {
  255. switch pname {
  256. case DELETE_STATUS, LINK_STATUS, VALIDATE_STATUS:
  257. if c.Call("getProgramParameter", p.Object, pname).Bool() {
  258. return TRUE
  259. }
  260. return FALSE
  261. default:
  262. return c.Call("getProgramParameter", p.Object, pname).Int()
  263. }
  264. }
  265. func GetProgramInfoLog(p Program) string {
  266. return c.Call("getProgramInfoLog", p.Object).String()
  267. }
  268. func GetRenderbufferParameteri(target, pname Enum) int {
  269. return c.Call("getRenderbufferParameter", target, pname).Int()
  270. }
  271. func GetShaderi(s Shader, pname Enum) int {
  272. switch pname {
  273. case DELETE_STATUS, COMPILE_STATUS:
  274. if c.Call("getShaderParameter", s.Object, pname).Bool() {
  275. return TRUE
  276. }
  277. return FALSE
  278. default:
  279. return c.Call("getShaderParameter", s.Object, pname).Int()
  280. }
  281. }
  282. func GetShaderInfoLog(s Shader) string {
  283. return c.Call("getShaderInfoLog", s.Object).String()
  284. }
  285. func GetShaderPrecisionFormat(shadertype, precisiontype Enum) (rangeMin, rangeMax, precision int) {
  286. println("GetShaderPrecisionFormat: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
  287. format := c.Call("getShaderPrecisionFormat", shadertype, precisiontype)
  288. rangeMin = format.Get("rangeMin").Int()
  289. rangeMax = format.Get("rangeMax").Int()
  290. precision = format.Get("precision").Int()
  291. return
  292. }
  293. func GetShaderSource(s Shader) string {
  294. return c.Call("getShaderSource", s.Object).String()
  295. }
  296. func GetString(pname Enum) string {
  297. return c.Call("getParameter", pname).String()
  298. }
  299. func GetTexParameterfv(dst []float32, target, pname Enum) {
  300. dst[0] = float32(c.Call("getTexParameter", pname).Float())
  301. }
  302. func GetTexParameteriv(dst []int32, target, pname Enum) {
  303. dst[0] = int32(c.Call("getTexParameter", pname).Int())
  304. }
  305. func GetUniformfv(dst []float32, src Uniform, p Program) {
  306. println("GetUniformfv: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
  307. result := c.Call("getUniform")
  308. length := result.Length()
  309. for i := 0; i < length; i++ {
  310. dst[i] = float32(result.Index(i).Float())
  311. }
  312. }
  313. func GetUniformiv(dst []int32, src Uniform, p Program) {
  314. println("GetUniformiv: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
  315. result := c.Call("getUniform")
  316. length := result.Length()
  317. for i := 0; i < length; i++ {
  318. dst[i] = int32(result.Index(i).Int())
  319. }
  320. }
  321. func GetUniformLocation(p Program, name string) Uniform {
  322. return Uniform{Object: c.Call("getUniformLocation", p.Object, name)}
  323. }
  324. func GetVertexAttribf(src Attrib, pname Enum) float32 {
  325. return float32(c.Call("getVertexAttrib", src.Value, pname).Float())
  326. }
  327. func GetVertexAttribfv(dst []float32, src Attrib, pname Enum) {
  328. println("GetVertexAttribfv: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
  329. result := c.Call("getVertexAttrib")
  330. length := result.Length()
  331. for i := 0; i < length; i++ {
  332. dst[i] = float32(result.Index(i).Float())
  333. }
  334. }
  335. func GetVertexAttribi(src Attrib, pname Enum) int32 {
  336. return int32(c.Call("getVertexAttrib", src.Value, pname).Int())
  337. }
  338. func GetVertexAttribiv(dst []int32, src Attrib, pname Enum) {
  339. println("GetVertexAttribiv: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
  340. result := c.Call("getVertexAttrib")
  341. length := result.Length()
  342. for i := 0; i < length; i++ {
  343. dst[i] = int32(result.Index(i).Int())
  344. }
  345. }
  346. func Hint(target, mode Enum) {
  347. c.Call("hint", target, mode)
  348. }
  349. func IsBuffer(b Buffer) bool {
  350. return c.Call("isBuffer", b.Object).Bool()
  351. }
  352. func IsEnabled(cap Enum) bool {
  353. return c.Call("isEnabled", cap).Bool()
  354. }
  355. func IsFramebuffer(fb Framebuffer) bool {
  356. return c.Call("isFramebuffer", fb.Object).Bool()
  357. }
  358. func IsProgram(p Program) bool {
  359. return c.Call("isProgram", p.Object).Bool()
  360. }
  361. func IsRenderbuffer(rb Renderbuffer) bool {
  362. return c.Call("isRenderbuffer", rb.Object).Bool()
  363. }
  364. func IsShader(s Shader) bool {
  365. return c.Call("isShader", s.Object).Bool()
  366. }
  367. func IsTexture(t Texture) bool {
  368. return c.Call("isTexture", t.Object).Bool()
  369. }
  370. func LineWidth(width float32) {
  371. c.Call("lineWidth", width)
  372. }
  373. func LinkProgram(p Program) {
  374. c.Call("linkProgram", p.Object)
  375. }
  376. func ObjectLabel(o Object, label string) {
  377. // not available in WebGL
  378. }
  379. func PixelStorei(pname Enum, param int32) {
  380. c.Call("pixelStorei", pname, param)
  381. }
  382. func PolygonOffset(factor, units float32) {
  383. c.Call("polygonOffset", factor, units)
  384. }
  385. func ReadPixels(dst []byte, x, y, width, height int, format, ty Enum) {
  386. println("ReadPixels: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
  387. if ty == Enum(UNSIGNED_BYTE) {
  388. c.Call("readPixels", x, y, width, height, format, ty, dst)
  389. } else {
  390. tmpDst := make([]float32, len(dst)/4)
  391. c.Call("readPixels", x, y, width, height, format, ty, tmpDst)
  392. for i, f := range tmpDst {
  393. binary.LittleEndian.PutUint32(dst[i*4:], math.Float32bits(f))
  394. }
  395. }
  396. }
  397. func ReleaseShaderCompiler() {
  398. // do nothing
  399. }
  400. func RenderbufferStorage(target, internalFormat Enum, width, height int) {
  401. c.Call("renderbufferStorage", target, internalFormat, width, height)
  402. }
  403. func SampleCoverage(value float32, invert bool) {
  404. c.Call("sampleCoverage", value, invert)
  405. }
  406. func Scissor(x, y, width, height int32) {
  407. c.Call("scissor", x, y, width, height)
  408. }
  409. func ShaderSource(s Shader, src string) {
  410. c.Call("shaderSource", s.Object, src)
  411. }
  412. func StencilFunc(fn Enum, ref int, mask uint32) {
  413. c.Call("stencilFunc", fn, ref, mask)
  414. }
  415. func StencilFuncSeparate(face, fn Enum, ref int, mask uint32) {
  416. c.Call("stencilFuncSeparate", face, fn, ref, mask)
  417. }
  418. func StencilMask(mask uint32) {
  419. c.Call("stencilMask", mask)
  420. }
  421. func StencilMaskSeparate(face Enum, mask uint32) {
  422. c.Call("stencilMaskSeparate", face, mask)
  423. }
  424. func StencilOp(fail, zfail, zpass Enum) {
  425. c.Call("stencilOp", fail, zfail, zpass)
  426. }
  427. func StencilOpSeparate(face, sfail, dpfail, dppass Enum) {
  428. c.Call("stencilOpSeparate", face, sfail, dpfail, dppass)
  429. }
  430. func TexImage2D(target Enum, level int, width, height int, format Enum, ty Enum, data []byte) {
  431. var p interface{}
  432. if data != nil {
  433. p = data
  434. }
  435. c.Call("texImage2D", target, level, format, width, height, 0, format, ty, p)
  436. }
  437. func TexImage2DMultisample(target Enum, samples int, internalformat Enum, width, height int, fixedsamplelocations bool) {
  438. println("TexImage2DMultisample: not available on WebGL.")
  439. }
  440. func TexSubImage2D(target Enum, level int, x, y, width, height int, format, ty Enum, data []byte) {
  441. c.Call("texSubImage2D", target, level, x, y, width, height, format, ty, data)
  442. }
  443. func TexParameterf(target, pname Enum, param float32) {
  444. c.Call("texParameterf", target, pname, param)
  445. }
  446. func TexParameterfv(target, pname Enum, params []float32) {
  447. println("TexParameterfv: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
  448. for _, param := range params {
  449. c.Call("texParameterf", target, pname, param)
  450. }
  451. }
  452. func TexParameteri(target, pname Enum, param int) {
  453. c.Call("texParameteri", target, pname, param)
  454. }
  455. func TexParameteriv(target, pname Enum, params []int32) {
  456. println("TexParameteriv: not yet tested (TODO: remove this after it's confirmed to work. Your feedback is welcome.)")
  457. for _, param := range params {
  458. c.Call("texParameteri", target, pname, param)
  459. }
  460. }
  461. func Uniform1f(dst Uniform, v float32) {
  462. c.Call("uniform1f", dst.Object, v)
  463. }
  464. func Uniform1fv(dst Uniform, src []float32) {
  465. c.Call("uniform1fv", dst.Object, src)
  466. }
  467. func Uniform1i(dst Uniform, v int) {
  468. c.Call("uniform1i", dst.Object, v)
  469. }
  470. func Uniform1iv(dst Uniform, src []int32) {
  471. c.Call("uniform1iv", dst.Object, src)
  472. }
  473. func Uniform2f(dst Uniform, v0, v1 float32) {
  474. c.Call("uniform2f", dst.Object, v0, v1)
  475. }
  476. func Uniform2fv(dst Uniform, src []float32) {
  477. c.Call("uniform2fv", dst.Object, src)
  478. }
  479. func Uniform2i(dst Uniform, v0, v1 int) {
  480. c.Call("uniform2i", dst.Object, v0, v1)
  481. }
  482. func Uniform2iv(dst Uniform, src []int32) {
  483. c.Call("uniform2iv", dst.Object, src)
  484. }
  485. func Uniform3f(dst Uniform, v0, v1, v2 float32) {
  486. c.Call("uniform3f", dst.Object, v0, v1, v2)
  487. }
  488. func Uniform3fv(dst Uniform, src []float32) {
  489. c.Call("uniform3fv", dst.Object, src)
  490. }
  491. func Uniform3i(dst Uniform, v0, v1, v2 int32) {
  492. c.Call("uniform3i", dst.Object, v0, v1, v2)
  493. }
  494. func Uniform3iv(dst Uniform, src []int32) {
  495. c.Call("uniform3iv", dst.Object, src)
  496. }
  497. func Uniform4f(dst Uniform, v0, v1, v2, v3 float32) {
  498. c.Call("uniform4f", dst.Object, v0, v1, v2, v3)
  499. }
  500. func Uniform4fv(dst Uniform, src []float32) {
  501. c.Call("uniform4fv", dst.Object, src)
  502. }
  503. func Uniform4i(dst Uniform, v0, v1, v2, v3 int32) {
  504. c.Call("uniform4i", dst.Object, v0, v1, v2, v3)
  505. }
  506. func Uniform4iv(dst Uniform, src []int32) {
  507. c.Call("uniform4iv", dst.Object, src)
  508. }
  509. func UniformMatrix2fv(dst Uniform, src []float32) {
  510. c.Call("uniformMatrix2fv", dst.Object, false, src)
  511. }
  512. func UniformMatrix3fv(dst Uniform, src []float32) {
  513. c.Call("uniformMatrix3fv", dst.Object, false, src)
  514. }
  515. func UniformMatrix4fv(dst Uniform, src []float32) {
  516. c.Call("uniformMatrix4fv", dst.Object, false, src)
  517. }
  518. func UseProgram(p Program) {
  519. c.Call("useProgram", p.Object)
  520. }
  521. func ValidateProgram(p Program) {
  522. c.Call("validateProgram", p.Object)
  523. }
  524. func VertexAttrib1f(dst Attrib, x float32) {
  525. c.Call("vertexAttrib1f", dst.Value, x)
  526. }
  527. func VertexAttrib1fv(dst Attrib, src []float32) {
  528. c.Call("vertexAttrib1fv", dst.Value, src)
  529. }
  530. func VertexAttrib2f(dst Attrib, x, y float32) {
  531. c.Call("vertexAttrib2f", dst.Value, x, y)
  532. }
  533. func VertexAttrib2fv(dst Attrib, src []float32) {
  534. c.Call("vertexAttrib2fv", dst.Value, src)
  535. }
  536. func VertexAttrib3f(dst Attrib, x, y, z float32) {
  537. c.Call("vertexAttrib3f", dst.Value, x, y, z)
  538. }
  539. func VertexAttrib3fv(dst Attrib, src []float32) {
  540. c.Call("vertexAttrib3fv", dst.Value, src)
  541. }
  542. func VertexAttrib4f(dst Attrib, x, y, z, w float32) {
  543. c.Call("vertexAttrib4f", dst.Value, x, y, z, w)
  544. }
  545. func VertexAttrib4fv(dst Attrib, src []float32) {
  546. c.Call("vertexAttrib4fv", dst.Value, src)
  547. }
  548. func VertexAttribPointer(dst Attrib, size int, ty Enum, normalized bool, stride, offset int) {
  549. c.Call("vertexAttribPointer", dst.Value, size, ty, normalized, stride, offset)
  550. }
  551. func Viewport(x, y, width, height int) {
  552. c.Call("viewport", x, y, width, height)
  553. }