API Docs for: 2.2.1
Show:

File: pixi/renderers/webgl/WebGLRenderer.hx

  1. package pixi.renderers.webgl;
  2. import pixi.renderers.webgl.utils.WebGLSpriteBatch;
  3. import pixi.renderers.webgl.utils.WebGLMaskManager;
  4. import pixi.renderers.webgl.utils.WebGLFilterManager;
  5. import pixi.renderers.webgl.utils.WebGLStencilManager;
  6. import pixi.renderers.webgl.utils.WebGLBlendModeManager;
  7. import pixi.renderers.webgl.utils.WebGLShaderManager;
  8. import pixi.utils.Event;
  9. import pixi.utils.Detector.RenderingOptions;
  10. import pixi.DomDefinitions;
  11. import pixi.textures.Texture;
  12. import pixi.geom.Point;
  13. import pixi.display.DisplayObject;
  14. import pixi.display.Stage;
  15. @:native("PIXI.WebGLRenderer")
  16. extern class WebGLRenderer implements IRenderer {
  17. /**
  18. * The WebGLRenderer draws the stage and all its content onto a webGL enabled canvas. This renderer
  19. * should be used for browsers that support webGL. This Render works by automatically managing webGLBatchs.
  20. * So no need for Sprite Batches or Sprite Clouds.
  21. * Don't forget to add the view to your DOM or you will not see anything :)
  22. *
  23. * @class WebGLRenderer
  24. * @constructor
  25. * @param [width=0] {Float} the width of the canvas view
  26. * @param [height=0] {Float} the height of the canvas view
  27. * @param [options] {Object} The optional renderer parameters
  28. * @param [options.view] {HTMLCanvasElement} the canvas to use as a view, optional
  29. * @param [options.transparent=false] {Bool} If the render view is transparent, default false
  30. * @param [options.antialias=false] {Bool} sets antialias (only applicable in chrome at the moment)
  31. * @param [options.preserveDrawingBuffer=false] {Bool} enables drawing buffer preservation, enable this if you need to call toDataUrl on the webgl context
  32. * @param [options.resolution=1] {Float} the resolution of the renderer retina would be 2
  33. */
  34. function new(width:Float, height:Float, ?options:RenderingOptions);
  35. /**
  36. * @property type
  37. * @type Int
  38. */
  39. var type:Int;
  40. /**
  41. * The resolution of the renderer
  42. *
  43. * @property resolution
  44. * @type Float
  45. * @default 1
  46. */
  47. var resolution:Float;
  48. /**
  49. * Whether the render view is transparent
  50. *
  51. * @property transparent
  52. * @type Bool
  53. */
  54. var transparent:Bool;
  55. /**
  56. * The value of the preserveDrawingBuffer flag affects whether or not the contents of the stencil buffer is retained after rendering.
  57. *
  58. * @property preserveDrawingBuffer
  59. * @type Bool
  60. */
  61. var preserveDrawingBuffer:Bool;
  62. /**
  63. * This sets if the WebGLRenderer will clear the context texture or not before the new render pass. If true:
  64. * If the Stage is NOT transparent, Pixi will clear to alpha (0, 0, 0, 0).
  65. * If the Stage is transparent, Pixi will clear to the target Stage's background color.
  66. * Disable this by setting this to false. For example: if your game has a canvas filling background image, you often don't need this set.
  67. *
  68. * @property clearBeforeRender
  69. * @type Bool
  70. * @default
  71. */
  72. var clearBeforeRender:Bool;
  73. /**
  74. * The width of the canvas view
  75. *
  76. * @property width
  77. * @type Float
  78. * @default 800
  79. */
  80. var width:Float;
  81. /**
  82. * The height of the canvas view
  83. *
  84. * @property height
  85. * @type Float
  86. * @default 600
  87. */
  88. var height:Float;
  89. /**
  90. * The canvas element that everything is drawn to
  91. *
  92. * @property view
  93. * @type HTMLCanvasElement
  94. */
  95. var view:CanvasElement;
  96. /**
  97. * @property contextLostBound
  98. * @type Function
  99. */
  100. var contextLostBound:Event -> Void;
  101. /**
  102. * @property contextRestoredBound
  103. * @type Function
  104. */
  105. var contextRestoredBound:Event -> Void;
  106. /**
  107. * @property projection
  108. * @type Point
  109. */
  110. var projection:Point;
  111. /**
  112. * @property offset
  113. * @type Point
  114. */
  115. var offset:Point;
  116. /**
  117. * Deals with managing the shader programs and their attribs
  118. * @property shaderManager
  119. * @type WebGLShaderManager
  120. */
  121. var shaderManager:WebGLShaderManager;
  122. /**
  123. * Manages the rendering of sprites
  124. * @property spriteBatch
  125. * @type WebGLSpriteBatch
  126. */
  127. var spriteBatch:WebGLSpriteBatch;
  128. /**
  129. * Manages the masks using the stencil buffer
  130. * @property maskManager
  131. * @type WebGLMaskManager
  132. */
  133. var maskManager:WebGLMaskManager;
  134. /**
  135. * Manages the filters
  136. * @property filterManager
  137. * @type WebGLFilterManager
  138. */
  139. var filterManager:WebGLFilterManager;
  140. /**
  141. * Manages the stencil buffer
  142. * @property stencilManager
  143. * @type WebGLStencilManager
  144. */
  145. var stencilManager:WebGLStencilManager;
  146. /**
  147. * Manages the blendModes
  148. * @property blendModeManager
  149. * @type WebGLBlendModeManager
  150. */
  151. var blendModeManager:WebGLBlendModeManager;
  152. /**
  153. * TODO remove
  154. * @property renderSession
  155. * @type Dynamic
  156. */
  157. var renderSession:Dynamic;
  158. /**
  159. * @method initContext
  160. */
  161. function initContext():Void;
  162. /**
  163. * Renders the stage to its webGL view
  164. *
  165. * @method render
  166. * @param stage {Stage} the Stage element to be rendered
  167. */
  168. function render(stage:Stage):Void;
  169. /**
  170. * Renders a Display Object.
  171. *
  172. * @method renderDisplayObject
  173. * @param displayObject {DisplayObject} The DisplayObject to render
  174. * @param projection {Point} The projection
  175. * @param buffer {Array} a standard WebGL buffer
  176. */
  177. function renderDisplayObject(displayObject:DisplayObject, projection:Point, buffer:Array<Dynamic>):Void;
  178. /**
  179. * resizes the webGL view to the specified width and height
  180. *
  181. * @method resize
  182. * @param width {Float} the new width of the webGL view
  183. * @param height {Float} the new height of the webGL view
  184. */
  185. function resize(width:Float, height:Float):Void;
  186. /**
  187. * Updates and Creates a WebGL texture for the renderers context.
  188. *
  189. * @method updateTexture
  190. * @param texture {Texture} the texture to update
  191. */
  192. function updateTexture(texture:Texture):Texture;
  193. /**
  194. * Removes everything from the renderer (event listeners, spritebatch, etc...)
  195. *
  196. * @method destroy
  197. */
  198. function destroy():Void;
  199. /**
  200. * Maps Pixi blend modes to WebGL blend modes.
  201. *
  202. * @method mapBlendModes
  203. */
  204. function mapBlendModes():Void;
  205. }