bgl.rst 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511
  1. OpenGL Wrapper (bgl)
  2. ====================
  3. .. module:: bgl
  4. This module wraps OpenGL constants and functions, making them available from
  5. within Blender Python.
  6. The complete list can be retrieved from the module itself, by listing its
  7. contents: dir(bgl). A simple search on the web can point to more
  8. than enough material to teach OpenGL programming, from books to many
  9. collections of tutorials.
  10. Here is a comprehensive `list of books <https://www.khronos.org/developers/books/>`__ (non free).
  11. The `arcsynthesis tutorials <https://web.archive.org/web/20150225192611/http://www.arcsynthesis.org/gltut/index.html>`__
  12. is one of the best resources to learn modern OpenGL and
  13. `g-truc <http://www.g-truc.net/post-opengl-samples.html#menu>`__
  14. offers a set of extensive examples, including advanced features.
  15. .. note::
  16. You can use the :class:`Image` type to load and set textures.
  17. See :class:`Image.gl_load` and :class:`Image.gl_load`,
  18. for example.
  19. .. function:: glBindTexture(target, texture):
  20. Bind a named texture to a texturing target
  21. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glBindTexture.xml>`__
  22. :type target: Enumerated constant
  23. :arg target: Specifies the target to which the texture is bound.
  24. :type texture: unsigned int
  25. :arg texture: Specifies the name of a texture.
  26. .. function:: glBlendFunc(sfactor, dfactor):
  27. Specify pixel arithmetic
  28. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glBlendFunc.xml>`__
  29. :type sfactor: Enumerated constant
  30. :arg sfactor: Specifies how the red, green, blue, and alpha source blending factors are
  31. computed.
  32. :type dfactor: Enumerated constant
  33. :arg dfactor: Specifies how the red, green, blue, and alpha destination
  34. blending factors are computed.
  35. .. function:: glClear(mask):
  36. Clear buffers to preset values
  37. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glClear.xml>`__
  38. :type mask: Enumerated constant(s)
  39. :arg mask: Bitwise OR of masks that indicate the buffers to be cleared.
  40. .. function:: glClearColor(red, green, blue, alpha):
  41. Specify clear values for the color buffers
  42. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glClearColor.xml>`__
  43. :type red, green, blue, alpha: float
  44. :arg red, green, blue, alpha: Specify the red, green, blue, and alpha values used when the
  45. color buffers are cleared. The initial values are all 0.
  46. .. function:: glClearDepth(depth):
  47. Specify the clear value for the depth buffer
  48. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glClearDepth.xml>`__
  49. :type depth: int
  50. :arg depth: Specifies the depth value used when the depth buffer is cleared.
  51. The initial value is 1.
  52. .. function:: glClearStencil(s):
  53. Specify the clear value for the stencil buffer
  54. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glClearStencil.xml>`__
  55. :type s: int
  56. :arg s: Specifies the index used when the stencil buffer is cleared. The initial value is 0.
  57. .. function:: glClipPlane (plane, equation):
  58. Specify a plane against which all geometry is clipped
  59. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glClipPlane.xml>`__
  60. :type plane: Enumerated constant
  61. :arg plane: Specifies which clipping plane is being positioned.
  62. :type equation: :class:`bgl.Buffer` object I{type GL_FLOAT}(double)
  63. :arg equation: Specifies the address of an array of four double- precision
  64. floating-point values. These values are interpreted as a plane equation.
  65. .. function:: glColor (red, green, blue, alpha):
  66. B{glColor3b, glColor3d, glColor3f, glColor3i, glColor3s, glColor3ub, glColor3ui, glColor3us,
  67. glColor4b, glColor4d, glColor4f, glColor4i, glColor4s, glColor4ub, glColor4ui, glColor4us,
  68. glColor3bv, glColor3dv, glColor3fv, glColor3iv, glColor3sv, glColor3ubv, glColor3uiv,
  69. glColor3usv, glColor4bv, glColor4dv, glColor4fv, glColor4iv, glColor4sv, glColor4ubv,
  70. glColor4uiv, glColor4usv}
  71. Set a new color.
  72. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glColor.xml>`__
  73. :type red, green, blue, alpha: Depends on function prototype.
  74. :arg red, green, blue: Specify new red, green, and blue values for the current color.
  75. :arg alpha: Specifies a new alpha value for the current color. Included only in the
  76. four-argument glColor4 commands. (With '4' colors only)
  77. .. function:: glColorMask(red, green, blue, alpha):
  78. Enable and disable writing of frame buffer color components
  79. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glColorMask.xml>`__
  80. :type red, green, blue, alpha: int (boolean)
  81. :arg red, green, blue, alpha: Specify whether red, green, blue, and alpha can or cannot be
  82. written into the frame buffer. The initial values are all GL_TRUE, indicating that the
  83. color components can be written.
  84. .. function:: glCopyTexImage2D(target, level, internalformat, x, y, width, height, border):
  85. Copy pixels into a 2D texture image
  86. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glCopyTexImage2D.xml>`__
  87. :type target: Enumerated constant
  88. :arg target: Specifies the target texture.
  89. :type level: int
  90. :arg level: Specifies the level-of-detail number. Level 0 is the base image level.
  91. Level n is the nth mipmap reduction image.
  92. :type internalformat: int
  93. :arg internalformat: Specifies the number of color components in the texture.
  94. :type width: int
  95. :type x, y: int
  96. :arg x, y: Specify the window coordinates of the first pixel that is copied
  97. from the frame buffer. This location is the lower left corner of a rectangular
  98. block of pixels.
  99. :arg width: Specifies the width of the texture image. Must be 2n+2(border) for
  100. some integer n. All implementations support texture images that are at least 64
  101. texels wide.
  102. :type height: int
  103. :arg height: Specifies the height of the texture image. Must be 2m+2(border) for
  104. some integer m. All implementations support texture images that are at least 64
  105. texels high.
  106. :type border: int
  107. :arg border: Specifies the width of the border. Must be either 0 or 1.
  108. .. function:: glCullFace(mode):
  109. Specify whether front- or back-facing facets can be culled
  110. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glCullFace.xml>`__
  111. :type mode: Enumerated constant
  112. :arg mode: Specifies whether front- or back-facing facets are candidates for culling.
  113. .. function:: glDeleteTextures(n, textures):
  114. Delete named textures
  115. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glDeleteTextures.xml>`__
  116. :type n: int
  117. :arg n: Specifies the number of textures to be deleted
  118. :type textures: :class:`bgl.Buffer` I{GL_INT}
  119. :arg textures: Specifies an array of textures to be deleted
  120. .. function:: glDepthFunc(func):
  121. Specify the value used for depth buffer comparisons
  122. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glDepthFunc.xml>`__
  123. :type func: Enumerated constant
  124. :arg func: Specifies the depth comparison function.
  125. .. function:: glDepthMask(flag):
  126. Enable or disable writing into the depth buffer
  127. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glDepthMask.xml>`__
  128. :type flag: int (boolean)
  129. :arg flag: Specifies whether the depth buffer is enabled for writing. If flag is GL_FALSE,
  130. depth buffer writing is disabled. Otherwise, it is enabled. Initially, depth buffer
  131. writing is enabled.
  132. .. function:: glDepthRange(zNear, zFar):
  133. Specify mapping of depth values from normalized device coordinates to window coordinates
  134. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glDepthRange.xml>`__
  135. :type zNear: int
  136. :arg zNear: Specifies the mapping of the near clipping plane to window coordinates.
  137. The initial value is 0.
  138. :type zFar: int
  139. :arg zFar: Specifies the mapping of the far clipping plane to window coordinates.
  140. The initial value is 1.
  141. .. function:: glDisable(cap):
  142. Disable server-side GL capabilities
  143. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glEnable.xml>`__
  144. :type cap: Enumerated constant
  145. :arg cap: Specifies a symbolic constant indicating a GL capability.
  146. .. function:: glDrawBuffer(mode):
  147. Specify which color buffers are to be drawn into
  148. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glDrawBuffer.xml>`__
  149. :type mode: Enumerated constant
  150. :arg mode: Specifies up to four color buffers to be drawn into.
  151. .. function:: glEdgeFlag (flag):
  152. B{glEdgeFlag, glEdgeFlagv}
  153. Flag edges as either boundary or non-boundary
  154. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glEdgeFlag.xml>`__
  155. :type flag: Depends of function prototype
  156. :arg flag: Specifies the current edge flag value.The initial value is GL_TRUE.
  157. .. function:: glEnable(cap):
  158. Enable server-side GL capabilities
  159. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glEnable.xml>`__
  160. :type cap: Enumerated constant
  161. :arg cap: Specifies a symbolic constant indicating a GL capability.
  162. .. function:: glEvalCoord (u,v):
  163. B{glEvalCoord1d, glEvalCoord1f, glEvalCoord2d, glEvalCoord2f, glEvalCoord1dv, glEvalCoord1fv,
  164. glEvalCoord2dv, glEvalCoord2fv}
  165. Evaluate enabled one- and two-dimensional maps
  166. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glEvalCoord.xml>`__
  167. :type u: Depends on function prototype.
  168. :arg u: Specifies a value that is the domain coordinate u to the basis function defined
  169. in a previous glMap1 or glMap2 command. If the function prototype ends in 'v' then
  170. u specifies a pointer to an array containing either one or two domain coordinates. The first
  171. coordinate is u. The second coordinate is v, which is present only in glEvalCoord2 versions.
  172. :type v: Depends on function prototype. (only with '2' prototypes)
  173. :arg v: Specifies a value that is the domain coordinate v to the basis function defined
  174. in a previous glMap2 command. This argument is not present in a glEvalCoord1 command.
  175. .. function:: glEvalMesh (mode, i1, i2):
  176. B{glEvalMesh1 or glEvalMesh2}
  177. Compute a one- or two-dimensional grid of points or lines
  178. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glEvalMesh.xml>`__
  179. :type mode: Enumerated constant
  180. :arg mode: In glEvalMesh1, specifies whether to compute a one-dimensional
  181. mesh of points or lines.
  182. :type i1, i2: int
  183. :arg i1, i2: Specify the first and last integer values for the grid domain variable i.
  184. .. function:: glEvalPoint (i, j):
  185. B{glEvalPoint1 and glEvalPoint2}
  186. Generate and evaluate a single point in a mesh
  187. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glEvalPoint.xml>`__
  188. :type i: int
  189. :arg i: Specifies the integer value for grid domain variable i.
  190. :type j: int (only with '2' prototypes)
  191. :arg j: Specifies the integer value for grid domain variable j (glEvalPoint2 only).
  192. .. function:: glFeedbackBuffer (size, type, buffer):
  193. Controls feedback mode
  194. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glFeedbackBuffer.xml>`__
  195. :type size: int
  196. :arg size: Specifies the maximum number of values that can be written into buffer.
  197. :type type: Enumerated constant
  198. :arg type: Specifies a symbolic constant that describes the information that
  199. will be returned for each vertex.
  200. :type buffer: :class:`bgl.Buffer` object I{GL_FLOAT}
  201. :arg buffer: Returns the feedback data.
  202. .. function:: glFinish():
  203. Block until all GL execution is complete
  204. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glFinish.xml>`__
  205. .. function:: glFlush():
  206. Force Execution of GL commands in finite time
  207. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glFlush.xml>`__
  208. .. function:: glFog (pname, param):
  209. B{glFogf, glFogi, glFogfv, glFogiv}
  210. Specify fog parameters
  211. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glFog.xml>`__
  212. :type pname: Enumerated constant
  213. :arg pname: Specifies a single-valued fog parameter. If the function prototype
  214. ends in 'v' specifies a fog parameter.
  215. :type param: Depends on function prototype.
  216. :arg param: Specifies the value or values to be assigned to pname. GL_FOG_COLOR
  217. requires an array of four values. All other parameters accept an array containing
  218. only a single value.
  219. .. function:: glFrontFace(mode):
  220. Define front- and back-facing polygons
  221. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glFrontFace.xml>`__
  222. :type mode: Enumerated constant
  223. :arg mode: Specifies the orientation of front-facing polygons.
  224. .. function:: glGenTextures(n, textures):
  225. Generate texture names
  226. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGenTextures.xml>`__
  227. :type n: int
  228. :arg n: Specifies the number of textures name to be generated.
  229. :type textures: :class:`bgl.Buffer` object I{type GL_INT}
  230. :arg textures: Specifies an array in which the generated textures names are stored.
  231. .. function:: glGet (pname, param):
  232. B{glGetBooleanv, glGetfloatv, glGetFloatv, glGetIntegerv}
  233. Return the value or values of a selected parameter
  234. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGet.xml>`__
  235. :type pname: Enumerated constant
  236. :arg pname: Specifies the parameter value to be returned.
  237. :type param: Depends on function prototype.
  238. :arg param: Returns the value or values of the specified parameter.
  239. .. function:: glGetError():
  240. Return error information
  241. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetError.xml>`__
  242. .. function:: glGetLight (light, pname, params):
  243. B{glGetLightfv and glGetLightiv}
  244. Return light source parameter values
  245. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetLight.xml>`__
  246. :type light: Enumerated constant
  247. :arg light: Specifies a light source. The number of possible lights depends on the
  248. implementation, but at least eight lights are supported. They are identified by symbolic
  249. names of the form GL_LIGHTi where 0 < i < GL_MAX_LIGHTS.
  250. :type pname: Enumerated constant
  251. :arg pname: Specifies a light source parameter for light.
  252. :type params: :class:`bgl.Buffer` object. Depends on function prototype.
  253. :arg params: Returns the requested data.
  254. .. function:: glGetMap (target, query, v):
  255. B{glGetMapdv, glGetMapfv, glGetMapiv}
  256. Return evaluator parameters
  257. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetMap.xml>`_
  258. :type target: Enumerated constant
  259. :arg target: Specifies the symbolic name of a map.
  260. :type query: Enumerated constant
  261. :arg query: Specifies which parameter to return.
  262. :type v: :class:`bgl.Buffer` object. Depends on function prototype.
  263. :arg v: Returns the requested data.
  264. .. function:: glGetMaterial (face, pname, params):
  265. B{glGetMaterialfv, glGetMaterialiv}
  266. Return material parameters
  267. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetMaterial.xml>`__
  268. :type face: Enumerated constant
  269. :arg face: Specifies which of the two materials is being queried.
  270. representing the front and back materials, respectively.
  271. :type pname: Enumerated constant
  272. :arg pname: Specifies the material parameter to return.
  273. :type params: :class:`bgl.Buffer` object. Depends on function prototype.
  274. :arg params: Returns the requested data.
  275. .. function:: glGetPixelMap (map, values):
  276. B{glGetPixelMapfv, glGetPixelMapuiv, glGetPixelMapusv}
  277. Return the specified pixel map
  278. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetPixelMap.xml>`__
  279. :type map: Enumerated constant
  280. :arg map: Specifies the name of the pixel map to return.
  281. :type values: :class:`bgl.Buffer` object. Depends on function prototype.
  282. :arg values: Returns the pixel map contents.
  283. .. function:: glGetString(name):
  284. Return a string describing the current GL connection
  285. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetString.xml>`__
  286. :type name: Enumerated constant
  287. :arg name: Specifies a symbolic constant.
  288. .. function:: glGetTexEnv (target, pname, params):
  289. B{glGetTexEnvfv, glGetTexEnviv}
  290. Return texture environment parameters
  291. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetTexEnv.xml>`__
  292. :type target: Enumerated constant
  293. :arg target: Specifies a texture environment. Must be GL_TEXTURE_ENV.
  294. :type pname: Enumerated constant
  295. :arg pname: Specifies the symbolic name of a texture environment parameter.
  296. :type params: :class:`bgl.Buffer` object. Depends on function prototype.
  297. :arg params: Returns the requested data.
  298. .. function:: glGetTexGen (coord, pname, params):
  299. B{glGetTexGendv, glGetTexGenfv, glGetTexGeniv}
  300. Return texture coordinate generation parameters
  301. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetTexGen.xml>`__
  302. :type coord: Enumerated constant
  303. :arg coord: Specifies a texture coordinate.
  304. :type pname: Enumerated constant
  305. :arg pname: Specifies the symbolic name of the value(s) to be returned.
  306. :type params: :class:`bgl.Buffer` object. Depends on function prototype.
  307. :arg params: Returns the requested data.
  308. .. function:: glGetTexImage(target, level, format, type, pixels):
  309. Return a texture image
  310. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetTexImage.xml>`__
  311. :type target: Enumerated constant
  312. :arg target: Specifies which texture is to be obtained.
  313. :type level: int
  314. :arg level: Specifies the level-of-detail number of the desired image.
  315. Level 0 is the base image level. Level n is the nth mipmap reduction image.
  316. :type format: Enumerated constant
  317. :arg format: Specifies a pixel format for the returned data.
  318. :type type: Enumerated constant
  319. :arg type: Specifies a pixel type for the returned data.
  320. :type pixels: :class:`bgl.Buffer` object.
  321. :arg pixels: Returns the texture image. Should be a pointer to an array of the
  322. type specified by type
  323. .. function:: glGetTexLevelParameter (target, level, pname, params):
  324. B{glGetTexLevelParameterfv, glGetTexLevelParameteriv}
  325. return texture parameter values for a specific level of detail
  326. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetTexLevelParameter.xml>`__
  327. :type target: Enumerated constant
  328. :arg target: Specifies the symbolic name of the target texture.
  329. :type level: int
  330. :arg level: Specifies the level-of-detail number of the desired image.
  331. Level 0 is the base image level. Level n is the nth mipmap reduction image.
  332. :type pname: Enumerated constant
  333. :arg pname: Specifies the symbolic name of a texture parameter.
  334. :type params: :class:`bgl.Buffer` object. Depends on function prototype.
  335. :arg params: Returns the requested data.
  336. .. function:: glGetTexParameter (target, pname, params):
  337. B{glGetTexParameterfv, glGetTexParameteriv}
  338. Return texture parameter values
  339. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetTexParameter.xml>`__
  340. :type target: Enumerated constant
  341. :arg target: Specifies the symbolic name of the target texture.
  342. :type pname: Enumerated constant
  343. :arg pname: Specifies the symbolic name the target texture.
  344. :type params: :class:`bgl.Buffer` object. Depends on function prototype.
  345. :arg params: Returns the texture parameters.
  346. .. function:: glHint(target, mode):
  347. Specify implementation-specific hints
  348. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glHint.xml>`__
  349. :type target: Enumerated constant
  350. :arg target: Specifies a symbolic constant indicating the behavior to be
  351. controlled.
  352. :type mode: Enumerated constant
  353. :arg mode: Specifies a symbolic constant indicating the desired behavior.
  354. .. function:: glIsEnabled(cap):
  355. Test whether a capability is enabled
  356. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glIsEnabled.xml>`__
  357. :type cap: Enumerated constant
  358. :arg cap: Specifies a constant representing a GL capability.
  359. .. function:: glIsTexture(texture):
  360. Determine if a name corresponds to a texture
  361. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glIsTexture.xml>`__
  362. :type texture: unsigned int
  363. :arg texture: Specifies a value that may be the name of a texture.
  364. .. function:: glLight (light, pname, param):
  365. B{glLightf,glLighti, glLightfv, glLightiv}
  366. Set the light source parameters
  367. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glLight.xml>`__
  368. :type light: Enumerated constant
  369. :arg light: Specifies a light. The number of lights depends on the implementation,
  370. but at least eight lights are supported. They are identified by symbolic names of the
  371. form GL_LIGHTi where 0 < i < GL_MAX_LIGHTS.
  372. :type pname: Enumerated constant
  373. :arg pname: Specifies a single-valued light source parameter for light.
  374. :type param: Depends on function prototype.
  375. :arg param: Specifies the value that parameter pname of light source light will be set to.
  376. If function prototype ends in 'v' specifies a pointer to the value or values that
  377. parameter pname of light source light will be set to.
  378. .. function:: glLightModel (pname, param):
  379. B{glLightModelf, glLightModeli, glLightModelfv, glLightModeliv}
  380. Set the lighting model parameters
  381. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glLightModel.xml>`__
  382. :type pname: Enumerated constant
  383. :arg pname: Specifies a single-value light model parameter.
  384. :type param: Depends on function prototype.
  385. :arg param: Specifies the value that param will be set to. If function prototype ends in 'v'
  386. specifies a pointer to the value or values that param will be set to.
  387. .. function:: glLineWidth(width):
  388. Specify the width of rasterized lines.
  389. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glLineWidth.xml>`__
  390. :type width: float
  391. :arg width: Specifies the width of rasterized lines. The initial value is 1.
  392. .. function:: glLoadMatrix (m):
  393. B{glLoadMatrixd, glLoadMatixf}
  394. Replace the current matrix with the specified matrix
  395. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glLoadMatrix.xml>`__
  396. :type m: :class:`bgl.Buffer` object. Depends on function prototype.
  397. :arg m: Specifies a pointer to 16 consecutive values, which are used as the elements
  398. of a 4x4 column-major matrix.
  399. .. function:: glLogicOp(opcode):
  400. Specify a logical pixel operation for color index rendering
  401. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glLogicOp.xml>`__
  402. :type opcode: Enumerated constant
  403. :arg opcode: Specifies a symbolic constant that selects a logical operation.
  404. .. function:: glMap1 (target, u1, u2, stride, order, points):
  405. B{glMap1d, glMap1f}
  406. Define a one-dimensional evaluator
  407. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glMap1.xml>`__
  408. :type target: Enumerated constant
  409. :arg target: Specifies the kind of values that are generated by the evaluator.
  410. :type u1, u2: Depends on function prototype.
  411. :arg u1,u2: Specify a linear mapping of u, as presented to glEvalCoord1, to ^, t
  412. he variable that is evaluated by the equations specified by this command.
  413. :type stride: int
  414. :arg stride: Specifies the number of floats or float (double)s between the beginning
  415. of one control point and the beginning of the next one in the data structure
  416. referenced in points. This allows control points to be embedded in arbitrary data
  417. structures. The only constraint is that the values for a particular control point must
  418. occupy contiguous memory locations.
  419. :type order: int
  420. :arg order: Specifies the number of control points. Must be positive.
  421. :type points: :class:`bgl.Buffer` object. Depends on function prototype.
  422. :arg points: Specifies a pointer to the array of control points.
  423. .. function:: glMap2 (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points):
  424. B{glMap2d, glMap2f}
  425. Define a two-dimensional evaluator
  426. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glMap2.xml>`__
  427. :type target: Enumerated constant
  428. :arg target: Specifies the kind of values that are generated by the evaluator.
  429. :type u1, u2: Depends on function prototype.
  430. :arg u1,u2: Specify a linear mapping of u, as presented to glEvalCoord2, to ^, t
  431. he variable that is evaluated by the equations specified by this command. Initially
  432. u1 is 0 and u2 is 1.
  433. :type ustride: int
  434. :arg ustride: Specifies the number of floats or float (double)s between the beginning
  435. of control point R and the beginning of control point R ij, where i and j are the u
  436. and v control point indices, respectively. This allows control points to be embedded
  437. in arbitrary data structures. The only constraint is that the values for a particular
  438. control point must occupy contiguous memory locations. The initial value of ustride is 0.
  439. :type uorder: int
  440. :arg uorder: Specifies the dimension of the control point array in the u axis.
  441. Must be positive. The initial value is 1.
  442. :type v1, v2: Depends on function prototype.
  443. :arg v1, v2: Specify a linear mapping of v, as presented to glEvalCoord2,
  444. to ^, one of the two variables that are evaluated by the equations
  445. specified by this command. Initially, v1 is 0 and v2 is 1.
  446. :type vstride: int
  447. :arg vstride: Specifies the number of floats or float (double)s between the
  448. beginning of control point R and the beginning of control point R ij,
  449. where i and j are the u and v control point(indices, respectively.
  450. This allows control points to be embedded in arbitrary data structures.
  451. The only constraint is that the values for a particular control point must
  452. occupy contiguous memory locations. The initial value of vstride is 0.
  453. :type vorder: int
  454. :arg vorder: Specifies the dimension of the control point array in the v axis.
  455. Must be positive. The initial value is 1.
  456. :type points: :class:`bgl.Buffer` object. Depends on function prototype.
  457. :arg points: Specifies a pointer to the array of control points.
  458. .. function:: glMapGrid (un, u1,u2 ,vn, v1, v2):
  459. B{glMapGrid1d, glMapGrid1f, glMapGrid2d, glMapGrid2f}
  460. Define a one- or two-dimensional mesh
  461. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glMapGrid.xml>`__
  462. :type un: int
  463. :arg un: Specifies the number of partitions in the grid range interval
  464. [u1, u2]. Must be positive.
  465. :type u1, u2: Depends on function prototype.
  466. :arg u1, u2: Specify the mappings for integer grid domain values i=0 and i=un.
  467. :type vn: int
  468. :arg vn: Specifies the number of partitions in the grid range interval
  469. [v1, v2] (glMapGrid2 only).
  470. :type v1, v2: Depends on function prototype.
  471. :arg v1, v2: Specify the mappings for integer grid domain values j=0 and j=vn
  472. (glMapGrid2 only).
  473. .. function:: glMaterial (face, pname, params):
  474. Specify material parameters for the lighting model.
  475. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glMaterial.xml>`__
  476. :type face: Enumerated constant
  477. :arg face: Specifies which face or faces are being updated. Must be one of:
  478. :type pname: Enumerated constant
  479. :arg pname: Specifies the single-valued material parameter of the face
  480. or faces that is being updated. Must be GL_SHININESS.
  481. :type params: int
  482. :arg params: Specifies the value that parameter GL_SHININESS will be set to.
  483. If function prototype ends in 'v' specifies a pointer to the value or values that
  484. pname will be set to.
  485. .. function:: glMultMatrix (m):
  486. B{glMultMatrixd, glMultMatrixf}
  487. Multiply the current matrix with the specified matrix
  488. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glMultMatrix.xml>`__
  489. :type m: :class:`bgl.Buffer` object. Depends on function prototype.
  490. :arg m: Points to 16 consecutive values that are used as the elements of a 4x4 column
  491. major matrix.
  492. .. function:: glNormal3 (nx, ny, nz, v):
  493. B{Normal3b, Normal3bv, Normal3d, Normal3dv, Normal3f, Normal3fv, Normal3i, Normal3iv,
  494. Normal3s, Normal3sv}
  495. Set the current normal vector
  496. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glNormal.xml>`__
  497. :type nx, ny, nz: Depends on function prototype. (non - 'v' prototypes only)
  498. :arg nx, ny, nz: Specify the x, y, and z coordinates of the new current normal.
  499. The initial value of the current normal is the unit vector, (0, 0, 1).
  500. :type v: :class:`bgl.Buffer` object. Depends on function prototype. ('v' prototypes)
  501. :arg v: Specifies a pointer to an array of three elements: the x, y, and z coordinates
  502. of the new current normal.
  503. .. function:: glPixelMap (map, mapsize, values):
  504. B{glPixelMapfv, glPixelMapuiv, glPixelMapusv}
  505. Set up pixel transfer maps
  506. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glPixelMap.xml>`__
  507. :type map: Enumerated constant
  508. :arg map: Specifies a symbolic map name.
  509. :type mapsize: int
  510. :arg mapsize: Specifies the size of the map being defined.
  511. :type values: :class:`bgl.Buffer` object. Depends on function prototype.
  512. :arg values: Specifies an array of mapsize values.
  513. .. function:: glPixelStore (pname, param):
  514. B{glPixelStoref, glPixelStorei}
  515. Set pixel storage modes
  516. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glPixelStore.xml>`__
  517. :type pname: Enumerated constant
  518. :arg pname: Specifies the symbolic name of the parameter to be set.
  519. Six values affect the packing of pixel data into memory.
  520. Six more affect the unpacking of pixel data from memory.
  521. :type param: Depends on function prototype.
  522. :arg param: Specifies the value that pname is set to.
  523. .. function:: glPixelTransfer (pname, param):
  524. B{glPixelTransferf, glPixelTransferi}
  525. Set pixel transfer modes
  526. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glPixelTransfer.xml>`__
  527. :type pname: Enumerated constant
  528. :arg pname: Specifies the symbolic name of the pixel transfer parameter to be set.
  529. :type param: Depends on function prototype.
  530. :arg param: Specifies the value that pname is set to.
  531. .. function:: glPointSize(size):
  532. Specify the diameter of rasterized points
  533. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glPointSize.xml>`__
  534. :type size: float
  535. :arg size: Specifies the diameter of rasterized points. The initial value is 1.
  536. .. function:: glPolygonMode(face, mode):
  537. Select a polygon rasterization mode
  538. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glPolygonMode.xml>`__
  539. :type face: Enumerated constant
  540. :arg face: Specifies the polygons that mode applies to.
  541. Must be GL_FRONT for front-facing polygons, GL_BACK for back- facing
  542. polygons, or GL_FRONT_AND_BACK for front- and back-facing polygons.
  543. :type mode: Enumerated constant
  544. :arg mode: Specifies how polygons will be rasterized.
  545. The initial value is GL_FILL for both front- and back- facing polygons.
  546. .. function:: glPolygonOffset(factor, units):
  547. Set the scale and units used to calculate depth values
  548. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glPolygonOffset.xml>`__
  549. :type factor: float
  550. :arg factor: Specifies a scale factor that is used to create a variable depth
  551. offset for each polygon. The initial value is 0.
  552. :type units: float
  553. :arg units: Is multiplied by an implementation-specific value to create a
  554. constant depth offset. The initial value is 0.
  555. .. function:: glRasterPos (x,y,z,w):
  556. B{glRasterPos2d, glRasterPos2f, glRasterPos2i, glRasterPos2s, glRasterPos3d,
  557. glRasterPos3f, glRasterPos3i, glRasterPos3s, glRasterPos4d, glRasterPos4f,
  558. glRasterPos4i, glRasterPos4s, glRasterPos2dv, glRasterPos2fv, glRasterPos2iv,
  559. glRasterPos2sv, glRasterPos3dv, glRasterPos3fv, glRasterPos3iv, glRasterPos3sv,
  560. glRasterPos4dv, glRasterPos4fv, glRasterPos4iv, glRasterPos4sv}
  561. Specify the raster position for pixel operations
  562. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glRasterPos.xml>`__
  563. :type x, y, z, w: Depends on function prototype. (z and w for '3' and '4' prototypes only)
  564. :arg x, y, z, w: Specify the x,y,z, and w object coordinates (if present) for the
  565. raster position. If function prototype ends in 'v' specifies a pointer to an array of two,
  566. three, or four elements, specifying x, y, z, and w coordinates, respectively.
  567. .. note::
  568. If you are drawing to the 3d view with a Scriptlink of a space handler
  569. the zoom level of the panels will scale the glRasterPos by the view matrix.
  570. so a X of 10 will not always offset 10 pixels as you would expect.
  571. To work around this get the scale value of the view matrix and use it to scale your pixel values.
  572. .. code-block:: python
  573. import bgl
  574. xval, yval= 100, 40
  575. # Get the scale of the view matrix
  576. view_matrix = bgl.Buffer(bgl.GL_FLOAT, 16)
  577. bgl.glGetFloatv(bgl.GL_MODELVIEW_MATRIX, view_matrix)
  578. f = 1.0 / view_matrix[0]
  579. # Instead of the usual glRasterPos2i(xval, yval)
  580. bgl.glRasterPos2f(xval * f, yval * f)
  581. .. function:: glReadBuffer(mode):
  582. Select a color buffer source for pixels.
  583. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glReadBuffer.xml>`__
  584. :type mode: Enumerated constant
  585. :arg mode: Specifies a color buffer.
  586. .. function:: glReadPixels(x, y, width, height, format, type, pixels):
  587. Read a block of pixels from the frame buffer
  588. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glReadPixels.xml>`__
  589. :type x, y: int
  590. :arg x, y: Specify the window coordinates of the first pixel that is read
  591. from the frame buffer. This location is the lower left corner of a rectangular
  592. block of pixels.
  593. :type width, height: int
  594. :arg width, height: Specify the dimensions of the pixel rectangle. width and
  595. height of one correspond to a single pixel.
  596. :type format: Enumerated constant
  597. :arg format: Specifies the format of the pixel data.
  598. :type type: Enumerated constant
  599. :arg type: Specifies the data type of the pixel data.
  600. :type pixels: :class:`bgl.Buffer` object
  601. :arg pixels: Returns the pixel data.
  602. .. function:: glRect (x1,y1,x2,y2,v1,v2):
  603. B{glRectd, glRectf, glRecti, glRects, glRectdv, glRectfv, glRectiv, glRectsv}
  604. Draw a rectangle
  605. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glRect.xml>`__
  606. :type x1, y1: Depends on function prototype. (for non 'v' prototypes only)
  607. :arg x1, y1: Specify one vertex of a rectangle
  608. :type x2, y2: Depends on function prototype. (for non 'v' prototypes only)
  609. :arg x2, y2: Specify the opposite vertex of the rectangle
  610. :type v1, v2: Depends on function prototype. (for 'v' prototypes only)
  611. :arg v1, v2: Specifies a pointer to one vertex of a rectangle and the pointer
  612. to the opposite vertex of the rectangle
  613. .. function:: glRotate (angle, x, y, z):
  614. B{glRotated, glRotatef}
  615. Multiply the current matrix by a rotation matrix
  616. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glRotate.xml>`__
  617. :type angle: Depends on function prototype.
  618. :arg angle: Specifies the angle of rotation in degrees.
  619. :type x, y, z: Depends on function prototype.
  620. :arg x, y, z: Specify the x, y, and z coordinates of a vector respectively.
  621. .. function:: glScale (x,y,z):
  622. B{glScaled, glScalef}
  623. Multiply the current matrix by a general scaling matrix
  624. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glScale.xml>`__
  625. :type x, y, z: Depends on function prototype.
  626. :arg x, y, z: Specify scale factors along the x, y, and z axes, respectively.
  627. .. function:: glScissor(x,y,width,height):
  628. Define the scissor box
  629. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glScissor.xml>`__
  630. :type x, y: int
  631. :arg x, y: Specify the lower left corner of the scissor box. Initially (0, 0).
  632. :type width, height: int
  633. :arg width height: Specify the width and height of the scissor box. When a
  634. GL context is first attached to a window, width and height are set to the
  635. dimensions of that window.
  636. .. function:: glStencilFunc(func, ref, mask):
  637. Set function and reference value for stencil testing
  638. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man/docbook4/xhtml/glStencilFunc.xml>`__
  639. :type func: Enumerated constant
  640. :arg func: Specifies the test function.
  641. :type ref: int
  642. :arg ref: Specifies the reference value for the stencil test. ref is clamped
  643. to the range [0,2n-1], where n is the number of bitplanes in the stencil
  644. buffer. The initial value is 0.
  645. :type mask: unsigned int
  646. :arg mask: Specifies a mask that is ANDed with both the reference value and
  647. the stored stencil value when the test is done. The initial value is all 1's.
  648. .. function:: glStencilMask(mask):
  649. Control the writing of individual bits in the stencil planes
  650. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glStencilMask.xml>`__
  651. :type mask: unsigned int
  652. :arg mask: Specifies a bit mask to enable and disable writing of individual bits
  653. in the stencil planes. Initially, the mask is all 1's.
  654. .. function:: glStencilOp(fail, zfail, zpass):
  655. Set stencil test actions
  656. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glStencilOp.xml>`__
  657. :type fail: Enumerated constant
  658. :arg fail: Specifies the action to take when the stencil test fails.
  659. The initial value is GL_KEEP.
  660. :type zfail: Enumerated constant
  661. :arg zfail: Specifies the stencil action when the stencil test passes, but the
  662. depth test fails. zfail accepts the same symbolic constants as fail.
  663. The initial value is GL_KEEP.
  664. :type zpass: Enumerated constant
  665. :arg zpass: Specifies the stencil action when both the stencil test and the
  666. depth test pass, or when the stencil test passes and either there is no
  667. depth buffer or depth testing is not enabled. zpass accepts the same
  668. symbolic constants
  669. as fail. The initial value is GL_KEEP.
  670. .. function:: glTexCoord (s,t,r,q,v):
  671. B{glTexCoord1d, glTexCoord1f, glTexCoord1i, glTexCoord1s, glTexCoord2d, glTexCoord2f,
  672. glTexCoord2i, glTexCoord2s, glTexCoord3d, glTexCoord3f, glTexCoord3i, glTexCoord3s,
  673. glTexCoord4d, glTexCoord4f, glTexCoord4i, glTexCoord4s, glTexCoord1dv, glTexCoord1fv,
  674. glTexCoord1iv, glTexCoord1sv, glTexCoord2dv, glTexCoord2fv, glTexCoord2iv,
  675. glTexCoord2sv, glTexCoord3dv, glTexCoord3fv, glTexCoord3iv, glTexCoord3sv,
  676. glTexCoord4dv, glTexCoord4fv, glTexCoord4iv, glTexCoord4sv}
  677. Set the current texture coordinates
  678. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glTexCoord.xml>`__
  679. :type s, t, r, q: Depends on function prototype. (r and q for '3' and '4' prototypes only)
  680. :arg s, t, r, q: Specify s, t, r, and q texture coordinates. Not all parameters are
  681. present in all forms of the command.
  682. :type v: :class:`bgl.Buffer` object. Depends on function prototype. (for 'v' prototypes only)
  683. :arg v: Specifies a pointer to an array of one, two, three, or four elements,
  684. which in turn specify the s, t, r, and q texture coordinates.
  685. .. function:: glTexEnv (target, pname, param):
  686. B{glTextEnvf, glTextEnvi, glTextEnvfv, glTextEnviv}
  687. Set texture environment parameters
  688. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glTexEnv.xml>`__
  689. :type target: Enumerated constant
  690. :arg target: Specifies a texture environment. Must be GL_TEXTURE_ENV.
  691. :type pname: Enumerated constant
  692. :arg pname: Specifies the symbolic name of a single-valued texture environment
  693. parameter. Must be GL_TEXTURE_ENV_MODE.
  694. :type param: Depends on function prototype.
  695. :arg param: Specifies a single symbolic constant. If function prototype ends in 'v'
  696. specifies a pointer to a parameter array that contains either a single
  697. symbolic constant or an RGBA color
  698. .. function:: glTexGen (coord, pname, param):
  699. B{glTexGend, glTexGenf, glTexGeni, glTexGendv, glTexGenfv, glTexGeniv}
  700. Control the generation of texture coordinates
  701. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glTexGen.xml>`__
  702. :type coord: Enumerated constant
  703. :arg coord: Specifies a texture coordinate.
  704. :type pname: Enumerated constant
  705. :arg pname: Specifies the symbolic name of the texture- coordinate generation function.
  706. :type param: Depends on function prototype.
  707. :arg param: Specifies a single-valued texture generation parameter.
  708. If function prototype ends in 'v' specifies a pointer to an array of texture
  709. generation parameters. If pname is GL_TEXTURE_GEN_MODE, then the array must
  710. contain a single symbolic constant. Otherwise, params holds the coefficients
  711. for the texture-coordinate generation function specified by pname.
  712. .. function:: glTexImage1D(target, level, internalformat, width, border, format, type, pixels):
  713. Specify a one-dimensional texture image
  714. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glTexImage1D.xml>`__
  715. :type target: Enumerated constant
  716. :arg target: Specifies the target texture.
  717. :type level: int
  718. :arg level: Specifies the level-of-detail number. Level 0 is the base image level.
  719. Level n is the nth mipmap reduction image.
  720. :type internalformat: int
  721. :arg internalformat: Specifies the number of color components in the texture.
  722. :type width: int
  723. :arg width: Specifies the width of the texture image. Must be 2n+2(border)
  724. for some integer n. All implementations support texture images that are
  725. at least 64 texels wide. The height of the 1D texture image is 1.
  726. :type border: int
  727. :arg border: Specifies the width of the border. Must be either 0 or 1.
  728. :type format: Enumerated constant
  729. :arg format: Specifies the format of the pixel data.
  730. :type type: Enumerated constant
  731. :arg type: Specifies the data type of the pixel data.
  732. :type pixels: :class:`bgl.Buffer` object.
  733. :arg pixels: Specifies a pointer to the image data in memory.
  734. .. function:: glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels):
  735. Specify a two-dimensional texture image
  736. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glTexImage2D.xml>`__
  737. :type target: Enumerated constant
  738. :arg target: Specifies the target texture.
  739. :type level: int
  740. :arg level: Specifies the level-of-detail number. Level 0 is the base image level.
  741. Level n is the nth mipmap reduction image.
  742. :type internalformat: int
  743. :arg internalformat: Specifies the number of color components in the texture.
  744. :type width: int
  745. :arg width: Specifies the width of the texture image. Must be 2n+2(border)
  746. for some integer n. All implementations support texture images that are at
  747. least 64 texels wide.
  748. :type height: int
  749. :arg height: Specifies the height of the texture image. Must be 2m+2(border) for
  750. some integer m. All implementations support texture images that are at
  751. least 64 texels high.
  752. :type border: int
  753. :arg border: Specifies the width of the border. Must be either 0 or 1.
  754. :type format: Enumerated constant
  755. :arg format: Specifies the format of the pixel data.
  756. :type type: Enumerated constant
  757. :arg type: Specifies the data type of the pixel data.
  758. :type pixels: :class:`bgl.Buffer` object.
  759. :arg pixels: Specifies a pointer to the image data in memory.
  760. .. function:: glTexParameter (target, pname, param):
  761. B{glTexParameterf, glTexParameteri, glTexParameterfv, glTexParameteriv}
  762. Set texture parameters
  763. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glTexParameter.xml>`__
  764. :type target: Enumerated constant
  765. :arg target: Specifies the target texture.
  766. :type pname: Enumerated constant
  767. :arg pname: Specifies the symbolic name of a single-valued texture parameter.
  768. :type param: Depends on function prototype.
  769. :arg param: Specifies the value of pname. If function prototype ends in 'v' specifies
  770. a pointer to an array where the value or values of pname are stored.
  771. .. function:: glTranslate (x, y, z):
  772. B{glTranslatef, glTranslated}
  773. Multiply the current matrix by a translation matrix
  774. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glTranslate.xml>`__
  775. :type x, y, z: Depends on function prototype.
  776. :arg x, y, z: Specify the x, y, and z coordinates of a translation vector.
  777. .. function:: glViewport(x,y,width,height):
  778. Set the viewport
  779. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glViewport.xml>`__
  780. :type x, y: int
  781. :arg x, y: Specify the lower left corner of the viewport rectangle,
  782. in pixels. The initial value is (0,0).
  783. :type width, height: int
  784. :arg width, height: Specify the width and height of the viewport. When a GL
  785. context is first attached to a window, width and height are set to the
  786. dimensions of that window.
  787. .. function:: glUseProgram(program):
  788. Installs a program object as part of current rendering state
  789. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glUseProgram.xml>`__
  790. :type program: int
  791. :arg program: Specifies the handle of the program object whose executables are to be used as part of current rendering state.
  792. .. function:: glValidateProgram(program):
  793. Validates a program object
  794. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glValidateProgram.xml>`__
  795. :type program: int
  796. :arg program: Specifies the handle of the program object to be validated.
  797. .. function:: glLinkProgram(program):
  798. Links a program object.
  799. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glLinkProgram.xml>`__
  800. :type program: int
  801. :arg program: Specifies the handle of the program object to be linked.
  802. .. function:: glActiveTexture(texture):
  803. Select active texture unit.
  804. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glActiveTexture.xml>`__
  805. :type texture: int
  806. :arg texture: Constant in ``GL_TEXTURE0`` 0 - 8
  807. .. function:: glAttachShader(program, shader):
  808. Attaches a shader object to a program object.
  809. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glAttachShader.xml>`__
  810. :type program: int
  811. :arg program: Specifies the program object to which a shader object will be attached.
  812. :type shader: int
  813. :arg shader: Specifies the shader object that is to be attached.
  814. .. function:: glCompileShader(shader):
  815. Compiles a shader object.
  816. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glCompileShader.xml>`__
  817. :type shader: int
  818. :arg shader: Specifies the shader object to be compiled.
  819. .. function:: glCreateProgram():
  820. Creates a program object
  821. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glCreateProgram.xml>`__
  822. :rtype: int
  823. :return: The new program or zero if an error occurs.
  824. .. function:: glCreateShader(shaderType):
  825. Creates a shader object.
  826. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glCreateShader.xml>`__
  827. :type shaderType: Specifies the type of shader to be created.
  828. Must be one of ``GL_VERTEX_SHADER``,
  829. ``GL_TESS_CONTROL_SHADER``,
  830. ``GL_TESS_EVALUATION_SHADER``,
  831. ``GL_GEOMETRY_SHADER``,
  832. or ``GL_FRAGMENT_SHADER``.
  833. :arg shaderType:
  834. :rtype: int
  835. :return: 0 if an error occurs.
  836. .. function:: glDeleteProgram(program):
  837. Deletes a program object.
  838. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glDeleteProgram.xml>`__
  839. :type program: int
  840. :arg program: Specifies the program object to be deleted.
  841. .. function:: glDeleteShader(shader):
  842. Deletes a shader object.
  843. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glDeleteShader.xml>`__
  844. :type shader: int
  845. :arg shader: Specifies the shader object to be deleted.
  846. .. function:: glDetachShader(program, shader):
  847. Detaches a shader object from a program object to which it is attached.
  848. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glDetachShader.xml>`__
  849. :type program: int
  850. :arg program: Specifies the program object from which to detach the shader object.
  851. :type shader: int
  852. :arg shader: pecifies the program object from which to detach the shader object.
  853. .. function:: glGetAttachedShaders(program, maxCount, count, shaders):
  854. Returns the handles of the shader objects attached to a program object.
  855. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetAttachedShaders.xml>`__
  856. :type program: int
  857. :arg program: Specifies the program object to be queried.
  858. :type maxCount: int
  859. :arg maxCount: Specifies the size of the array for storing the returned object names.
  860. :type count: :class:`bgl.Buffer` int buffer.
  861. :arg count: Returns the number of names actually returned in objects.
  862. :type shaders: :class:`bgl.Buffer` int buffer.
  863. :arg shaders: Specifies an array that is used to return the names of attached shader objects.
  864. .. function:: glGetProgramInfoLog(program, maxLength, length, infoLog):
  865. Returns the information log for a program object.
  866. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetProgramInfoLog.xml>`__
  867. :type program: int
  868. :arg program: Specifies the program object whose information log is to be queried.
  869. :type maxLength: int
  870. :arg maxLength: Specifies the size of the character buffer for storing the returned information log.
  871. :type length: :class:`bgl.Buffer` int buffer.
  872. :arg length: Returns the length of the string returned in **infoLog** (excluding the null terminator).
  873. :type infoLog: :class:`bgl.Buffer` char buffer.
  874. :arg infoLog: Specifies an array of characters that is used to return the information log.
  875. .. function:: glGetShaderInfoLog(program, maxLength, length, infoLog):
  876. Returns the information log for a shader object.
  877. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetShaderInfoLog.xml>`__
  878. :type shader: int
  879. :arg shader: Specifies the shader object whose information log is to be queried.
  880. :type maxLength: int
  881. :arg maxLength: Specifies the size of the character buffer for storing the returned information log.
  882. :type length: :class:`bgl.Buffer` int buffer.
  883. :arg length: Returns the length of the string returned in **infoLog** (excluding the null terminator).
  884. :type infoLog: :class:`bgl.Buffer` char buffer.
  885. :arg infoLog: Specifies an array of characters that is used to return the information log.
  886. .. function:: glGetProgramiv(program, pname, params):
  887. Returns a parameter from a program object.
  888. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetProgram.xml>`__
  889. :type program: int
  890. :arg program: Specifies the program object to be queried.
  891. :type pname: int
  892. :arg pname: Specifies the object parameter.
  893. :type params: :class:`bgl.Buffer` int buffer.
  894. :arg params: Returns the requested object parameter.
  895. .. function:: glIsShader(shader):
  896. Determines if a name corresponds to a shader object.
  897. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glIsShader.xml>`__
  898. :type shader: int
  899. :arg shader: Specifies a potential shader object.
  900. .. function:: glIsProgram(program):
  901. Determines if a name corresponds to a program object
  902. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glIsProgram.xml>`__
  903. :type program: int
  904. :arg program: Specifies a potential program object.
  905. .. function:: glGetShaderSource(shader, bufSize, length, source):
  906. Returns the source code string from a shader object
  907. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man2/xhtml/glGetShaderSource.xml>`__
  908. :type shader: int
  909. :arg shader: Specifies the shader object to be queried.
  910. :type bufSize: int
  911. :arg bufSize: Specifies the size of the character buffer for storing the returned source code string.
  912. :type length: :class:`bgl.Buffer` int buffer.
  913. :arg length: Returns the length of the string returned in source (excluding the null terminator).
  914. :type source: :class:`bgl.Buffer` char.
  915. :arg source: Specifies an array of characters that is used to return the source code string.
  916. .. function:: glShaderSource(shader, shader_string):
  917. Replaces the source code in a shader object.
  918. .. seealso:: `OpenGL Docs <https://www.opengl.org/sdk/docs/man/html/glShaderSource.xhtml>`__
  919. :type shader: int
  920. :arg shader: Specifies the handle of the shader object whose source code is to be replaced.
  921. :type shader_string: string
  922. :arg shader_string: The shader string.
  923. .. class:: Buffer
  924. The Buffer object is simply a block of memory that is delineated and initialized by the
  925. user. Many OpenGL functions return data to a C-style pointer, however, because this
  926. is not possible in python the Buffer object can be used to this end. Wherever pointer
  927. notation is used in the OpenGL functions the Buffer object can be used in it's bgl
  928. wrapper. In some instances the Buffer object will need to be initialized with the template
  929. parameter, while in other instances the user will want to create just a blank buffer
  930. which will be zeroed by default.
  931. .. code-block:: python
  932. import bgl
  933. myByteBuffer = bgl.Buffer(bgl.GL_BYTE, [32, 32])
  934. bgl.glGetPolygonStipple(myByteBuffer)
  935. print(myByteBuffer.dimensions)
  936. print(myByteBuffer.to_list())
  937. sliceBuffer = myByteBuffer[0:16]
  938. print(sliceBuffer)
  939. .. attribute:: dimensions
  940. The number of dimensions of the Buffer.
  941. .. method:: to_list()
  942. The contents of the Buffer as a python list.
  943. .. method:: __init__(type, dimensions, template = None):
  944. This will create a new Buffer object for use with other bgl OpenGL commands.
  945. Only the type of argument to store in the buffer and the dimensions of the buffer
  946. are necessary. Buffers are zeroed by default unless a template is supplied, in
  947. which case the buffer is initialized to the template.
  948. :type type: int
  949. :arg type: The format to store data in. The type should be one of
  950. GL_BYTE, GL_SHORT, GL_INT, or GL_FLOAT.
  951. :type dimensions: An int or sequence object specifying the dimensions of the buffer.
  952. :arg dimensions: If the dimensions are specified as an int a linear array will
  953. be created for the buffer. If a sequence is passed for the dimensions, the buffer
  954. becomes n-Dimensional, where n is equal to the number of parameters passed in the
  955. sequence. Example: [256,2] is a two- dimensional buffer while [256,256,4] creates
  956. a three- dimensional buffer. You can think of each additional dimension as a sub-item
  957. of the dimension to the left. i.e. [10,2] is a 10 element array each with 2 sub-items.
  958. [(0,0), (0,1), (1,0), (1,1), (2,0), ...] etc.
  959. :type template: A python sequence object (optional)
  960. :arg template: A sequence of matching dimensions which will be used to initialize
  961. the Buffer. If a template is not passed in all fields will be initialized to 0.
  962. :rtype: Buffer object
  963. :return: The newly created buffer as a PyObject.