interface.go 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  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. package gl
  5. // Context is an OpenGL ES context.
  6. //
  7. // A Context has a method for every GL function supported by ES 2 or later.
  8. // In a program compiled with ES 3 support, a Context is also a Context3.
  9. // For example, a program can:
  10. //
  11. // func f(glctx gl.Context) {
  12. // glctx.(gl.Context3).BlitFramebuffer(...)
  13. // }
  14. //
  15. // Calls are not safe for concurrent use. However calls can be made from
  16. // any goroutine, the gl package removes the notion of thread-local
  17. // context.
  18. //
  19. // Contexts are independent. Two contexts can be used concurrently.
  20. type Context interface {
  21. // ActiveTexture sets the active texture unit.
  22. //
  23. // http://www.khronos.org/opengles/sdk/docs/man3/html/glActiveTexture.xhtml
  24. ActiveTexture(texture Enum)
  25. // AttachShader attaches a shader to a program.
  26. //
  27. // http://www.khronos.org/opengles/sdk/docs/man3/html/glAttachShader.xhtml
  28. AttachShader(p Program, s Shader)
  29. // BindAttribLocation binds a vertex attribute index with a named
  30. // variable.
  31. //
  32. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBindAttribLocation.xhtml
  33. BindAttribLocation(p Program, a Attrib, name string)
  34. // BindBuffer binds a buffer.
  35. //
  36. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBindBuffer.xhtml
  37. BindBuffer(target Enum, b Buffer)
  38. // BindFramebuffer binds a framebuffer.
  39. //
  40. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBindFramebuffer.xhtml
  41. BindFramebuffer(target Enum, fb Framebuffer)
  42. // BindRenderbuffer binds a render buffer.
  43. //
  44. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBindRenderbuffer.xhtml
  45. BindRenderbuffer(target Enum, rb Renderbuffer)
  46. // BindTexture binds a texture.
  47. //
  48. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBindTexture.xhtml
  49. BindTexture(target Enum, t Texture)
  50. // BindVertexArray binds a vertex array.
  51. //
  52. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBindVertexArray.xhtml
  53. BindVertexArray(rb VertexArray)
  54. // BlendColor sets the blend color.
  55. //
  56. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBlendColor.xhtml
  57. BlendColor(red, green, blue, alpha float32)
  58. // BlendEquation sets both RGB and alpha blend equations.
  59. //
  60. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBlendEquation.xhtml
  61. BlendEquation(mode Enum)
  62. // BlendEquationSeparate sets RGB and alpha blend equations separately.
  63. //
  64. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBlendEquationSeparate.xhtml
  65. BlendEquationSeparate(modeRGB, modeAlpha Enum)
  66. // BlendFunc sets the pixel blending factors.
  67. //
  68. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBlendFunc.xhtml
  69. BlendFunc(sfactor, dfactor Enum)
  70. // BlendFunc sets the pixel RGB and alpha blending factors separately.
  71. //
  72. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBlendFuncSeparate.xhtml
  73. BlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha Enum)
  74. // BufferData creates a new data store for the bound buffer object.
  75. //
  76. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBufferData.xhtml
  77. BufferData(target Enum, src []byte, usage Enum)
  78. // BufferInit creates a new uninitialized data store for the bound buffer object.
  79. //
  80. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBufferData.xhtml
  81. BufferInit(target Enum, size int, usage Enum)
  82. // BufferSubData sets some of data in the bound buffer object.
  83. //
  84. // http://www.khronos.org/opengles/sdk/docs/man3/html/glBufferSubData.xhtml
  85. BufferSubData(target Enum, offset int, data []byte)
  86. // CheckFramebufferStatus reports the completeness status of the
  87. // active framebuffer.
  88. //
  89. // http://www.khronos.org/opengles/sdk/docs/man3/html/glCheckFramebufferStatus.xhtml
  90. CheckFramebufferStatus(target Enum) Enum
  91. // Clear clears the window.
  92. //
  93. // The behavior of Clear is influenced by the pixel ownership test,
  94. // the scissor test, dithering, and the buffer writemasks.
  95. //
  96. // http://www.khronos.org/opengles/sdk/docs/man3/html/glClear.xhtml
  97. Clear(mask Enum)
  98. // ClearColor specifies the RGBA values used to clear color buffers.
  99. //
  100. // http://www.khronos.org/opengles/sdk/docs/man3/html/glClearColor.xhtml
  101. ClearColor(red, green, blue, alpha float32)
  102. // ClearDepthf sets the depth value used to clear the depth buffer.
  103. //
  104. // http://www.khronos.org/opengles/sdk/docs/man3/html/glClearDepthf.xhtml
  105. ClearDepthf(d float32)
  106. // ClearStencil sets the index used to clear the stencil buffer.
  107. //
  108. // http://www.khronos.org/opengles/sdk/docs/man3/html/glClearStencil.xhtml
  109. ClearStencil(s int)
  110. // ColorMask specifies whether color components in the framebuffer
  111. // can be written.
  112. //
  113. // http://www.khronos.org/opengles/sdk/docs/man3/html/glColorMask.xhtml
  114. ColorMask(red, green, blue, alpha bool)
  115. // CompileShader compiles the source code of s.
  116. //
  117. // http://www.khronos.org/opengles/sdk/docs/man3/html/glCompileShader.xhtml
  118. CompileShader(s Shader)
  119. // CompressedTexImage2D writes a compressed 2D texture.
  120. //
  121. // http://www.khronos.org/opengles/sdk/docs/man3/html/glCompressedTexImage2D.xhtml
  122. CompressedTexImage2D(target Enum, level int, internalformat Enum, width, height, border int, data []byte)
  123. // CompressedTexSubImage2D writes a subregion of a compressed 2D texture.
  124. //
  125. // http://www.khronos.org/opengles/sdk/docs/man3/html/glCompressedTexSubImage2D.xhtml
  126. CompressedTexSubImage2D(target Enum, level, xoffset, yoffset, width, height int, format Enum, data []byte)
  127. // CopyTexImage2D writes a 2D texture from the current framebuffer.
  128. //
  129. // http://www.khronos.org/opengles/sdk/docs/man3/html/glCopyTexImage2D.xhtml
  130. CopyTexImage2D(target Enum, level int, internalformat Enum, x, y, width, height, border int)
  131. // CopyTexSubImage2D writes a 2D texture subregion from the
  132. // current framebuffer.
  133. //
  134. // http://www.khronos.org/opengles/sdk/docs/man3/html/glCopyTexSubImage2D.xhtml
  135. CopyTexSubImage2D(target Enum, level, xoffset, yoffset, x, y, width, height int)
  136. // CreateBuffer creates a buffer object.
  137. //
  138. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGenBuffers.xhtml
  139. CreateBuffer() Buffer
  140. // CreateFramebuffer creates a framebuffer object.
  141. //
  142. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGenFramebuffers.xhtml
  143. CreateFramebuffer() Framebuffer
  144. // CreateProgram creates a new empty program object.
  145. //
  146. // http://www.khronos.org/opengles/sdk/docs/man3/html/glCreateProgram.xhtml
  147. CreateProgram() Program
  148. // CreateRenderbuffer create a renderbuffer object.
  149. //
  150. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGenRenderbuffers.xhtml
  151. CreateRenderbuffer() Renderbuffer
  152. // CreateShader creates a new empty shader object.
  153. //
  154. // http://www.khronos.org/opengles/sdk/docs/man3/html/glCreateShader.xhtml
  155. CreateShader(ty Enum) Shader
  156. // CreateTexture creates a texture object.
  157. //
  158. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGenTextures.xhtml
  159. CreateTexture() Texture
  160. // CreateTVertexArray creates a vertex array.
  161. //
  162. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGenVertexArrays.xhtml
  163. CreateVertexArray() VertexArray
  164. // CullFace specifies which polygons are candidates for culling.
  165. //
  166. // Valid modes: FRONT, BACK, FRONT_AND_BACK.
  167. //
  168. // http://www.khronos.org/opengles/sdk/docs/man3/html/glCullFace.xhtml
  169. CullFace(mode Enum)
  170. // DeleteBuffer deletes the given buffer object.
  171. //
  172. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteBuffers.xhtml
  173. DeleteBuffer(v Buffer)
  174. // DeleteFramebuffer deletes the given framebuffer object.
  175. //
  176. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteFramebuffers.xhtml
  177. DeleteFramebuffer(v Framebuffer)
  178. // DeleteProgram deletes the given program object.
  179. //
  180. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteProgram.xhtml
  181. DeleteProgram(p Program)
  182. // DeleteRenderbuffer deletes the given render buffer object.
  183. //
  184. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteRenderbuffers.xhtml
  185. DeleteRenderbuffer(v Renderbuffer)
  186. // DeleteShader deletes shader s.
  187. //
  188. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteShader.xhtml
  189. DeleteShader(s Shader)
  190. // DeleteTexture deletes the given texture object.
  191. //
  192. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteTextures.xhtml
  193. DeleteTexture(v Texture)
  194. // DeleteVertexArray deletes the given render buffer object.
  195. //
  196. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteVertexArrays.xhtml
  197. DeleteVertexArray(v VertexArray)
  198. // DepthFunc sets the function used for depth buffer comparisons.
  199. //
  200. // Valid fn values:
  201. // NEVER
  202. // LESS
  203. // EQUAL
  204. // LEQUAL
  205. // GREATER
  206. // NOTEQUAL
  207. // GEQUAL
  208. // ALWAYS
  209. //
  210. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDepthFunc.xhtml
  211. DepthFunc(fn Enum)
  212. // DepthMask sets the depth buffer enabled for writing.
  213. //
  214. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDepthMask.xhtml
  215. DepthMask(flag bool)
  216. // DepthRangef sets the mapping from normalized device coordinates to
  217. // window coordinates.
  218. //
  219. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDepthRangef.xhtml
  220. DepthRangef(n, f float32)
  221. // DetachShader detaches the shader s from the program p.
  222. //
  223. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDetachShader.xhtml
  224. DetachShader(p Program, s Shader)
  225. // Disable disables various GL capabilities.
  226. //
  227. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDisable.xhtml
  228. Disable(cap Enum)
  229. // DisableVertexAttribArray disables a vertex attribute array.
  230. //
  231. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDisableVertexAttribArray.xhtml
  232. DisableVertexAttribArray(a Attrib)
  233. // DrawArrays renders geometric primitives from the bound data.
  234. //
  235. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDrawArrays.xhtml
  236. DrawArrays(mode Enum, first, count int)
  237. // DrawElements renders primitives from a bound buffer.
  238. //
  239. // http://www.khronos.org/opengles/sdk/docs/man3/html/glDrawElements.xhtml
  240. DrawElements(mode Enum, count int, ty Enum, offset int)
  241. // TODO(crawshaw): consider DrawElements8 / DrawElements16 / DrawElements32
  242. // Enable enables various GL capabilities.
  243. //
  244. // http://www.khronos.org/opengles/sdk/docs/man3/html/glEnable.xhtml
  245. Enable(cap Enum)
  246. // EnableVertexAttribArray enables a vertex attribute array.
  247. //
  248. // http://www.khronos.org/opengles/sdk/docs/man3/html/glEnableVertexAttribArray.xhtml
  249. EnableVertexAttribArray(a Attrib)
  250. // Finish blocks until the effects of all previously called GL
  251. // commands are complete.
  252. //
  253. // http://www.khronos.org/opengles/sdk/docs/man3/html/glFinish.xhtml
  254. Finish()
  255. // Flush empties all buffers. It does not block.
  256. //
  257. // An OpenGL implementation may buffer network communication,
  258. // the command stream, or data inside the graphics accelerator.
  259. //
  260. // http://www.khronos.org/opengles/sdk/docs/man3/html/glFlush.xhtml
  261. Flush()
  262. // FramebufferRenderbuffer attaches rb to the current frame buffer.
  263. //
  264. // http://www.khronos.org/opengles/sdk/docs/man3/html/glFramebufferRenderbuffer.xhtml
  265. FramebufferRenderbuffer(target, attachment, rbTarget Enum, rb Renderbuffer)
  266. // FramebufferTexture2D attaches the t to the current frame buffer.
  267. //
  268. // http://www.khronos.org/opengles/sdk/docs/man3/html/glFramebufferTexture2D.xhtml
  269. FramebufferTexture2D(target, attachment, texTarget Enum, t Texture, level int)
  270. // FrontFace defines which polygons are front-facing.
  271. //
  272. // Valid modes: CW, CCW.
  273. //
  274. // http://www.khronos.org/opengles/sdk/docs/man3/html/glFrontFace.xhtml
  275. FrontFace(mode Enum)
  276. // GenerateMipmap generates mipmaps for the current texture.
  277. //
  278. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGenerateMipmap.xhtml
  279. GenerateMipmap(target Enum)
  280. // GetActiveAttrib returns details about an active attribute variable.
  281. // A value of 0 for index selects the first active attribute variable.
  282. // Permissible values for index range from 0 to the number of active
  283. // attribute variables minus 1.
  284. //
  285. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetActiveAttrib.xhtml
  286. GetActiveAttrib(p Program, index uint32) (name string, size int, ty Enum)
  287. // GetActiveUniform returns details about an active uniform variable.
  288. // A value of 0 for index selects the first active uniform variable.
  289. // Permissible values for index range from 0 to the number of active
  290. // uniform variables minus 1.
  291. //
  292. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetActiveUniform.xhtml
  293. GetActiveUniform(p Program, index uint32) (name string, size int, ty Enum)
  294. // GetAttachedShaders returns the shader objects attached to program p.
  295. //
  296. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetAttachedShaders.xhtml
  297. GetAttachedShaders(p Program) []Shader
  298. // GetAttribLocation returns the location of an attribute variable.
  299. //
  300. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetAttribLocation.xhtml
  301. GetAttribLocation(p Program, name string) Attrib
  302. // GetBooleanv returns the boolean values of parameter pname.
  303. //
  304. // Many boolean parameters can be queried more easily using IsEnabled.
  305. //
  306. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGet.xhtml
  307. GetBooleanv(dst []bool, pname Enum)
  308. // GetFloatv returns the float values of parameter pname.
  309. //
  310. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGet.xhtml
  311. GetFloatv(dst []float32, pname Enum)
  312. // GetIntegerv returns the int values of parameter pname.
  313. //
  314. // Single values may be queried more easily using GetInteger.
  315. //
  316. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGet.xhtml
  317. GetIntegerv(dst []int32, pname Enum)
  318. // GetInteger returns the int value of parameter pname.
  319. //
  320. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGet.xhtml
  321. GetInteger(pname Enum) int
  322. // GetBufferParameteri returns a parameter for the active buffer.
  323. //
  324. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetBufferParameter.xhtml
  325. GetBufferParameteri(target, value Enum) int
  326. // GetError returns the next error.
  327. //
  328. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetError.xhtml
  329. GetError() Enum
  330. // GetFramebufferAttachmentParameteri returns attachment parameters
  331. // for the active framebuffer object.
  332. //
  333. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetFramebufferAttachmentParameteriv.xhtml
  334. GetFramebufferAttachmentParameteri(target, attachment, pname Enum) int
  335. // GetProgrami returns a parameter value for a program.
  336. //
  337. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetProgramiv.xhtml
  338. GetProgrami(p Program, pname Enum) int
  339. // GetProgramInfoLog returns the information log for a program.
  340. //
  341. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetProgramInfoLog.xhtml
  342. GetProgramInfoLog(p Program) string
  343. // GetRenderbufferParameteri returns a parameter value for a render buffer.
  344. //
  345. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetRenderbufferParameteriv.xhtml
  346. GetRenderbufferParameteri(target, pname Enum) int
  347. // GetShaderi returns a parameter value for a shader.
  348. //
  349. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetShaderiv.xhtml
  350. GetShaderi(s Shader, pname Enum) int
  351. // GetShaderInfoLog returns the information log for a shader.
  352. //
  353. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetShaderInfoLog.xhtml
  354. GetShaderInfoLog(s Shader) string
  355. // GetShaderPrecisionFormat returns range and precision limits for
  356. // shader types.
  357. //
  358. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetShaderPrecisionFormat.xhtml
  359. GetShaderPrecisionFormat(shadertype, precisiontype Enum) (rangeLow, rangeHigh, precision int)
  360. // GetShaderSource returns source code of shader s.
  361. //
  362. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetShaderSource.xhtml
  363. GetShaderSource(s Shader) string
  364. // GetString reports current GL state.
  365. //
  366. // Valid name values:
  367. // EXTENSIONS
  368. // RENDERER
  369. // SHADING_LANGUAGE_VERSION
  370. // VENDOR
  371. // VERSION
  372. //
  373. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetString.xhtml
  374. GetString(pname Enum) string
  375. // GetTexParameterfv returns the float values of a texture parameter.
  376. //
  377. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetTexParameter.xhtml
  378. GetTexParameterfv(dst []float32, target, pname Enum)
  379. // GetTexParameteriv returns the int values of a texture parameter.
  380. //
  381. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetTexParameter.xhtml
  382. GetTexParameteriv(dst []int32, target, pname Enum)
  383. // GetUniformfv returns the float values of a uniform variable.
  384. //
  385. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetUniform.xhtml
  386. GetUniformfv(dst []float32, src Uniform, p Program)
  387. // GetUniformiv returns the float values of a uniform variable.
  388. //
  389. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetUniform.xhtml
  390. GetUniformiv(dst []int32, src Uniform, p Program)
  391. // GetUniformLocation returns the location of a uniform variable.
  392. //
  393. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetUniformLocation.xhtml
  394. GetUniformLocation(p Program, name string) Uniform
  395. // GetVertexAttribf reads the float value of a vertex attribute.
  396. //
  397. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetVertexAttrib.xhtml
  398. GetVertexAttribf(src Attrib, pname Enum) float32
  399. // GetVertexAttribfv reads float values of a vertex attribute.
  400. //
  401. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetVertexAttrib.xhtml
  402. GetVertexAttribfv(dst []float32, src Attrib, pname Enum)
  403. // GetVertexAttribi reads the int value of a vertex attribute.
  404. //
  405. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetVertexAttrib.xhtml
  406. GetVertexAttribi(src Attrib, pname Enum) int32
  407. // GetVertexAttribiv reads int values of a vertex attribute.
  408. //
  409. // http://www.khronos.org/opengles/sdk/docs/man3/html/glGetVertexAttrib.xhtml
  410. GetVertexAttribiv(dst []int32, src Attrib, pname Enum)
  411. // TODO(crawshaw): glGetVertexAttribPointerv
  412. // Hint sets implementation-specific modes.
  413. //
  414. // http://www.khronos.org/opengles/sdk/docs/man3/html/glHint.xhtml
  415. Hint(target, mode Enum)
  416. // IsBuffer reports if b is a valid buffer.
  417. //
  418. // http://www.khronos.org/opengles/sdk/docs/man3/html/glIsBuffer.xhtml
  419. IsBuffer(b Buffer) bool
  420. // IsEnabled reports if cap is an enabled capability.
  421. //
  422. // http://www.khronos.org/opengles/sdk/docs/man3/html/glIsEnabled.xhtml
  423. IsEnabled(cap Enum) bool
  424. // IsFramebuffer reports if fb is a valid frame buffer.
  425. //
  426. // http://www.khronos.org/opengles/sdk/docs/man3/html/glIsFramebuffer.xhtml
  427. IsFramebuffer(fb Framebuffer) bool
  428. // IsProgram reports if p is a valid program object.
  429. //
  430. // http://www.khronos.org/opengles/sdk/docs/man3/html/glIsProgram.xhtml
  431. IsProgram(p Program) bool
  432. // IsRenderbuffer reports if rb is a valid render buffer.
  433. //
  434. // http://www.khronos.org/opengles/sdk/docs/man3/html/glIsRenderbuffer.xhtml
  435. IsRenderbuffer(rb Renderbuffer) bool
  436. // IsShader reports if s is valid shader.
  437. //
  438. // http://www.khronos.org/opengles/sdk/docs/man3/html/glIsShader.xhtml
  439. IsShader(s Shader) bool
  440. // IsTexture reports if t is a valid texture.
  441. //
  442. // http://www.khronos.org/opengles/sdk/docs/man3/html/glIsTexture.xhtml
  443. IsTexture(t Texture) bool
  444. // LineWidth specifies the width of lines.
  445. //
  446. // http://www.khronos.org/opengles/sdk/docs/man3/html/glLineWidth.xhtml
  447. LineWidth(width float32)
  448. // LinkProgram links the specified program.
  449. //
  450. // http://www.khronos.org/opengles/sdk/docs/man3/html/glLinkProgram.xhtml
  451. LinkProgram(p Program)
  452. // PixelStorei sets pixel storage parameters.
  453. //
  454. // http://www.khronos.org/opengles/sdk/docs/man3/html/glPixelStorei.xhtml
  455. PixelStorei(pname Enum, param int32)
  456. // PolygonOffset sets the scaling factors for depth offsets.
  457. //
  458. // http://www.khronos.org/opengles/sdk/docs/man3/html/glPolygonOffset.xhtml
  459. PolygonOffset(factor, units float32)
  460. // ReadPixels returns pixel data from a buffer.
  461. //
  462. // In GLES 3, the source buffer is controlled with ReadBuffer.
  463. //
  464. // http://www.khronos.org/opengles/sdk/docs/man3/html/glReadPixels.xhtml
  465. ReadPixels(dst []byte, x, y, width, height int, format, ty Enum)
  466. // ReleaseShaderCompiler frees resources allocated by the shader compiler.
  467. //
  468. // http://www.khronos.org/opengles/sdk/docs/man3/html/glReleaseShaderCompiler.xhtml
  469. ReleaseShaderCompiler()
  470. // RenderbufferStorage establishes the data storage, format, and
  471. // dimensions of a renderbuffer object's image.
  472. //
  473. // http://www.khronos.org/opengles/sdk/docs/man3/html/glRenderbufferStorage.xhtml
  474. RenderbufferStorage(target, internalFormat Enum, width, height int)
  475. // SampleCoverage sets multisample coverage parameters.
  476. //
  477. // http://www.khronos.org/opengles/sdk/docs/man3/html/glSampleCoverage.xhtml
  478. SampleCoverage(value float32, invert bool)
  479. // Scissor defines the scissor box rectangle, in window coordinates.
  480. //
  481. // http://www.khronos.org/opengles/sdk/docs/man3/html/glScissor.xhtml
  482. Scissor(x, y, width, height int32)
  483. // TODO(crawshaw): ShaderBinary
  484. // ShaderSource sets the source code of s to the given source code.
  485. //
  486. // http://www.khronos.org/opengles/sdk/docs/man3/html/glShaderSource.xhtml
  487. ShaderSource(s Shader, src string)
  488. // StencilFunc sets the front and back stencil test reference value.
  489. //
  490. // http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilFunc.xhtml
  491. StencilFunc(fn Enum, ref int, mask uint32)
  492. // StencilFunc sets the front or back stencil test reference value.
  493. //
  494. // http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilFuncSeparate.xhtml
  495. StencilFuncSeparate(face, fn Enum, ref int, mask uint32)
  496. // StencilMask controls the writing of bits in the stencil planes.
  497. //
  498. // http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilMask.xhtml
  499. StencilMask(mask uint32)
  500. // StencilMaskSeparate controls the writing of bits in the stencil planes.
  501. //
  502. // http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilMaskSeparate.xhtml
  503. StencilMaskSeparate(face Enum, mask uint32)
  504. // StencilOp sets front and back stencil test actions.
  505. //
  506. // http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilOp.xhtml
  507. StencilOp(fail, zfail, zpass Enum)
  508. // StencilOpSeparate sets front or back stencil tests.
  509. //
  510. // http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilOpSeparate.xhtml
  511. StencilOpSeparate(face, sfail, dpfail, dppass Enum)
  512. // TexImage2D writes a 2D texture image.
  513. //
  514. // http://www.khronos.org/opengles/sdk/docs/man3/html/glTexImage2D.xhtml
  515. TexImage2D(target Enum, level int, internalFormat int, width, height int, format Enum, ty Enum, data []byte)
  516. // TexSubImage2D writes a subregion of a 2D texture image.
  517. //
  518. // http://www.khronos.org/opengles/sdk/docs/man3/html/glTexSubImage2D.xhtml
  519. TexSubImage2D(target Enum, level int, x, y, width, height int, format, ty Enum, data []byte)
  520. // TexParameterf sets a float texture parameter.
  521. //
  522. // http://www.khronos.org/opengles/sdk/docs/man3/html/glTexParameter.xhtml
  523. TexParameterf(target, pname Enum, param float32)
  524. // TexParameterfv sets a float texture parameter array.
  525. //
  526. // http://www.khronos.org/opengles/sdk/docs/man3/html/glTexParameter.xhtml
  527. TexParameterfv(target, pname Enum, params []float32)
  528. // TexParameteri sets an integer texture parameter.
  529. //
  530. // http://www.khronos.org/opengles/sdk/docs/man3/html/glTexParameter.xhtml
  531. TexParameteri(target, pname Enum, param int)
  532. // TexParameteriv sets an integer texture parameter array.
  533. //
  534. // http://www.khronos.org/opengles/sdk/docs/man3/html/glTexParameter.xhtml
  535. TexParameteriv(target, pname Enum, params []int32)
  536. // Uniform1f writes a float uniform variable.
  537. //
  538. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  539. Uniform1f(dst Uniform, v float32)
  540. // Uniform1fv writes a [len(src)]float uniform array.
  541. //
  542. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  543. Uniform1fv(dst Uniform, src []float32)
  544. // Uniform1i writes an int uniform variable.
  545. //
  546. // Uniform1i and Uniform1iv are the only two functions that may be used
  547. // to load uniform variables defined as sampler types. Loading samplers
  548. // with any other function will result in a INVALID_OPERATION error.
  549. //
  550. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  551. Uniform1i(dst Uniform, v int)
  552. // Uniform1iv writes a int uniform array of len(src) elements.
  553. //
  554. // Uniform1i and Uniform1iv are the only two functions that may be used
  555. // to load uniform variables defined as sampler types. Loading samplers
  556. // with any other function will result in a INVALID_OPERATION error.
  557. //
  558. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  559. Uniform1iv(dst Uniform, src []int32)
  560. // Uniform2f writes a vec2 uniform variable.
  561. //
  562. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  563. Uniform2f(dst Uniform, v0, v1 float32)
  564. // Uniform2fv writes a vec2 uniform array of len(src)/2 elements.
  565. //
  566. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  567. Uniform2fv(dst Uniform, src []float32)
  568. // Uniform2i writes an ivec2 uniform variable.
  569. //
  570. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  571. Uniform2i(dst Uniform, v0, v1 int)
  572. // Uniform2iv writes an ivec2 uniform array of len(src)/2 elements.
  573. //
  574. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  575. Uniform2iv(dst Uniform, src []int32)
  576. // Uniform3f writes a vec3 uniform variable.
  577. //
  578. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  579. Uniform3f(dst Uniform, v0, v1, v2 float32)
  580. // Uniform3fv writes a vec3 uniform array of len(src)/3 elements.
  581. //
  582. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  583. Uniform3fv(dst Uniform, src []float32)
  584. // Uniform3i writes an ivec3 uniform variable.
  585. //
  586. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  587. Uniform3i(dst Uniform, v0, v1, v2 int32)
  588. // Uniform3iv writes an ivec3 uniform array of len(src)/3 elements.
  589. //
  590. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  591. Uniform3iv(dst Uniform, src []int32)
  592. // Uniform4f writes a vec4 uniform variable.
  593. //
  594. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  595. Uniform4f(dst Uniform, v0, v1, v2, v3 float32)
  596. // Uniform4fv writes a vec4 uniform array of len(src)/4 elements.
  597. //
  598. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  599. Uniform4fv(dst Uniform, src []float32)
  600. // Uniform4i writes an ivec4 uniform variable.
  601. //
  602. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  603. Uniform4i(dst Uniform, v0, v1, v2, v3 int32)
  604. // Uniform4i writes an ivec4 uniform array of len(src)/4 elements.
  605. //
  606. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  607. Uniform4iv(dst Uniform, src []int32)
  608. // UniformMatrix2fv writes 2x2 matrices. Each matrix uses four
  609. // float32 values, so the number of matrices written is len(src)/4.
  610. //
  611. // Each matrix must be supplied in column major order.
  612. //
  613. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  614. UniformMatrix2fv(dst Uniform, src []float32)
  615. // UniformMatrix3fv writes 3x3 matrices. Each matrix uses nine
  616. // float32 values, so the number of matrices written is len(src)/9.
  617. //
  618. // Each matrix must be supplied in column major order.
  619. //
  620. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  621. UniformMatrix3fv(dst Uniform, src []float32)
  622. // UniformMatrix4fv writes 4x4 matrices. Each matrix uses 16
  623. // float32 values, so the number of matrices written is len(src)/16.
  624. //
  625. // Each matrix must be supplied in column major order.
  626. //
  627. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
  628. UniformMatrix4fv(dst Uniform, src []float32)
  629. // UseProgram sets the active program.
  630. //
  631. // http://www.khronos.org/opengles/sdk/docs/man3/html/glUseProgram.xhtml
  632. UseProgram(p Program)
  633. // ValidateProgram checks to see whether the executables contained in
  634. // program can execute given the current OpenGL state.
  635. //
  636. // Typically only used for debugging.
  637. //
  638. // http://www.khronos.org/opengles/sdk/docs/man3/html/glValidateProgram.xhtml
  639. ValidateProgram(p Program)
  640. // VertexAttrib1f writes a float vertex attribute.
  641. //
  642. // http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
  643. VertexAttrib1f(dst Attrib, x float32)
  644. // VertexAttrib1fv writes a float vertex attribute.
  645. //
  646. // http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
  647. VertexAttrib1fv(dst Attrib, src []float32)
  648. // VertexAttrib2f writes a vec2 vertex attribute.
  649. //
  650. // http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
  651. VertexAttrib2f(dst Attrib, x, y float32)
  652. // VertexAttrib2fv writes a vec2 vertex attribute.
  653. //
  654. // http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
  655. VertexAttrib2fv(dst Attrib, src []float32)
  656. // VertexAttrib3f writes a vec3 vertex attribute.
  657. //
  658. // http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
  659. VertexAttrib3f(dst Attrib, x, y, z float32)
  660. // VertexAttrib3fv writes a vec3 vertex attribute.
  661. //
  662. // http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
  663. VertexAttrib3fv(dst Attrib, src []float32)
  664. // VertexAttrib4f writes a vec4 vertex attribute.
  665. //
  666. // http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
  667. VertexAttrib4f(dst Attrib, x, y, z, w float32)
  668. // VertexAttrib4fv writes a vec4 vertex attribute.
  669. //
  670. // http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
  671. VertexAttrib4fv(dst Attrib, src []float32)
  672. // VertexAttribPointer uses a bound buffer to define vertex attribute data.
  673. //
  674. // Direct use of VertexAttribPointer to load data into OpenGL is not
  675. // supported via the Go bindings. Instead, use BindBuffer with an
  676. // ARRAY_BUFFER and then fill it using BufferData.
  677. //
  678. // The size argument specifies the number of components per attribute,
  679. // between 1-4. The stride argument specifies the byte offset between
  680. // consecutive vertex attributes.
  681. //
  682. // http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttribPointer.xhtml
  683. VertexAttribPointer(dst Attrib, size int, ty Enum, normalized bool, stride, offset int)
  684. // Viewport sets the viewport, an affine transformation that
  685. // normalizes device coordinates to window coordinates.
  686. //
  687. // http://www.khronos.org/opengles/sdk/docs/man3/html/glViewport.xhtml
  688. Viewport(x, y, width, height int)
  689. }
  690. // Context3 is an OpenGL ES 3 context.
  691. //
  692. // When the gl package is compiled with GL ES 3 support, the produced
  693. // Context object also implements the Context3 interface.
  694. type Context3 interface {
  695. Context
  696. // BlitFramebuffer copies a block of pixels between framebuffers.
  697. //
  698. // https://www.khronos.org/opengles/sdk/docs/man3/html/glBlitFramebuffer.xhtml
  699. BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1 int, mask uint, filter Enum)
  700. }
  701. // Worker is used by display driver code to execute OpenGL calls.
  702. //
  703. // Typically display driver code creates a gl.Context for an application,
  704. // and along with it establishes a locked OS thread to execute the cgo
  705. // calls:
  706. //
  707. // go func() {
  708. // runtime.LockOSThread()
  709. // // ... platform-specific cgo call to bind a C OpenGL context
  710. // // into thread-local storage.
  711. //
  712. // glctx, worker := gl.NewContext()
  713. // workAvailable := worker.WorkAvailable()
  714. // go userAppCode(glctx)
  715. // for {
  716. // select {
  717. // case <-workAvailable:
  718. // worker.DoWork()
  719. // case <-drawEvent:
  720. // // ... platform-specific cgo call to draw screen
  721. // }
  722. // }
  723. // }()
  724. //
  725. // This interface is an internal implementation detail and should only be used
  726. // by the package responsible for managing the screen, such as
  727. // golang.org/x/mobile/app.
  728. type Worker interface {
  729. // WorkAvailable returns a channel that communicates when DoWork should be
  730. // called.
  731. WorkAvailable() <-chan struct{}
  732. // DoWork performs any pending OpenGL calls.
  733. DoWork()
  734. }