diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 4956802..44f1323 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -5,7 +5,9 @@ /** * A set of functions used by the webGL renderer to draw the primitive graphics data * - * @class CanvasGraphics + * @class WebGLGraphics + * @private + * @static */ PIXI.WebGLGraphics = function() { @@ -19,7 +21,7 @@ * @private * @method renderGraphics * @param graphics {Graphics} - * @param projection {Object} + * @param renderSession {Object} */ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset) { @@ -91,7 +93,8 @@ * @static * @private * @method updateGraphics - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to update + * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { @@ -145,7 +148,7 @@ * @static * @private * @method buildRectangle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) @@ -214,7 +217,7 @@ * @static * @private * @method buildCircle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw * @param webGLData {Object} */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) @@ -287,7 +290,7 @@ * @static * @private * @method buildLine - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) @@ -497,7 +500,7 @@ * @static * @private * @method buildPoly - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData) diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 4956802..44f1323 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -5,7 +5,9 @@ /** * A set of functions used by the webGL renderer to draw the primitive graphics data * - * @class CanvasGraphics + * @class WebGLGraphics + * @private + * @static */ PIXI.WebGLGraphics = function() { @@ -19,7 +21,7 @@ * @private * @method renderGraphics * @param graphics {Graphics} - * @param projection {Object} + * @param renderSession {Object} */ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset) { @@ -91,7 +93,8 @@ * @static * @private * @method updateGraphics - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to update + * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { @@ -145,7 +148,7 @@ * @static * @private * @method buildRectangle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) @@ -214,7 +217,7 @@ * @static * @private * @method buildCircle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw * @param webGLData {Object} */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) @@ -287,7 +290,7 @@ * @static * @private * @method buildLine - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) @@ -497,7 +500,7 @@ * @static * @private * @method buildPoly - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData) diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index a929c8f..12a7849 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -2,6 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ + +/** +* @class WebGLMaskManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLMaskManager = function(gl) { this.maskStack = []; @@ -10,11 +17,22 @@ this.setContext(gl); }; +/** +* Sets the drawing context to the one given in parameter +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLMaskManager.prototype.setContext = function(gl) { this.gl = gl; }; +/** +* Applies the Mask and adds it to the current filter stack +* @method pushMask +* @param maskData {Array} +* @param renderSession {RenderSession} +*/ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession) { var gl = this.gl; @@ -39,6 +57,12 @@ gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popMask +* +* @param renderSession {RenderSession} TODO-Alvin +*/ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession) { var gl = this.gl; @@ -62,6 +86,10 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLMaskManager.prototype.destroy = function() { this.maskStack = null; diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 4956802..44f1323 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -5,7 +5,9 @@ /** * A set of functions used by the webGL renderer to draw the primitive graphics data * - * @class CanvasGraphics + * @class WebGLGraphics + * @private + * @static */ PIXI.WebGLGraphics = function() { @@ -19,7 +21,7 @@ * @private * @method renderGraphics * @param graphics {Graphics} - * @param projection {Object} + * @param renderSession {Object} */ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset) { @@ -91,7 +93,8 @@ * @static * @private * @method updateGraphics - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to update + * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { @@ -145,7 +148,7 @@ * @static * @private * @method buildRectangle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) @@ -214,7 +217,7 @@ * @static * @private * @method buildCircle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw * @param webGLData {Object} */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) @@ -287,7 +290,7 @@ * @static * @private * @method buildLine - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) @@ -497,7 +500,7 @@ * @static * @private * @method buildPoly - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData) diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index a929c8f..12a7849 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -2,6 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ + +/** +* @class WebGLMaskManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLMaskManager = function(gl) { this.maskStack = []; @@ -10,11 +17,22 @@ this.setContext(gl); }; +/** +* Sets the drawing context to the one given in parameter +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLMaskManager.prototype.setContext = function(gl) { this.gl = gl; }; +/** +* Applies the Mask and adds it to the current filter stack +* @method pushMask +* @param maskData {Array} +* @param renderSession {RenderSession} +*/ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession) { var gl = this.gl; @@ -39,6 +57,12 @@ gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popMask +* +* @param renderSession {RenderSession} TODO-Alvin +*/ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession) { var gl = this.gl; @@ -62,6 +86,10 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLMaskManager.prototype.destroy = function() { this.maskStack = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index 5355259..17e5937 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -2,6 +2,12 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** +* @class WebGLShaderManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLShaderManager = function(gl) { @@ -18,6 +24,13 @@ //this.stripShader = new PIXI.StripShader(gl); }; + +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +*/ PIXI.WebGLShaderManager.prototype.setContext = function(gl) { this.gl = gl; @@ -36,6 +49,11 @@ }; +/** +* Initialises the context and the properties +* @method setAttribs +* @param attribs {Array} TODO-Alvin +*/ PIXI.WebGLShaderManager.prototype.setAttribs = function(attribs) { // reset temp state @@ -77,6 +95,11 @@ // console.log(this.tempAttribState) }; +/** +* TODO-Alvin +* @method activateShader +* @param shader {Object} the shader that is going to be activated +*/ PIXI.WebGLShaderManager.prototype.activateShader = function(shader) { //if(this.currentShader == shader)return; @@ -90,6 +113,10 @@ }; +/** +* Triggers the primitive shader +* @method activatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function() { var gl = this.gl; @@ -100,6 +127,10 @@ }; +/** +* Disable the primitive shader +* @method deactivatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() { var gl = this.gl; @@ -109,6 +140,10 @@ this.setAttribs(this.defaultShader.attributes); }; +/** +* Destroys +* @method destroy +*/ PIXI.WebGLShaderManager.prototype.destroy = function() { this.attribState = null; diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 4956802..44f1323 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -5,7 +5,9 @@ /** * A set of functions used by the webGL renderer to draw the primitive graphics data * - * @class CanvasGraphics + * @class WebGLGraphics + * @private + * @static */ PIXI.WebGLGraphics = function() { @@ -19,7 +21,7 @@ * @private * @method renderGraphics * @param graphics {Graphics} - * @param projection {Object} + * @param renderSession {Object} */ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset) { @@ -91,7 +93,8 @@ * @static * @private * @method updateGraphics - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to update + * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { @@ -145,7 +148,7 @@ * @static * @private * @method buildRectangle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) @@ -214,7 +217,7 @@ * @static * @private * @method buildCircle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw * @param webGLData {Object} */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) @@ -287,7 +290,7 @@ * @static * @private * @method buildLine - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) @@ -497,7 +500,7 @@ * @static * @private * @method buildPoly - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData) diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index a929c8f..12a7849 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -2,6 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ + +/** +* @class WebGLMaskManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLMaskManager = function(gl) { this.maskStack = []; @@ -10,11 +17,22 @@ this.setContext(gl); }; +/** +* Sets the drawing context to the one given in parameter +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLMaskManager.prototype.setContext = function(gl) { this.gl = gl; }; +/** +* Applies the Mask and adds it to the current filter stack +* @method pushMask +* @param maskData {Array} +* @param renderSession {RenderSession} +*/ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession) { var gl = this.gl; @@ -39,6 +57,12 @@ gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popMask +* +* @param renderSession {RenderSession} TODO-Alvin +*/ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession) { var gl = this.gl; @@ -62,6 +86,10 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLMaskManager.prototype.destroy = function() { this.maskStack = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index 5355259..17e5937 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -2,6 +2,12 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** +* @class WebGLShaderManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLShaderManager = function(gl) { @@ -18,6 +24,13 @@ //this.stripShader = new PIXI.StripShader(gl); }; + +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +*/ PIXI.WebGLShaderManager.prototype.setContext = function(gl) { this.gl = gl; @@ -36,6 +49,11 @@ }; +/** +* Initialises the context and the properties +* @method setAttribs +* @param attribs {Array} TODO-Alvin +*/ PIXI.WebGLShaderManager.prototype.setAttribs = function(attribs) { // reset temp state @@ -77,6 +95,11 @@ // console.log(this.tempAttribState) }; +/** +* TODO-Alvin +* @method activateShader +* @param shader {Object} the shader that is going to be activated +*/ PIXI.WebGLShaderManager.prototype.activateShader = function(shader) { //if(this.currentShader == shader)return; @@ -90,6 +113,10 @@ }; +/** +* Triggers the primitive shader +* @method activatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function() { var gl = this.gl; @@ -100,6 +127,10 @@ }; +/** +* Disable the primitive shader +* @method deactivatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() { var gl = this.gl; @@ -109,6 +140,10 @@ this.setAttribs(this.defaultShader.attributes); }; +/** +* Destroys +* @method destroy +*/ PIXI.WebGLShaderManager.prototype.destroy = function() { this.attribState = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 672de62..bf151bf 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -8,11 +8,30 @@ * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/WebGLSpriteBatch.java */ + /** + * + * @class WebGLSpriteBatch + * @private + * @constructor + * @param gl {WebGLContext} the current WebGL drawing context + * + */ PIXI.WebGLSpriteBatch = function(gl) { - + /** + * TODO-Alvin + * + * @property vertSize + * @type Number + */ this.vertSize = 6; + + /** + * TODO-Alvin + * @property size + * @type Number + */ this.size = 10000;//Math.pow(2, 16) / this.vertSize; // console.log(this.size); @@ -21,9 +40,23 @@ //the total number of indices in our batch var numIndices = this.size * 6; - //vertex data + //vertex data + + /** + * Holds the vertices + * + * @property vertices + * @type Float32Array + */ this.vertices = new Float32Array(numVerts); + //index data + /** + * Holds the indices + * + * @property indices + * @type Uint16Array + */ this.indices = new Uint16Array(numIndices); this.lastIndexCount = 0; @@ -46,6 +79,12 @@ this.setContext(gl); }; +/** +* +* @method setContext +* +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) { this.gl = gl; @@ -67,6 +106,12 @@ this.currentBlendMode = 99999; }; +/** +* +* @method begin +* +* @param renderSession {RenderSession} the RenderSession +*/ PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession) { this.renderSession = renderSession; @@ -75,12 +120,22 @@ this.start(); }; +/** +* +* @method end +* +*/ PIXI.WebGLSpriteBatch.prototype.end = function() { this.flush(); }; - +/** +* +* @method render +* +* @param sprite {Sprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) { // check texture.. @@ -194,6 +249,12 @@ }; +/** +* +* @method renderTilingSprite +* +* @param sprite {TilingSprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite) { var texture = tilingSprite.tilingTexture; @@ -309,6 +370,13 @@ this.currentBatchSize++; }; + +/** +* +* +* @method flush TODO-Alvin +* +*/ PIXI.WebGLSpriteBatch.prototype.flush = function() { // If the batch is length 0 then return as there is nothing to draw @@ -345,12 +413,21 @@ this.renderSession.drawCount++; }; - +/** +* +* @method stop +* +*/ PIXI.WebGLSpriteBatch.prototype.stop = function() { this.flush(); }; +/** +* +* @method start +* +*/ PIXI.WebGLSpriteBatch.prototype.start = function() { var gl = this.gl; @@ -379,6 +456,13 @@ } }; +/** +* +* @method setBlendMode +* +* @param blendMode {Number} the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD +* TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode) { this.flush(); @@ -389,6 +473,10 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +/** +* Destroys the SpriteBatch +* @method destroy +*/ PIXI.WebGLSpriteBatch.prototype.destroy = function() { diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 4956802..44f1323 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -5,7 +5,9 @@ /** * A set of functions used by the webGL renderer to draw the primitive graphics data * - * @class CanvasGraphics + * @class WebGLGraphics + * @private + * @static */ PIXI.WebGLGraphics = function() { @@ -19,7 +21,7 @@ * @private * @method renderGraphics * @param graphics {Graphics} - * @param projection {Object} + * @param renderSession {Object} */ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset) { @@ -91,7 +93,8 @@ * @static * @private * @method updateGraphics - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to update + * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { @@ -145,7 +148,7 @@ * @static * @private * @method buildRectangle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) @@ -214,7 +217,7 @@ * @static * @private * @method buildCircle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw * @param webGLData {Object} */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) @@ -287,7 +290,7 @@ * @static * @private * @method buildLine - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) @@ -497,7 +500,7 @@ * @static * @private * @method buildPoly - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData) diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index a929c8f..12a7849 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -2,6 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ + +/** +* @class WebGLMaskManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLMaskManager = function(gl) { this.maskStack = []; @@ -10,11 +17,22 @@ this.setContext(gl); }; +/** +* Sets the drawing context to the one given in parameter +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLMaskManager.prototype.setContext = function(gl) { this.gl = gl; }; +/** +* Applies the Mask and adds it to the current filter stack +* @method pushMask +* @param maskData {Array} +* @param renderSession {RenderSession} +*/ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession) { var gl = this.gl; @@ -39,6 +57,12 @@ gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popMask +* +* @param renderSession {RenderSession} TODO-Alvin +*/ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession) { var gl = this.gl; @@ -62,6 +86,10 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLMaskManager.prototype.destroy = function() { this.maskStack = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index 5355259..17e5937 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -2,6 +2,12 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** +* @class WebGLShaderManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLShaderManager = function(gl) { @@ -18,6 +24,13 @@ //this.stripShader = new PIXI.StripShader(gl); }; + +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +*/ PIXI.WebGLShaderManager.prototype.setContext = function(gl) { this.gl = gl; @@ -36,6 +49,11 @@ }; +/** +* Initialises the context and the properties +* @method setAttribs +* @param attribs {Array} TODO-Alvin +*/ PIXI.WebGLShaderManager.prototype.setAttribs = function(attribs) { // reset temp state @@ -77,6 +95,11 @@ // console.log(this.tempAttribState) }; +/** +* TODO-Alvin +* @method activateShader +* @param shader {Object} the shader that is going to be activated +*/ PIXI.WebGLShaderManager.prototype.activateShader = function(shader) { //if(this.currentShader == shader)return; @@ -90,6 +113,10 @@ }; +/** +* Triggers the primitive shader +* @method activatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function() { var gl = this.gl; @@ -100,6 +127,10 @@ }; +/** +* Disable the primitive shader +* @method deactivatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() { var gl = this.gl; @@ -109,6 +140,10 @@ this.setAttribs(this.defaultShader.attributes); }; +/** +* Destroys +* @method destroy +*/ PIXI.WebGLShaderManager.prototype.destroy = function() { this.attribState = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 672de62..bf151bf 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -8,11 +8,30 @@ * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/WebGLSpriteBatch.java */ + /** + * + * @class WebGLSpriteBatch + * @private + * @constructor + * @param gl {WebGLContext} the current WebGL drawing context + * + */ PIXI.WebGLSpriteBatch = function(gl) { - + /** + * TODO-Alvin + * + * @property vertSize + * @type Number + */ this.vertSize = 6; + + /** + * TODO-Alvin + * @property size + * @type Number + */ this.size = 10000;//Math.pow(2, 16) / this.vertSize; // console.log(this.size); @@ -21,9 +40,23 @@ //the total number of indices in our batch var numIndices = this.size * 6; - //vertex data + //vertex data + + /** + * Holds the vertices + * + * @property vertices + * @type Float32Array + */ this.vertices = new Float32Array(numVerts); + //index data + /** + * Holds the indices + * + * @property indices + * @type Uint16Array + */ this.indices = new Uint16Array(numIndices); this.lastIndexCount = 0; @@ -46,6 +79,12 @@ this.setContext(gl); }; +/** +* +* @method setContext +* +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) { this.gl = gl; @@ -67,6 +106,12 @@ this.currentBlendMode = 99999; }; +/** +* +* @method begin +* +* @param renderSession {RenderSession} the RenderSession +*/ PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession) { this.renderSession = renderSession; @@ -75,12 +120,22 @@ this.start(); }; +/** +* +* @method end +* +*/ PIXI.WebGLSpriteBatch.prototype.end = function() { this.flush(); }; - +/** +* +* @method render +* +* @param sprite {Sprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) { // check texture.. @@ -194,6 +249,12 @@ }; +/** +* +* @method renderTilingSprite +* +* @param sprite {TilingSprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite) { var texture = tilingSprite.tilingTexture; @@ -309,6 +370,13 @@ this.currentBatchSize++; }; + +/** +* +* +* @method flush TODO-Alvin +* +*/ PIXI.WebGLSpriteBatch.prototype.flush = function() { // If the batch is length 0 then return as there is nothing to draw @@ -345,12 +413,21 @@ this.renderSession.drawCount++; }; - +/** +* +* @method stop +* +*/ PIXI.WebGLSpriteBatch.prototype.stop = function() { this.flush(); }; +/** +* +* @method start +* +*/ PIXI.WebGLSpriteBatch.prototype.start = function() { var gl = this.gl; @@ -379,6 +456,13 @@ } }; +/** +* +* @method setBlendMode +* +* @param blendMode {Number} the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD +* TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode) { this.flush(); @@ -389,6 +473,10 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +/** +* Destroys the SpriteBatch +* @method destroy +*/ PIXI.WebGLSpriteBatch.prototype.destroy = function() { diff --git a/src/pixi/text/BitmapText.js b/src/pixi/text/BitmapText.js index ca1aaa2..b617c7f 100644 --- a/src/pixi/text/BitmapText.js +++ b/src/pixi/text/BitmapText.js @@ -44,11 +44,11 @@ /** * Set the style of the text + * style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) + * [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text * * @method setStyle - * @param style {Object} The style parameters - * @param style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) - * @param [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text + * @param style {Object} The style parameters, contained as properties of an object */ PIXI.BitmapText.prototype.setStyle = function(style) { diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 4956802..44f1323 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -5,7 +5,9 @@ /** * A set of functions used by the webGL renderer to draw the primitive graphics data * - * @class CanvasGraphics + * @class WebGLGraphics + * @private + * @static */ PIXI.WebGLGraphics = function() { @@ -19,7 +21,7 @@ * @private * @method renderGraphics * @param graphics {Graphics} - * @param projection {Object} + * @param renderSession {Object} */ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset) { @@ -91,7 +93,8 @@ * @static * @private * @method updateGraphics - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to update + * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { @@ -145,7 +148,7 @@ * @static * @private * @method buildRectangle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) @@ -214,7 +217,7 @@ * @static * @private * @method buildCircle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw * @param webGLData {Object} */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) @@ -287,7 +290,7 @@ * @static * @private * @method buildLine - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) @@ -497,7 +500,7 @@ * @static * @private * @method buildPoly - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData) diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index a929c8f..12a7849 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -2,6 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ + +/** +* @class WebGLMaskManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLMaskManager = function(gl) { this.maskStack = []; @@ -10,11 +17,22 @@ this.setContext(gl); }; +/** +* Sets the drawing context to the one given in parameter +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLMaskManager.prototype.setContext = function(gl) { this.gl = gl; }; +/** +* Applies the Mask and adds it to the current filter stack +* @method pushMask +* @param maskData {Array} +* @param renderSession {RenderSession} +*/ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession) { var gl = this.gl; @@ -39,6 +57,12 @@ gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popMask +* +* @param renderSession {RenderSession} TODO-Alvin +*/ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession) { var gl = this.gl; @@ -62,6 +86,10 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLMaskManager.prototype.destroy = function() { this.maskStack = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index 5355259..17e5937 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -2,6 +2,12 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** +* @class WebGLShaderManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLShaderManager = function(gl) { @@ -18,6 +24,13 @@ //this.stripShader = new PIXI.StripShader(gl); }; + +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +*/ PIXI.WebGLShaderManager.prototype.setContext = function(gl) { this.gl = gl; @@ -36,6 +49,11 @@ }; +/** +* Initialises the context and the properties +* @method setAttribs +* @param attribs {Array} TODO-Alvin +*/ PIXI.WebGLShaderManager.prototype.setAttribs = function(attribs) { // reset temp state @@ -77,6 +95,11 @@ // console.log(this.tempAttribState) }; +/** +* TODO-Alvin +* @method activateShader +* @param shader {Object} the shader that is going to be activated +*/ PIXI.WebGLShaderManager.prototype.activateShader = function(shader) { //if(this.currentShader == shader)return; @@ -90,6 +113,10 @@ }; +/** +* Triggers the primitive shader +* @method activatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function() { var gl = this.gl; @@ -100,6 +127,10 @@ }; +/** +* Disable the primitive shader +* @method deactivatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() { var gl = this.gl; @@ -109,6 +140,10 @@ this.setAttribs(this.defaultShader.attributes); }; +/** +* Destroys +* @method destroy +*/ PIXI.WebGLShaderManager.prototype.destroy = function() { this.attribState = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 672de62..bf151bf 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -8,11 +8,30 @@ * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/WebGLSpriteBatch.java */ + /** + * + * @class WebGLSpriteBatch + * @private + * @constructor + * @param gl {WebGLContext} the current WebGL drawing context + * + */ PIXI.WebGLSpriteBatch = function(gl) { - + /** + * TODO-Alvin + * + * @property vertSize + * @type Number + */ this.vertSize = 6; + + /** + * TODO-Alvin + * @property size + * @type Number + */ this.size = 10000;//Math.pow(2, 16) / this.vertSize; // console.log(this.size); @@ -21,9 +40,23 @@ //the total number of indices in our batch var numIndices = this.size * 6; - //vertex data + //vertex data + + /** + * Holds the vertices + * + * @property vertices + * @type Float32Array + */ this.vertices = new Float32Array(numVerts); + //index data + /** + * Holds the indices + * + * @property indices + * @type Uint16Array + */ this.indices = new Uint16Array(numIndices); this.lastIndexCount = 0; @@ -46,6 +79,12 @@ this.setContext(gl); }; +/** +* +* @method setContext +* +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) { this.gl = gl; @@ -67,6 +106,12 @@ this.currentBlendMode = 99999; }; +/** +* +* @method begin +* +* @param renderSession {RenderSession} the RenderSession +*/ PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession) { this.renderSession = renderSession; @@ -75,12 +120,22 @@ this.start(); }; +/** +* +* @method end +* +*/ PIXI.WebGLSpriteBatch.prototype.end = function() { this.flush(); }; - +/** +* +* @method render +* +* @param sprite {Sprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) { // check texture.. @@ -194,6 +249,12 @@ }; +/** +* +* @method renderTilingSprite +* +* @param sprite {TilingSprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite) { var texture = tilingSprite.tilingTexture; @@ -309,6 +370,13 @@ this.currentBatchSize++; }; + +/** +* +* +* @method flush TODO-Alvin +* +*/ PIXI.WebGLSpriteBatch.prototype.flush = function() { // If the batch is length 0 then return as there is nothing to draw @@ -345,12 +413,21 @@ this.renderSession.drawCount++; }; - +/** +* +* @method stop +* +*/ PIXI.WebGLSpriteBatch.prototype.stop = function() { this.flush(); }; +/** +* +* @method start +* +*/ PIXI.WebGLSpriteBatch.prototype.start = function() { var gl = this.gl; @@ -379,6 +456,13 @@ } }; +/** +* +* @method setBlendMode +* +* @param blendMode {Number} the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD +* TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode) { this.flush(); @@ -389,6 +473,10 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +/** +* Destroys the SpriteBatch +* @method destroy +*/ PIXI.WebGLSpriteBatch.prototype.destroy = function() { diff --git a/src/pixi/text/BitmapText.js b/src/pixi/text/BitmapText.js index ca1aaa2..b617c7f 100644 --- a/src/pixi/text/BitmapText.js +++ b/src/pixi/text/BitmapText.js @@ -44,11 +44,11 @@ /** * Set the style of the text + * style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) + * [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text * * @method setStyle - * @param style {Object} The style parameters - * @param style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) - * @param [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text + * @param style {Object} The style parameters, contained as properties of an object */ PIXI.BitmapText.prototype.setStyle = function(style) { diff --git a/src/pixi/text/Text.js b/src/pixi/text/Text.js index 7393942..5244ca2 100644 --- a/src/pixi/text/Text.js +++ b/src/pixi/text/Text.js @@ -20,8 +20,21 @@ */ PIXI.Text = function(text, style) { + /** + * The canvas element that everything is drawn to + * + * @property canvas + * @type HTMLCanvasElement + */ this.canvas = document.createElement('canvas'); + + /** + * The canvas 2d context that everything is drawn with + * @property context + * @type HTMLCanvasElement 2d Context + */ this.context = this.canvas.getContext('2d'); + PIXI.Sprite.call(this, PIXI.Texture.fromCanvas(this.canvas)); this.setText(text); @@ -167,6 +180,13 @@ this.requiresUpdate = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Text.prototype._renderWebGL = function(renderSession) { if(this.requiresUpdate) @@ -198,6 +218,7 @@ /* * http://stackoverflow.com/users/34441/ellisbben * great solution to the problem! + * returns the height of the given font * * @method determineFontHeight * @param fontStyle {Object} diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 4956802..44f1323 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -5,7 +5,9 @@ /** * A set of functions used by the webGL renderer to draw the primitive graphics data * - * @class CanvasGraphics + * @class WebGLGraphics + * @private + * @static */ PIXI.WebGLGraphics = function() { @@ -19,7 +21,7 @@ * @private * @method renderGraphics * @param graphics {Graphics} - * @param projection {Object} + * @param renderSession {Object} */ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset) { @@ -91,7 +93,8 @@ * @static * @private * @method updateGraphics - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to update + * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { @@ -145,7 +148,7 @@ * @static * @private * @method buildRectangle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) @@ -214,7 +217,7 @@ * @static * @private * @method buildCircle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw * @param webGLData {Object} */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) @@ -287,7 +290,7 @@ * @static * @private * @method buildLine - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) @@ -497,7 +500,7 @@ * @static * @private * @method buildPoly - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData) diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index a929c8f..12a7849 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -2,6 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ + +/** +* @class WebGLMaskManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLMaskManager = function(gl) { this.maskStack = []; @@ -10,11 +17,22 @@ this.setContext(gl); }; +/** +* Sets the drawing context to the one given in parameter +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLMaskManager.prototype.setContext = function(gl) { this.gl = gl; }; +/** +* Applies the Mask and adds it to the current filter stack +* @method pushMask +* @param maskData {Array} +* @param renderSession {RenderSession} +*/ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession) { var gl = this.gl; @@ -39,6 +57,12 @@ gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popMask +* +* @param renderSession {RenderSession} TODO-Alvin +*/ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession) { var gl = this.gl; @@ -62,6 +86,10 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLMaskManager.prototype.destroy = function() { this.maskStack = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index 5355259..17e5937 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -2,6 +2,12 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** +* @class WebGLShaderManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLShaderManager = function(gl) { @@ -18,6 +24,13 @@ //this.stripShader = new PIXI.StripShader(gl); }; + +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +*/ PIXI.WebGLShaderManager.prototype.setContext = function(gl) { this.gl = gl; @@ -36,6 +49,11 @@ }; +/** +* Initialises the context and the properties +* @method setAttribs +* @param attribs {Array} TODO-Alvin +*/ PIXI.WebGLShaderManager.prototype.setAttribs = function(attribs) { // reset temp state @@ -77,6 +95,11 @@ // console.log(this.tempAttribState) }; +/** +* TODO-Alvin +* @method activateShader +* @param shader {Object} the shader that is going to be activated +*/ PIXI.WebGLShaderManager.prototype.activateShader = function(shader) { //if(this.currentShader == shader)return; @@ -90,6 +113,10 @@ }; +/** +* Triggers the primitive shader +* @method activatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function() { var gl = this.gl; @@ -100,6 +127,10 @@ }; +/** +* Disable the primitive shader +* @method deactivatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() { var gl = this.gl; @@ -109,6 +140,10 @@ this.setAttribs(this.defaultShader.attributes); }; +/** +* Destroys +* @method destroy +*/ PIXI.WebGLShaderManager.prototype.destroy = function() { this.attribState = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 672de62..bf151bf 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -8,11 +8,30 @@ * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/WebGLSpriteBatch.java */ + /** + * + * @class WebGLSpriteBatch + * @private + * @constructor + * @param gl {WebGLContext} the current WebGL drawing context + * + */ PIXI.WebGLSpriteBatch = function(gl) { - + /** + * TODO-Alvin + * + * @property vertSize + * @type Number + */ this.vertSize = 6; + + /** + * TODO-Alvin + * @property size + * @type Number + */ this.size = 10000;//Math.pow(2, 16) / this.vertSize; // console.log(this.size); @@ -21,9 +40,23 @@ //the total number of indices in our batch var numIndices = this.size * 6; - //vertex data + //vertex data + + /** + * Holds the vertices + * + * @property vertices + * @type Float32Array + */ this.vertices = new Float32Array(numVerts); + //index data + /** + * Holds the indices + * + * @property indices + * @type Uint16Array + */ this.indices = new Uint16Array(numIndices); this.lastIndexCount = 0; @@ -46,6 +79,12 @@ this.setContext(gl); }; +/** +* +* @method setContext +* +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) { this.gl = gl; @@ -67,6 +106,12 @@ this.currentBlendMode = 99999; }; +/** +* +* @method begin +* +* @param renderSession {RenderSession} the RenderSession +*/ PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession) { this.renderSession = renderSession; @@ -75,12 +120,22 @@ this.start(); }; +/** +* +* @method end +* +*/ PIXI.WebGLSpriteBatch.prototype.end = function() { this.flush(); }; - +/** +* +* @method render +* +* @param sprite {Sprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) { // check texture.. @@ -194,6 +249,12 @@ }; +/** +* +* @method renderTilingSprite +* +* @param sprite {TilingSprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite) { var texture = tilingSprite.tilingTexture; @@ -309,6 +370,13 @@ this.currentBatchSize++; }; + +/** +* +* +* @method flush TODO-Alvin +* +*/ PIXI.WebGLSpriteBatch.prototype.flush = function() { // If the batch is length 0 then return as there is nothing to draw @@ -345,12 +413,21 @@ this.renderSession.drawCount++; }; - +/** +* +* @method stop +* +*/ PIXI.WebGLSpriteBatch.prototype.stop = function() { this.flush(); }; +/** +* +* @method start +* +*/ PIXI.WebGLSpriteBatch.prototype.start = function() { var gl = this.gl; @@ -379,6 +456,13 @@ } }; +/** +* +* @method setBlendMode +* +* @param blendMode {Number} the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD +* TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode) { this.flush(); @@ -389,6 +473,10 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +/** +* Destroys the SpriteBatch +* @method destroy +*/ PIXI.WebGLSpriteBatch.prototype.destroy = function() { diff --git a/src/pixi/text/BitmapText.js b/src/pixi/text/BitmapText.js index ca1aaa2..b617c7f 100644 --- a/src/pixi/text/BitmapText.js +++ b/src/pixi/text/BitmapText.js @@ -44,11 +44,11 @@ /** * Set the style of the text + * style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) + * [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text * * @method setStyle - * @param style {Object} The style parameters - * @param style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) - * @param [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text + * @param style {Object} The style parameters, contained as properties of an object */ PIXI.BitmapText.prototype.setStyle = function(style) { diff --git a/src/pixi/text/Text.js b/src/pixi/text/Text.js index 7393942..5244ca2 100644 --- a/src/pixi/text/Text.js +++ b/src/pixi/text/Text.js @@ -20,8 +20,21 @@ */ PIXI.Text = function(text, style) { + /** + * The canvas element that everything is drawn to + * + * @property canvas + * @type HTMLCanvasElement + */ this.canvas = document.createElement('canvas'); + + /** + * The canvas 2d context that everything is drawn with + * @property context + * @type HTMLCanvasElement 2d Context + */ this.context = this.canvas.getContext('2d'); + PIXI.Sprite.call(this, PIXI.Texture.fromCanvas(this.canvas)); this.setText(text); @@ -167,6 +180,13 @@ this.requiresUpdate = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Text.prototype._renderWebGL = function(renderSession) { if(this.requiresUpdate) @@ -198,6 +218,7 @@ /* * http://stackoverflow.com/users/34441/ellisbben * great solution to the problem! + * returns the height of the given font * * @method determineFontHeight * @param fontStyle {Object} diff --git a/src/pixi/textures/BaseTexture.js b/src/pixi/textures/BaseTexture.js index df76c70..3461549 100644 --- a/src/pixi/textures/BaseTexture.js +++ b/src/pixi/textures/BaseTexture.js @@ -15,6 +15,7 @@ * @uses EventTarget * @constructor * @param source {String} the source object (image or canvas) + * @param scaleMode {Number} Should be one of the PIXI.scaleMode consts */ PIXI.BaseTexture = function(source, scaleMode) { diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 4956802..44f1323 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -5,7 +5,9 @@ /** * A set of functions used by the webGL renderer to draw the primitive graphics data * - * @class CanvasGraphics + * @class WebGLGraphics + * @private + * @static */ PIXI.WebGLGraphics = function() { @@ -19,7 +21,7 @@ * @private * @method renderGraphics * @param graphics {Graphics} - * @param projection {Object} + * @param renderSession {Object} */ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset) { @@ -91,7 +93,8 @@ * @static * @private * @method updateGraphics - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to update + * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { @@ -145,7 +148,7 @@ * @static * @private * @method buildRectangle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) @@ -214,7 +217,7 @@ * @static * @private * @method buildCircle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw * @param webGLData {Object} */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) @@ -287,7 +290,7 @@ * @static * @private * @method buildLine - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) @@ -497,7 +500,7 @@ * @static * @private * @method buildPoly - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData) diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index a929c8f..12a7849 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -2,6 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ + +/** +* @class WebGLMaskManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLMaskManager = function(gl) { this.maskStack = []; @@ -10,11 +17,22 @@ this.setContext(gl); }; +/** +* Sets the drawing context to the one given in parameter +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLMaskManager.prototype.setContext = function(gl) { this.gl = gl; }; +/** +* Applies the Mask and adds it to the current filter stack +* @method pushMask +* @param maskData {Array} +* @param renderSession {RenderSession} +*/ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession) { var gl = this.gl; @@ -39,6 +57,12 @@ gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popMask +* +* @param renderSession {RenderSession} TODO-Alvin +*/ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession) { var gl = this.gl; @@ -62,6 +86,10 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLMaskManager.prototype.destroy = function() { this.maskStack = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index 5355259..17e5937 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -2,6 +2,12 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** +* @class WebGLShaderManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLShaderManager = function(gl) { @@ -18,6 +24,13 @@ //this.stripShader = new PIXI.StripShader(gl); }; + +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +*/ PIXI.WebGLShaderManager.prototype.setContext = function(gl) { this.gl = gl; @@ -36,6 +49,11 @@ }; +/** +* Initialises the context and the properties +* @method setAttribs +* @param attribs {Array} TODO-Alvin +*/ PIXI.WebGLShaderManager.prototype.setAttribs = function(attribs) { // reset temp state @@ -77,6 +95,11 @@ // console.log(this.tempAttribState) }; +/** +* TODO-Alvin +* @method activateShader +* @param shader {Object} the shader that is going to be activated +*/ PIXI.WebGLShaderManager.prototype.activateShader = function(shader) { //if(this.currentShader == shader)return; @@ -90,6 +113,10 @@ }; +/** +* Triggers the primitive shader +* @method activatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function() { var gl = this.gl; @@ -100,6 +127,10 @@ }; +/** +* Disable the primitive shader +* @method deactivatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() { var gl = this.gl; @@ -109,6 +140,10 @@ this.setAttribs(this.defaultShader.attributes); }; +/** +* Destroys +* @method destroy +*/ PIXI.WebGLShaderManager.prototype.destroy = function() { this.attribState = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 672de62..bf151bf 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -8,11 +8,30 @@ * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/WebGLSpriteBatch.java */ + /** + * + * @class WebGLSpriteBatch + * @private + * @constructor + * @param gl {WebGLContext} the current WebGL drawing context + * + */ PIXI.WebGLSpriteBatch = function(gl) { - + /** + * TODO-Alvin + * + * @property vertSize + * @type Number + */ this.vertSize = 6; + + /** + * TODO-Alvin + * @property size + * @type Number + */ this.size = 10000;//Math.pow(2, 16) / this.vertSize; // console.log(this.size); @@ -21,9 +40,23 @@ //the total number of indices in our batch var numIndices = this.size * 6; - //vertex data + //vertex data + + /** + * Holds the vertices + * + * @property vertices + * @type Float32Array + */ this.vertices = new Float32Array(numVerts); + //index data + /** + * Holds the indices + * + * @property indices + * @type Uint16Array + */ this.indices = new Uint16Array(numIndices); this.lastIndexCount = 0; @@ -46,6 +79,12 @@ this.setContext(gl); }; +/** +* +* @method setContext +* +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) { this.gl = gl; @@ -67,6 +106,12 @@ this.currentBlendMode = 99999; }; +/** +* +* @method begin +* +* @param renderSession {RenderSession} the RenderSession +*/ PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession) { this.renderSession = renderSession; @@ -75,12 +120,22 @@ this.start(); }; +/** +* +* @method end +* +*/ PIXI.WebGLSpriteBatch.prototype.end = function() { this.flush(); }; - +/** +* +* @method render +* +* @param sprite {Sprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) { // check texture.. @@ -194,6 +249,12 @@ }; +/** +* +* @method renderTilingSprite +* +* @param sprite {TilingSprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite) { var texture = tilingSprite.tilingTexture; @@ -309,6 +370,13 @@ this.currentBatchSize++; }; + +/** +* +* +* @method flush TODO-Alvin +* +*/ PIXI.WebGLSpriteBatch.prototype.flush = function() { // If the batch is length 0 then return as there is nothing to draw @@ -345,12 +413,21 @@ this.renderSession.drawCount++; }; - +/** +* +* @method stop +* +*/ PIXI.WebGLSpriteBatch.prototype.stop = function() { this.flush(); }; +/** +* +* @method start +* +*/ PIXI.WebGLSpriteBatch.prototype.start = function() { var gl = this.gl; @@ -379,6 +456,13 @@ } }; +/** +* +* @method setBlendMode +* +* @param blendMode {Number} the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD +* TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode) { this.flush(); @@ -389,6 +473,10 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +/** +* Destroys the SpriteBatch +* @method destroy +*/ PIXI.WebGLSpriteBatch.prototype.destroy = function() { diff --git a/src/pixi/text/BitmapText.js b/src/pixi/text/BitmapText.js index ca1aaa2..b617c7f 100644 --- a/src/pixi/text/BitmapText.js +++ b/src/pixi/text/BitmapText.js @@ -44,11 +44,11 @@ /** * Set the style of the text + * style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) + * [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text * * @method setStyle - * @param style {Object} The style parameters - * @param style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) - * @param [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text + * @param style {Object} The style parameters, contained as properties of an object */ PIXI.BitmapText.prototype.setStyle = function(style) { diff --git a/src/pixi/text/Text.js b/src/pixi/text/Text.js index 7393942..5244ca2 100644 --- a/src/pixi/text/Text.js +++ b/src/pixi/text/Text.js @@ -20,8 +20,21 @@ */ PIXI.Text = function(text, style) { + /** + * The canvas element that everything is drawn to + * + * @property canvas + * @type HTMLCanvasElement + */ this.canvas = document.createElement('canvas'); + + /** + * The canvas 2d context that everything is drawn with + * @property context + * @type HTMLCanvasElement 2d Context + */ this.context = this.canvas.getContext('2d'); + PIXI.Sprite.call(this, PIXI.Texture.fromCanvas(this.canvas)); this.setText(text); @@ -167,6 +180,13 @@ this.requiresUpdate = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Text.prototype._renderWebGL = function(renderSession) { if(this.requiresUpdate) @@ -198,6 +218,7 @@ /* * http://stackoverflow.com/users/34441/ellisbben * great solution to the problem! + * returns the height of the given font * * @method determineFontHeight * @param fontStyle {Object} diff --git a/src/pixi/textures/BaseTexture.js b/src/pixi/textures/BaseTexture.js index df76c70..3461549 100644 --- a/src/pixi/textures/BaseTexture.js +++ b/src/pixi/textures/BaseTexture.js @@ -15,6 +15,7 @@ * @uses EventTarget * @constructor * @param source {String} the source object (image or canvas) + * @param scaleMode {Number} Should be one of the PIXI.scaleMode consts */ PIXI.BaseTexture = function(source, scaleMode) { diff --git a/src/pixi/utils/Detector.js b/src/pixi/utils/Detector.js index cf4896b..7054e0f 100644 --- a/src/pixi/utils/Detector.js +++ b/src/pixi/utils/Detector.js @@ -6,7 +6,8 @@ * This helper function will automatically detect which renderer you should be using. * WebGL is the preferred renderer as it is a lot faster. If webGL is not supported by * the browser then this function will return a canvas renderer - * + * @class autoDetectRenderer + * @static * @param width=800 {Number} the width of the renderers view * @param height=600 {Number} the height of the renderers view * @param [view] {Canvas} the canvas to use as a view, optional diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 4956802..44f1323 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -5,7 +5,9 @@ /** * A set of functions used by the webGL renderer to draw the primitive graphics data * - * @class CanvasGraphics + * @class WebGLGraphics + * @private + * @static */ PIXI.WebGLGraphics = function() { @@ -19,7 +21,7 @@ * @private * @method renderGraphics * @param graphics {Graphics} - * @param projection {Object} + * @param renderSession {Object} */ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset) { @@ -91,7 +93,8 @@ * @static * @private * @method updateGraphics - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to update + * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { @@ -145,7 +148,7 @@ * @static * @private * @method buildRectangle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) @@ -214,7 +217,7 @@ * @static * @private * @method buildCircle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw * @param webGLData {Object} */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) @@ -287,7 +290,7 @@ * @static * @private * @method buildLine - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) @@ -497,7 +500,7 @@ * @static * @private * @method buildPoly - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData) diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index a929c8f..12a7849 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -2,6 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ + +/** +* @class WebGLMaskManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLMaskManager = function(gl) { this.maskStack = []; @@ -10,11 +17,22 @@ this.setContext(gl); }; +/** +* Sets the drawing context to the one given in parameter +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLMaskManager.prototype.setContext = function(gl) { this.gl = gl; }; +/** +* Applies the Mask and adds it to the current filter stack +* @method pushMask +* @param maskData {Array} +* @param renderSession {RenderSession} +*/ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession) { var gl = this.gl; @@ -39,6 +57,12 @@ gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popMask +* +* @param renderSession {RenderSession} TODO-Alvin +*/ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession) { var gl = this.gl; @@ -62,6 +86,10 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLMaskManager.prototype.destroy = function() { this.maskStack = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index 5355259..17e5937 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -2,6 +2,12 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** +* @class WebGLShaderManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLShaderManager = function(gl) { @@ -18,6 +24,13 @@ //this.stripShader = new PIXI.StripShader(gl); }; + +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +*/ PIXI.WebGLShaderManager.prototype.setContext = function(gl) { this.gl = gl; @@ -36,6 +49,11 @@ }; +/** +* Initialises the context and the properties +* @method setAttribs +* @param attribs {Array} TODO-Alvin +*/ PIXI.WebGLShaderManager.prototype.setAttribs = function(attribs) { // reset temp state @@ -77,6 +95,11 @@ // console.log(this.tempAttribState) }; +/** +* TODO-Alvin +* @method activateShader +* @param shader {Object} the shader that is going to be activated +*/ PIXI.WebGLShaderManager.prototype.activateShader = function(shader) { //if(this.currentShader == shader)return; @@ -90,6 +113,10 @@ }; +/** +* Triggers the primitive shader +* @method activatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function() { var gl = this.gl; @@ -100,6 +127,10 @@ }; +/** +* Disable the primitive shader +* @method deactivatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() { var gl = this.gl; @@ -109,6 +140,10 @@ this.setAttribs(this.defaultShader.attributes); }; +/** +* Destroys +* @method destroy +*/ PIXI.WebGLShaderManager.prototype.destroy = function() { this.attribState = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 672de62..bf151bf 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -8,11 +8,30 @@ * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/WebGLSpriteBatch.java */ + /** + * + * @class WebGLSpriteBatch + * @private + * @constructor + * @param gl {WebGLContext} the current WebGL drawing context + * + */ PIXI.WebGLSpriteBatch = function(gl) { - + /** + * TODO-Alvin + * + * @property vertSize + * @type Number + */ this.vertSize = 6; + + /** + * TODO-Alvin + * @property size + * @type Number + */ this.size = 10000;//Math.pow(2, 16) / this.vertSize; // console.log(this.size); @@ -21,9 +40,23 @@ //the total number of indices in our batch var numIndices = this.size * 6; - //vertex data + //vertex data + + /** + * Holds the vertices + * + * @property vertices + * @type Float32Array + */ this.vertices = new Float32Array(numVerts); + //index data + /** + * Holds the indices + * + * @property indices + * @type Uint16Array + */ this.indices = new Uint16Array(numIndices); this.lastIndexCount = 0; @@ -46,6 +79,12 @@ this.setContext(gl); }; +/** +* +* @method setContext +* +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) { this.gl = gl; @@ -67,6 +106,12 @@ this.currentBlendMode = 99999; }; +/** +* +* @method begin +* +* @param renderSession {RenderSession} the RenderSession +*/ PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession) { this.renderSession = renderSession; @@ -75,12 +120,22 @@ this.start(); }; +/** +* +* @method end +* +*/ PIXI.WebGLSpriteBatch.prototype.end = function() { this.flush(); }; - +/** +* +* @method render +* +* @param sprite {Sprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) { // check texture.. @@ -194,6 +249,12 @@ }; +/** +* +* @method renderTilingSprite +* +* @param sprite {TilingSprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite) { var texture = tilingSprite.tilingTexture; @@ -309,6 +370,13 @@ this.currentBatchSize++; }; + +/** +* +* +* @method flush TODO-Alvin +* +*/ PIXI.WebGLSpriteBatch.prototype.flush = function() { // If the batch is length 0 then return as there is nothing to draw @@ -345,12 +413,21 @@ this.renderSession.drawCount++; }; - +/** +* +* @method stop +* +*/ PIXI.WebGLSpriteBatch.prototype.stop = function() { this.flush(); }; +/** +* +* @method start +* +*/ PIXI.WebGLSpriteBatch.prototype.start = function() { var gl = this.gl; @@ -379,6 +456,13 @@ } }; +/** +* +* @method setBlendMode +* +* @param blendMode {Number} the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD +* TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode) { this.flush(); @@ -389,6 +473,10 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +/** +* Destroys the SpriteBatch +* @method destroy +*/ PIXI.WebGLSpriteBatch.prototype.destroy = function() { diff --git a/src/pixi/text/BitmapText.js b/src/pixi/text/BitmapText.js index ca1aaa2..b617c7f 100644 --- a/src/pixi/text/BitmapText.js +++ b/src/pixi/text/BitmapText.js @@ -44,11 +44,11 @@ /** * Set the style of the text + * style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) + * [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text * * @method setStyle - * @param style {Object} The style parameters - * @param style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) - * @param [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text + * @param style {Object} The style parameters, contained as properties of an object */ PIXI.BitmapText.prototype.setStyle = function(style) { diff --git a/src/pixi/text/Text.js b/src/pixi/text/Text.js index 7393942..5244ca2 100644 --- a/src/pixi/text/Text.js +++ b/src/pixi/text/Text.js @@ -20,8 +20,21 @@ */ PIXI.Text = function(text, style) { + /** + * The canvas element that everything is drawn to + * + * @property canvas + * @type HTMLCanvasElement + */ this.canvas = document.createElement('canvas'); + + /** + * The canvas 2d context that everything is drawn with + * @property context + * @type HTMLCanvasElement 2d Context + */ this.context = this.canvas.getContext('2d'); + PIXI.Sprite.call(this, PIXI.Texture.fromCanvas(this.canvas)); this.setText(text); @@ -167,6 +180,13 @@ this.requiresUpdate = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Text.prototype._renderWebGL = function(renderSession) { if(this.requiresUpdate) @@ -198,6 +218,7 @@ /* * http://stackoverflow.com/users/34441/ellisbben * great solution to the problem! + * returns the height of the given font * * @method determineFontHeight * @param fontStyle {Object} diff --git a/src/pixi/textures/BaseTexture.js b/src/pixi/textures/BaseTexture.js index df76c70..3461549 100644 --- a/src/pixi/textures/BaseTexture.js +++ b/src/pixi/textures/BaseTexture.js @@ -15,6 +15,7 @@ * @uses EventTarget * @constructor * @param source {String} the source object (image or canvas) + * @param scaleMode {Number} Should be one of the PIXI.scaleMode consts */ PIXI.BaseTexture = function(source, scaleMode) { diff --git a/src/pixi/utils/Detector.js b/src/pixi/utils/Detector.js index cf4896b..7054e0f 100644 --- a/src/pixi/utils/Detector.js +++ b/src/pixi/utils/Detector.js @@ -6,7 +6,8 @@ * This helper function will automatically detect which renderer you should be using. * WebGL is the preferred renderer as it is a lot faster. If webGL is not supported by * the browser then this function will return a canvas renderer - * + * @class autoDetectRenderer + * @static * @param width=800 {Number} the width of the renderers view * @param height=600 {Number} the height of the renderers view * @param [view] {Canvas} the canvas to use as a view, optional diff --git a/src/pixi/utils/EventTarget.js b/src/pixi/utils/EventTarget.js index 92dca1f..a772a44 100644 --- a/src/pixi/utils/EventTarget.js +++ b/src/pixi/utils/EventTarget.js @@ -11,7 +11,7 @@ * Adds event emitter functionality to a class * * @class EventTarget - * @example + * * function MyEmitter() { * PIXI.EventTarget.call(this); //mixes in event target stuff * } @@ -21,8 +21,21 @@ */ PIXI.EventTarget = function () { + /** + * Holds all the listeners + * + * @property listeneners + * @type Object + */ var listeners = {}; + /** + * Adds a listener for a specific event + * + * @method addEventListener + * @param type {string} A string representing the event type to listen for. + * @param listener {function} The callback function that will be fired when the event occurs + */ this.addEventListener = this.on = function ( type, listener ) { @@ -39,6 +52,12 @@ }; + /** + * Fires the event, ie pretends that the event has happened + * + * @method dispatchEvent + * @param event {Event} the event object + */ this.dispatchEvent = this.emit = function ( event ) { if ( !listeners[ event.type ] || !listeners[ event.type ].length ) { @@ -55,6 +74,13 @@ }; + /** + * Removes the specified listener that was assigned to the specified event type + * + * @method removeEventListener + * @param type {string} A string representing the event type which will have its listener removed + * @param listener {function} The callback function that was be fired when the event occured + */ this.removeEventListener = this.off = function ( type, listener ) { var index = listeners[ type ].indexOf( listener ); @@ -67,6 +93,12 @@ }; + /** + * Removes all the listeners that were active for the specified event type + * + * @method removeAllEventListeners + * @param type {string} A string representing the event type which will have all its listeners removed + */ this.removeAllEventListeners = function( type ) { var a = listeners[type]; if (a) diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 4956802..44f1323 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -5,7 +5,9 @@ /** * A set of functions used by the webGL renderer to draw the primitive graphics data * - * @class CanvasGraphics + * @class WebGLGraphics + * @private + * @static */ PIXI.WebGLGraphics = function() { @@ -19,7 +21,7 @@ * @private * @method renderGraphics * @param graphics {Graphics} - * @param projection {Object} + * @param renderSession {Object} */ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset) { @@ -91,7 +93,8 @@ * @static * @private * @method updateGraphics - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to update + * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { @@ -145,7 +148,7 @@ * @static * @private * @method buildRectangle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) @@ -214,7 +217,7 @@ * @static * @private * @method buildCircle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw * @param webGLData {Object} */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) @@ -287,7 +290,7 @@ * @static * @private * @method buildLine - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) @@ -497,7 +500,7 @@ * @static * @private * @method buildPoly - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData) diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index a929c8f..12a7849 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -2,6 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ + +/** +* @class WebGLMaskManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLMaskManager = function(gl) { this.maskStack = []; @@ -10,11 +17,22 @@ this.setContext(gl); }; +/** +* Sets the drawing context to the one given in parameter +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLMaskManager.prototype.setContext = function(gl) { this.gl = gl; }; +/** +* Applies the Mask and adds it to the current filter stack +* @method pushMask +* @param maskData {Array} +* @param renderSession {RenderSession} +*/ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession) { var gl = this.gl; @@ -39,6 +57,12 @@ gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popMask +* +* @param renderSession {RenderSession} TODO-Alvin +*/ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession) { var gl = this.gl; @@ -62,6 +86,10 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLMaskManager.prototype.destroy = function() { this.maskStack = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index 5355259..17e5937 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -2,6 +2,12 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** +* @class WebGLShaderManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLShaderManager = function(gl) { @@ -18,6 +24,13 @@ //this.stripShader = new PIXI.StripShader(gl); }; + +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +*/ PIXI.WebGLShaderManager.prototype.setContext = function(gl) { this.gl = gl; @@ -36,6 +49,11 @@ }; +/** +* Initialises the context and the properties +* @method setAttribs +* @param attribs {Array} TODO-Alvin +*/ PIXI.WebGLShaderManager.prototype.setAttribs = function(attribs) { // reset temp state @@ -77,6 +95,11 @@ // console.log(this.tempAttribState) }; +/** +* TODO-Alvin +* @method activateShader +* @param shader {Object} the shader that is going to be activated +*/ PIXI.WebGLShaderManager.prototype.activateShader = function(shader) { //if(this.currentShader == shader)return; @@ -90,6 +113,10 @@ }; +/** +* Triggers the primitive shader +* @method activatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function() { var gl = this.gl; @@ -100,6 +127,10 @@ }; +/** +* Disable the primitive shader +* @method deactivatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() { var gl = this.gl; @@ -109,6 +140,10 @@ this.setAttribs(this.defaultShader.attributes); }; +/** +* Destroys +* @method destroy +*/ PIXI.WebGLShaderManager.prototype.destroy = function() { this.attribState = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 672de62..bf151bf 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -8,11 +8,30 @@ * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/WebGLSpriteBatch.java */ + /** + * + * @class WebGLSpriteBatch + * @private + * @constructor + * @param gl {WebGLContext} the current WebGL drawing context + * + */ PIXI.WebGLSpriteBatch = function(gl) { - + /** + * TODO-Alvin + * + * @property vertSize + * @type Number + */ this.vertSize = 6; + + /** + * TODO-Alvin + * @property size + * @type Number + */ this.size = 10000;//Math.pow(2, 16) / this.vertSize; // console.log(this.size); @@ -21,9 +40,23 @@ //the total number of indices in our batch var numIndices = this.size * 6; - //vertex data + //vertex data + + /** + * Holds the vertices + * + * @property vertices + * @type Float32Array + */ this.vertices = new Float32Array(numVerts); + //index data + /** + * Holds the indices + * + * @property indices + * @type Uint16Array + */ this.indices = new Uint16Array(numIndices); this.lastIndexCount = 0; @@ -46,6 +79,12 @@ this.setContext(gl); }; +/** +* +* @method setContext +* +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) { this.gl = gl; @@ -67,6 +106,12 @@ this.currentBlendMode = 99999; }; +/** +* +* @method begin +* +* @param renderSession {RenderSession} the RenderSession +*/ PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession) { this.renderSession = renderSession; @@ -75,12 +120,22 @@ this.start(); }; +/** +* +* @method end +* +*/ PIXI.WebGLSpriteBatch.prototype.end = function() { this.flush(); }; - +/** +* +* @method render +* +* @param sprite {Sprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) { // check texture.. @@ -194,6 +249,12 @@ }; +/** +* +* @method renderTilingSprite +* +* @param sprite {TilingSprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite) { var texture = tilingSprite.tilingTexture; @@ -309,6 +370,13 @@ this.currentBatchSize++; }; + +/** +* +* +* @method flush TODO-Alvin +* +*/ PIXI.WebGLSpriteBatch.prototype.flush = function() { // If the batch is length 0 then return as there is nothing to draw @@ -345,12 +413,21 @@ this.renderSession.drawCount++; }; - +/** +* +* @method stop +* +*/ PIXI.WebGLSpriteBatch.prototype.stop = function() { this.flush(); }; +/** +* +* @method start +* +*/ PIXI.WebGLSpriteBatch.prototype.start = function() { var gl = this.gl; @@ -379,6 +456,13 @@ } }; +/** +* +* @method setBlendMode +* +* @param blendMode {Number} the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD +* TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode) { this.flush(); @@ -389,6 +473,10 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +/** +* Destroys the SpriteBatch +* @method destroy +*/ PIXI.WebGLSpriteBatch.prototype.destroy = function() { diff --git a/src/pixi/text/BitmapText.js b/src/pixi/text/BitmapText.js index ca1aaa2..b617c7f 100644 --- a/src/pixi/text/BitmapText.js +++ b/src/pixi/text/BitmapText.js @@ -44,11 +44,11 @@ /** * Set the style of the text + * style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) + * [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text * * @method setStyle - * @param style {Object} The style parameters - * @param style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) - * @param [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text + * @param style {Object} The style parameters, contained as properties of an object */ PIXI.BitmapText.prototype.setStyle = function(style) { diff --git a/src/pixi/text/Text.js b/src/pixi/text/Text.js index 7393942..5244ca2 100644 --- a/src/pixi/text/Text.js +++ b/src/pixi/text/Text.js @@ -20,8 +20,21 @@ */ PIXI.Text = function(text, style) { + /** + * The canvas element that everything is drawn to + * + * @property canvas + * @type HTMLCanvasElement + */ this.canvas = document.createElement('canvas'); + + /** + * The canvas 2d context that everything is drawn with + * @property context + * @type HTMLCanvasElement 2d Context + */ this.context = this.canvas.getContext('2d'); + PIXI.Sprite.call(this, PIXI.Texture.fromCanvas(this.canvas)); this.setText(text); @@ -167,6 +180,13 @@ this.requiresUpdate = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Text.prototype._renderWebGL = function(renderSession) { if(this.requiresUpdate) @@ -198,6 +218,7 @@ /* * http://stackoverflow.com/users/34441/ellisbben * great solution to the problem! + * returns the height of the given font * * @method determineFontHeight * @param fontStyle {Object} diff --git a/src/pixi/textures/BaseTexture.js b/src/pixi/textures/BaseTexture.js index df76c70..3461549 100644 --- a/src/pixi/textures/BaseTexture.js +++ b/src/pixi/textures/BaseTexture.js @@ -15,6 +15,7 @@ * @uses EventTarget * @constructor * @param source {String} the source object (image or canvas) + * @param scaleMode {Number} Should be one of the PIXI.scaleMode consts */ PIXI.BaseTexture = function(source, scaleMode) { diff --git a/src/pixi/utils/Detector.js b/src/pixi/utils/Detector.js index cf4896b..7054e0f 100644 --- a/src/pixi/utils/Detector.js +++ b/src/pixi/utils/Detector.js @@ -6,7 +6,8 @@ * This helper function will automatically detect which renderer you should be using. * WebGL is the preferred renderer as it is a lot faster. If webGL is not supported by * the browser then this function will return a canvas renderer - * + * @class autoDetectRenderer + * @static * @param width=800 {Number} the width of the renderers view * @param height=600 {Number} the height of the renderers view * @param [view] {Canvas} the canvas to use as a view, optional diff --git a/src/pixi/utils/EventTarget.js b/src/pixi/utils/EventTarget.js index 92dca1f..a772a44 100644 --- a/src/pixi/utils/EventTarget.js +++ b/src/pixi/utils/EventTarget.js @@ -11,7 +11,7 @@ * Adds event emitter functionality to a class * * @class EventTarget - * @example + * * function MyEmitter() { * PIXI.EventTarget.call(this); //mixes in event target stuff * } @@ -21,8 +21,21 @@ */ PIXI.EventTarget = function () { + /** + * Holds all the listeners + * + * @property listeneners + * @type Object + */ var listeners = {}; + /** + * Adds a listener for a specific event + * + * @method addEventListener + * @param type {string} A string representing the event type to listen for. + * @param listener {function} The callback function that will be fired when the event occurs + */ this.addEventListener = this.on = function ( type, listener ) { @@ -39,6 +52,12 @@ }; + /** + * Fires the event, ie pretends that the event has happened + * + * @method dispatchEvent + * @param event {Event} the event object + */ this.dispatchEvent = this.emit = function ( event ) { if ( !listeners[ event.type ] || !listeners[ event.type ].length ) { @@ -55,6 +74,13 @@ }; + /** + * Removes the specified listener that was assigned to the specified event type + * + * @method removeEventListener + * @param type {string} A string representing the event type which will have its listener removed + * @param listener {function} The callback function that was be fired when the event occured + */ this.removeEventListener = this.off = function ( type, listener ) { var index = listeners[ type ].indexOf( listener ); @@ -67,6 +93,12 @@ }; + /** + * Removes all the listeners that were active for the specified event type + * + * @method removeAllEventListeners + * @param type {string} A string representing the event type which will have all its listeners removed + */ this.removeAllEventListeners = function( type ) { var a = listeners[type]; if (a) diff --git a/src/pixi/utils/Polyk.js b/src/pixi/utils/Polyk.js index 8c5d30e..aaf3bdb 100644 --- a/src/pixi/utils/Polyk.js +++ b/src/pixi/utils/Polyk.js @@ -28,17 +28,23 @@ This is an amazing lib! - slightly modified by mat groves (matgroves.com); + slightly modified by Mat Groves (matgroves.com); */ +/** + * Based on the Polyk library http://polyk.ivank.net released under MIT licence. + * This is an amazing lib! + * slightly modified by Mat Groves (matgroves.com); + * @class PolyK + * + */ PIXI.PolyK = {}; /** * Triangulates shapes for webGL graphic fills * * @method Triangulate - * @namespace PolyK - * @constructor + * */ PIXI.PolyK.Triangulate = function(p) { @@ -114,10 +120,17 @@ }; /** - * Checks if a point is within a triangle + * Checks whether a point is within a triangle * - * @class _PointInTriangle - * @namespace PolyK + * @method _PointInTriangle + * @param px {Number} x coordinate of the point to test + * @param py {Number} y coordinate of the point to test + * @param ax {Number} x coordinate of the a point of the triangle + * @param ay {Number} y coordinate of the a point of the triangle + * @param bx {Number} x coordinate of the b point of the triangle + * @param by {Number} y coordinate of the b point of the triangle + * @param cx {Number} x coordinate of the c point of the triangle + * @param cy {Number} y coordinate of the c point of the triangle * @private */ PIXI.PolyK._PointInTriangle = function(px, py, ax, ay, bx, by, cx, cy) @@ -144,10 +157,10 @@ }; /** - * Checks if a shape is convex + * Checks whether a shape is convex * - * @class _convex - * @namespace PolyK + * @method _convex + * * @private */ PIXI.PolyK._convex = function(ax, ay, bx, by, cx, cy, sign) diff --git a/Gruntfile.js b/Gruntfile.js index 0853648..d0215a1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -45,6 +45,7 @@ '<%= dirs.src %>/renderers/webgl/utils/WebGLSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFastSpriteBatch.js', '<%= dirs.src %>/renderers/webgl/utils/WebGLFilterManager.js', + '<%= dirs.src %>/renderers/webgl/utils/FilterTexture.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasMaskManager.js', '<%= dirs.src %>/renderers/canvas/utils/CanvasTinter.js', '<%= dirs.src %>/renderers/canvas/CanvasRenderer.js', @@ -86,7 +87,7 @@ '/**', ' * @license', ' * <%= pkg.name %> - v<%= pkg.version %>', - ' * Copyright (c) 2012, Mat Groves', + ' * Copyright (c) 2012-2014, Mat Groves', ' * <%= pkg.homepage %>', ' *', ' * Compiled: <%= grunt.template.today("yyyy-mm-dd") %>', diff --git a/docs/assets/favicon.png b/docs/assets/favicon.png index 5a95dda..77031a8 100644 --- a/docs/assets/favicon.png +++ b/docs/assets/favicon.png Binary files differ diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index 54975c7..bfd3017 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -21,6 +21,13 @@ PIXI.SpriteBatch.prototype = Object.create( PIXI.DisplayObjectContainer.prototype ); PIXI.SpriteBatch.constructor = PIXI.SpriteBatch; + +/* + * Initialises the spriteBatch + * + * @method initWebGL + * @param gl {WebGLContext} the current WebGL drawing context + */ PIXI.SpriteBatch.prototype.initWebGL = function(gl) { diff --git a/src/pixi/display/Stage.js b/src/pixi/display/Stage.js index 04f8050..e42c772 100644 --- a/src/pixi/display/Stage.js +++ b/src/pixi/display/Stage.js @@ -11,7 +11,7 @@ * @param backgroundColor {Number} the background color of the stage, you have to pass this in is in hex format * like: 0xFFFFFF for white * - * @example Creating a stage is a mandatory process when you use Pixi, which is as simple as this : + * Creating a stage is a mandatory process when you use Pixi, which is as simple as this : * var stage = new PIXI.Stage(0xFFFFFF); * where the parameter given is the background colour of the stage, in hex * you will use this stage instance to add your sprites to it and therefore to the renderer diff --git a/src/pixi/loaders/BitmapFontLoader.js b/src/pixi/loaders/BitmapFontLoader.js index 4fa32d5..7db0a34 100644 --- a/src/pixi/loaders/BitmapFontLoader.js +++ b/src/pixi/loaders/BitmapFontLoader.js @@ -67,7 +67,7 @@ */ PIXI.BitmapFontLoader.prototype.load = function() { - this.ajaxRequest = new XMLHttpRequest(); + this.ajaxRequest = new PIXI.ajaxRequest(); var scope = this; this.ajaxRequest.onreadystatechange = function() { @@ -80,7 +80,7 @@ }; /** - * Invoked when XML file is loaded, parses the data + * Invoked when the XML file is loaded, parses the data * * @method onXMLLoaded * @private diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 6f3c26e..32b75dd 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -102,7 +102,7 @@ this.view = view || document.createElement( "canvas" ); /** - * The canvas 2d context that everything is drawn to + * The canvas 2d context that everything is drawn with * @property context * @type HTMLCanvasElement 2d Context */ diff --git a/src/pixi/renderers/webgl/shaders/PixiFastShader.js b/src/pixi/renderers/webgl/shaders/PixiFastShader.js index 3078d2a..94a4ade 100644 --- a/src/pixi/renderers/webgl/shaders/PixiFastShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiFastShader.js @@ -6,19 +6,25 @@ /** * @class PIXI.PixiFastShader * @constructor +* @param gl {WebGLContext} the current WebGL drawing context */ PIXI.PixiFastShader = function(gl) { + + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** - * @property {any} program - The WebGL program. - */ + * @property {any} program - The WebGL program. + */ this.program = null; /** - * @property {array} fragmentSrc - The fragment shader. - */ + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision lowp float;', 'varying vec2 vTextureCoord;', @@ -29,6 +35,9 @@ '}' ]; + /** + * @property {array} vertexSrc - The vertex shader + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aPositionCoord;', @@ -70,7 +79,9 @@ }; /** -* @method PIXI.PixiFastShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiFastShader.prototype.init = function() { @@ -120,6 +131,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiFastShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/PixiShader.js b/src/pixi/renderers/webgl/shaders/PixiShader.js index 422d3b2..08ecd48 100644 --- a/src/pixi/renderers/webgl/shaders/PixiShader.js +++ b/src/pixi/renderers/webgl/shaders/PixiShader.js @@ -9,6 +9,10 @@ */ PIXI.PixiShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; /** @@ -41,7 +45,9 @@ }; /** -* @method PIXI.PixiShader#init +* Initialises the shader +* @method init +* */ PIXI.PixiShader.prototype.init = function() { @@ -96,7 +102,7 @@ * Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/ * http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf * -* @method PIXI.PixiShader#initUniforms +* @method initUniforms */ PIXI.PixiShader.prototype.initUniforms = function() { @@ -167,7 +173,7 @@ /** * Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded) * -* @method PIXI.PixiShader#initSampler2D +* @method initSampler2D */ PIXI.PixiShader.prototype.initSampler2D = function(uniform) { @@ -242,7 +248,7 @@ /** * Updates the shader uniform values. * -* @method PIXI.PixiShader#syncUniforms +* @method syncUniforms */ PIXI.PixiShader.prototype.syncUniforms = function() { @@ -297,6 +303,11 @@ }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PixiShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); @@ -306,6 +317,11 @@ this.attributes = null; }; +/** +* +* @property defaultVertexSrc +* @type String +*/ PIXI.PixiShader.defaultVertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', diff --git a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js index b653154..c05109f 100644 --- a/src/pixi/renderers/webgl/shaders/PrimitiveShader.js +++ b/src/pixi/renderers/webgl/shaders/PrimitiveShader.js @@ -2,14 +2,28 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class PrimitiveShader +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.PrimitiveShader = function(gl) { + /** + * @property gl + * @type WebGLContext + */ this.gl = gl; - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property fragmentSrc + * @type Array + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec4 vColor;', @@ -19,6 +33,10 @@ '}' ]; + /** + * @property vertexSrc + * @type Array + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec4 aColor;', @@ -40,6 +58,11 @@ this.init(); }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.PrimitiveShader.prototype.init = function() { @@ -66,6 +89,11 @@ this.program = program; }; +/** +* Destroys the shader +* @method destroy +* +*/ PIXI.PrimitiveShader.prototype.destroy = function() { this.gl.deleteProgram( this.program ); diff --git a/src/pixi/renderers/webgl/shaders/StripShader.js b/src/pixi/renderers/webgl/shaders/StripShader.js index 3eab9e3..ae65470 100644 --- a/src/pixi/renderers/webgl/shaders/StripShader.js +++ b/src/pixi/renderers/webgl/shaders/StripShader.js @@ -5,9 +5,14 @@ PIXI.StripShader = function() { - // the webGL program.. + /** + * @property {any} program - The WebGL program. + */ this.program = null; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.fragmentSrc = [ 'precision mediump float;', 'varying vec2 vTextureCoord;', @@ -21,6 +26,9 @@ '}' ]; + /** + * @property {array} fragmentSrc - The fragment shader. + */ this.vertexSrc = [ 'attribute vec2 aVertexPosition;', 'attribute vec2 aTextureCoord;', @@ -41,6 +49,11 @@ ]; }; +/** +* Initialises the shader +* @method init +* +*/ PIXI.StripShader.prototype.init = function() { diff --git a/src/pixi/renderers/webgl/utils/FilterTexture.js b/src/pixi/renderers/webgl/utils/FilterTexture.js new file mode 100644 index 0000000..00b3c8a --- /dev/null +++ b/src/pixi/renderers/webgl/utils/FilterTexture.js @@ -0,0 +1,84 @@ +/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + +/** +* @class FilterTexture +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +* @private +*/ +PIXI.FilterTexture = function(gl, width, height) +{ + /** + * @property gl + * @type WebGLContext + */ + this.gl = gl; + + // next time to create a frame buffer and texture + this.frameBuffer = gl.createFramebuffer(); + this.texture = gl.createTexture(); + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); + gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); + + this.resize(width, height); +}; + + +/** +* Clears the filter texture +* @method clear +*/ +PIXI.FilterTexture.prototype.clear = function() +{ + var gl = this.gl; + + gl.clearColor(0,0,0, 0); + gl.clear(gl.COLOR_BUFFER_BIT); +}; + +/** + * Resizes the texture to the specified width and height + * + * @method resize + * @param width {Number} the new width of the texture + * @param height {Number} the new height of the texture + */ +PIXI.FilterTexture.prototype.resize = function(width, height) +{ + if(this.width === width && this.height === height) return; + + this.width = width; + this.height = height; + + var gl = this.gl; + + gl.bindTexture(gl.TEXTURE_2D, this.texture); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); + +}; + +/** +* Destroys the filter texture +* @method destroy +*/ +PIXI.FilterTexture.prototype.destroy = function() +{ + var gl = this.gl; + gl.deleteFramebuffer( this.frameBuffer ); + gl.deleteTexture( this.texture ); + + this.frameBuffer = null; + this.texture = null; +}; diff --git a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js index 61ab704..dd1303f 100644 --- a/src/pixi/renderers/webgl/utils/WebGLFilterManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLFilterManager.js @@ -2,7 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ - +/** +* @class WebGLFilterManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +* @private +*/ PIXI.WebGLFilterManager = function(gl, transparent) { this.transparent = transparent; @@ -16,7 +22,11 @@ }; // API - +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLFilterManager.prototype.setContext = function(gl) { this.gl = gl; @@ -25,6 +35,12 @@ this.initShaderBuffers(); }; +/** +* +* @method begin +* @param renderSession {RenderSession} +* @param buffer {ArrayBuffer} +*/ PIXI.WebGLFilterManager.prototype.begin = function(renderSession, buffer) { this.renderSession = renderSession; @@ -37,6 +53,11 @@ this.buffer = buffer; }; +/** +* Applies the filter and adds it to the current filter stack +* @method pushFilter +* @param filterBlock {Object} TODO-Alvin +*/ PIXI.WebGLFilterManager.prototype.pushFilter = function(filterBlock) { var gl = this.gl; @@ -118,6 +139,10 @@ }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popFilter +*/ PIXI.WebGLFilterManager.prototype.popFilter = function() { var gl = this.gl; @@ -291,6 +316,15 @@ filterBlock._glFilterTexture = null; }; + +/** +* Applies the filter to the specified area +* @method applyFilterPass +* @param filter {AbstractFilter} the filter that needs to be applied +* @param filterArea {texture} TODO - might need an update +* @param width {Number} the horizontal range of the filter +* @param height {Number} the vertical range of the filter +*/ PIXI.WebGLFilterManager.prototype.applyFilterPass = function(filter, filterArea, width, height) { // use program @@ -343,6 +377,10 @@ this.renderSession.drawCount++; }; +/** +* Initialises the shader buffers +* @method initShaderBuffers +*/ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function() { var gl = this.gl; @@ -399,6 +437,10 @@ gl.STATIC_DRAW); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLFilterManager.prototype.destroy = function() { var gl = this.gl; @@ -420,58 +462,4 @@ gl.deleteBuffer(this.uvBuffer); gl.deleteBuffer(this.colorBuffer); gl.deleteBuffer(this.indexBuffer); -}; - -PIXI.FilterTexture = function(gl, width, height) -{ - this.gl = gl; - - // next time to create a frame buffer and texture - this.frameBuffer = gl.createFramebuffer(); - this.texture = gl.createTexture(); - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer ); - - gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer ); - gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.texture, 0); - - this.resize(width, height); -}; - -PIXI.FilterTexture.prototype.clear = function() -{ - var gl = this.gl; - - gl.clearColor(0,0,0, 0); - gl.clear(gl.COLOR_BUFFER_BIT); -}; - -PIXI.FilterTexture.prototype.resize = function(width, height) -{ - if(this.width === width && this.height === height) return; - - this.width = width; - this.height = height; - - var gl = this.gl; - - gl.bindTexture(gl.TEXTURE_2D, this.texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width, height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null); - -}; - -PIXI.FilterTexture.prototype.destroy = function() -{ - var gl = this.gl; - gl.deleteFramebuffer( this.frameBuffer ); - gl.deleteTexture( this.texture ); - - this.frameBuffer = null; - this.texture = null; -}; - +}; \ No newline at end of file diff --git a/src/pixi/renderers/webgl/utils/WebGLGraphics.js b/src/pixi/renderers/webgl/utils/WebGLGraphics.js index 4956802..44f1323 100644 --- a/src/pixi/renderers/webgl/utils/WebGLGraphics.js +++ b/src/pixi/renderers/webgl/utils/WebGLGraphics.js @@ -5,7 +5,9 @@ /** * A set of functions used by the webGL renderer to draw the primitive graphics data * - * @class CanvasGraphics + * @class WebGLGraphics + * @private + * @static */ PIXI.WebGLGraphics = function() { @@ -19,7 +21,7 @@ * @private * @method renderGraphics * @param graphics {Graphics} - * @param projection {Object} + * @param renderSession {Object} */ PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset) { @@ -91,7 +93,8 @@ * @static * @private * @method updateGraphics - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to update + * @param gl {WebGLContext} the current WebGL drawing context */ PIXI.WebGLGraphics.updateGraphics = function(graphics, gl) { @@ -145,7 +148,7 @@ * @static * @private * @method buildRectangle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData) @@ -214,7 +217,7 @@ * @static * @private * @method buildCircle - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw * @param webGLData {Object} */ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData) @@ -287,7 +290,7 @@ * @static * @private * @method buildLine - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData) @@ -497,7 +500,7 @@ * @static * @private * @method buildPoly - * @param graphics {Graphics} + * @param graphicsData {Graphics} The graphics object to draw TODO-Alvin * @param webGLData {Object} */ PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData) diff --git a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js index a929c8f..12a7849 100644 --- a/src/pixi/renderers/webgl/utils/WebGLMaskManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLMaskManager.js @@ -2,6 +2,13 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ + +/** +* @class WebGLMaskManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLMaskManager = function(gl) { this.maskStack = []; @@ -10,11 +17,22 @@ this.setContext(gl); }; +/** +* Sets the drawing context to the one given in parameter +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLMaskManager.prototype.setContext = function(gl) { this.gl = gl; }; +/** +* Applies the Mask and adds it to the current filter stack +* @method pushMask +* @param maskData {Array} +* @param renderSession {RenderSession} +*/ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession) { var gl = this.gl; @@ -39,6 +57,12 @@ gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP); }; +/** +* Removes the last filter from the filter stack and doesn't return it +* @method popMask +* +* @param renderSession {RenderSession} TODO-Alvin +*/ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession) { var gl = this.gl; @@ -62,6 +86,10 @@ if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST); }; +/** +* TODO-Alvin +* @method destroy +*/ PIXI.WebGLMaskManager.prototype.destroy = function() { this.maskStack = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js index 5355259..17e5937 100644 --- a/src/pixi/renderers/webgl/utils/WebGLShaderManager.js +++ b/src/pixi/renderers/webgl/utils/WebGLShaderManager.js @@ -2,6 +2,12 @@ * @author Mat Groves http://matgroves.com/ @Doormat23 */ +/** +* @class WebGLShaderManager +* @constructor +* @param gl {WebGLContext} the current WebGL drawing context +* @private +*/ PIXI.WebGLShaderManager = function(gl) { @@ -18,6 +24,13 @@ //this.stripShader = new PIXI.StripShader(gl); }; + +/** +* Initialises the context and the properties +* @method setContext +* @param gl {WebGLContext} the current WebGL drawing context +* @param transparent {Boolean} Whether or not the drawing context should be transparent +*/ PIXI.WebGLShaderManager.prototype.setContext = function(gl) { this.gl = gl; @@ -36,6 +49,11 @@ }; +/** +* Initialises the context and the properties +* @method setAttribs +* @param attribs {Array} TODO-Alvin +*/ PIXI.WebGLShaderManager.prototype.setAttribs = function(attribs) { // reset temp state @@ -77,6 +95,11 @@ // console.log(this.tempAttribState) }; +/** +* TODO-Alvin +* @method activateShader +* @param shader {Object} the shader that is going to be activated +*/ PIXI.WebGLShaderManager.prototype.activateShader = function(shader) { //if(this.currentShader == shader)return; @@ -90,6 +113,10 @@ }; +/** +* Triggers the primitive shader +* @method activatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function() { var gl = this.gl; @@ -100,6 +127,10 @@ }; +/** +* Disable the primitive shader +* @method deactivatePrimitiveShader +*/ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function() { var gl = this.gl; @@ -109,6 +140,10 @@ this.setAttribs(this.defaultShader.attributes); }; +/** +* Destroys +* @method destroy +*/ PIXI.WebGLShaderManager.prototype.destroy = function() { this.attribState = null; diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index 672de62..bf151bf 100644 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -8,11 +8,30 @@ * https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/WebGLSpriteBatch.java */ + /** + * + * @class WebGLSpriteBatch + * @private + * @constructor + * @param gl {WebGLContext} the current WebGL drawing context + * + */ PIXI.WebGLSpriteBatch = function(gl) { - + /** + * TODO-Alvin + * + * @property vertSize + * @type Number + */ this.vertSize = 6; + + /** + * TODO-Alvin + * @property size + * @type Number + */ this.size = 10000;//Math.pow(2, 16) / this.vertSize; // console.log(this.size); @@ -21,9 +40,23 @@ //the total number of indices in our batch var numIndices = this.size * 6; - //vertex data + //vertex data + + /** + * Holds the vertices + * + * @property vertices + * @type Float32Array + */ this.vertices = new Float32Array(numVerts); + //index data + /** + * Holds the indices + * + * @property indices + * @type Uint16Array + */ this.indices = new Uint16Array(numIndices); this.lastIndexCount = 0; @@ -46,6 +79,12 @@ this.setContext(gl); }; +/** +* +* @method setContext +* +* @param gl {WebGLContext} the current WebGL drawing context +*/ PIXI.WebGLSpriteBatch.prototype.setContext = function(gl) { this.gl = gl; @@ -67,6 +106,12 @@ this.currentBlendMode = 99999; }; +/** +* +* @method begin +* +* @param renderSession {RenderSession} the RenderSession +*/ PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession) { this.renderSession = renderSession; @@ -75,12 +120,22 @@ this.start(); }; +/** +* +* @method end +* +*/ PIXI.WebGLSpriteBatch.prototype.end = function() { this.flush(); }; - +/** +* +* @method render +* +* @param sprite {Sprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.render = function(sprite) { // check texture.. @@ -194,6 +249,12 @@ }; +/** +* +* @method renderTilingSprite +* +* @param sprite {TilingSprite} the sprite to render TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite) { var texture = tilingSprite.tilingTexture; @@ -309,6 +370,13 @@ this.currentBatchSize++; }; + +/** +* +* +* @method flush TODO-Alvin +* +*/ PIXI.WebGLSpriteBatch.prototype.flush = function() { // If the batch is length 0 then return as there is nothing to draw @@ -345,12 +413,21 @@ this.renderSession.drawCount++; }; - +/** +* +* @method stop +* +*/ PIXI.WebGLSpriteBatch.prototype.stop = function() { this.flush(); }; +/** +* +* @method start +* +*/ PIXI.WebGLSpriteBatch.prototype.start = function() { var gl = this.gl; @@ -379,6 +456,13 @@ } }; +/** +* +* @method setBlendMode +* +* @param blendMode {Number} the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD +* TODO-Alvin +*/ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode) { this.flush(); @@ -389,6 +473,10 @@ this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); }; +/** +* Destroys the SpriteBatch +* @method destroy +*/ PIXI.WebGLSpriteBatch.prototype.destroy = function() { diff --git a/src/pixi/text/BitmapText.js b/src/pixi/text/BitmapText.js index ca1aaa2..b617c7f 100644 --- a/src/pixi/text/BitmapText.js +++ b/src/pixi/text/BitmapText.js @@ -44,11 +44,11 @@ /** * Set the style of the text + * style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) + * [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text * * @method setStyle - * @param style {Object} The style parameters - * @param style.font {String} The size (optional) and bitmap font id (required) eq 'Arial' or '20px Arial' (must have loaded previously) - * @param [style.align='left'] {String} Alignment for multiline text ('left', 'center' or 'right'), does not affect single line text + * @param style {Object} The style parameters, contained as properties of an object */ PIXI.BitmapText.prototype.setStyle = function(style) { diff --git a/src/pixi/text/Text.js b/src/pixi/text/Text.js index 7393942..5244ca2 100644 --- a/src/pixi/text/Text.js +++ b/src/pixi/text/Text.js @@ -20,8 +20,21 @@ */ PIXI.Text = function(text, style) { + /** + * The canvas element that everything is drawn to + * + * @property canvas + * @type HTMLCanvasElement + */ this.canvas = document.createElement('canvas'); + + /** + * The canvas 2d context that everything is drawn with + * @property context + * @type HTMLCanvasElement 2d Context + */ this.context = this.canvas.getContext('2d'); + PIXI.Sprite.call(this, PIXI.Texture.fromCanvas(this.canvas)); this.setText(text); @@ -167,6 +180,13 @@ this.requiresUpdate = true; }; +/** +* Renders the object using the WebGL renderer +* +* @method _renderWebGL +* @param renderSession {RenderSession} +* @private +*/ PIXI.Text.prototype._renderWebGL = function(renderSession) { if(this.requiresUpdate) @@ -198,6 +218,7 @@ /* * http://stackoverflow.com/users/34441/ellisbben * great solution to the problem! + * returns the height of the given font * * @method determineFontHeight * @param fontStyle {Object} diff --git a/src/pixi/textures/BaseTexture.js b/src/pixi/textures/BaseTexture.js index df76c70..3461549 100644 --- a/src/pixi/textures/BaseTexture.js +++ b/src/pixi/textures/BaseTexture.js @@ -15,6 +15,7 @@ * @uses EventTarget * @constructor * @param source {String} the source object (image or canvas) + * @param scaleMode {Number} Should be one of the PIXI.scaleMode consts */ PIXI.BaseTexture = function(source, scaleMode) { diff --git a/src/pixi/utils/Detector.js b/src/pixi/utils/Detector.js index cf4896b..7054e0f 100644 --- a/src/pixi/utils/Detector.js +++ b/src/pixi/utils/Detector.js @@ -6,7 +6,8 @@ * This helper function will automatically detect which renderer you should be using. * WebGL is the preferred renderer as it is a lot faster. If webGL is not supported by * the browser then this function will return a canvas renderer - * + * @class autoDetectRenderer + * @static * @param width=800 {Number} the width of the renderers view * @param height=600 {Number} the height of the renderers view * @param [view] {Canvas} the canvas to use as a view, optional diff --git a/src/pixi/utils/EventTarget.js b/src/pixi/utils/EventTarget.js index 92dca1f..a772a44 100644 --- a/src/pixi/utils/EventTarget.js +++ b/src/pixi/utils/EventTarget.js @@ -11,7 +11,7 @@ * Adds event emitter functionality to a class * * @class EventTarget - * @example + * * function MyEmitter() { * PIXI.EventTarget.call(this); //mixes in event target stuff * } @@ -21,8 +21,21 @@ */ PIXI.EventTarget = function () { + /** + * Holds all the listeners + * + * @property listeneners + * @type Object + */ var listeners = {}; + /** + * Adds a listener for a specific event + * + * @method addEventListener + * @param type {string} A string representing the event type to listen for. + * @param listener {function} The callback function that will be fired when the event occurs + */ this.addEventListener = this.on = function ( type, listener ) { @@ -39,6 +52,12 @@ }; + /** + * Fires the event, ie pretends that the event has happened + * + * @method dispatchEvent + * @param event {Event} the event object + */ this.dispatchEvent = this.emit = function ( event ) { if ( !listeners[ event.type ] || !listeners[ event.type ].length ) { @@ -55,6 +74,13 @@ }; + /** + * Removes the specified listener that was assigned to the specified event type + * + * @method removeEventListener + * @param type {string} A string representing the event type which will have its listener removed + * @param listener {function} The callback function that was be fired when the event occured + */ this.removeEventListener = this.off = function ( type, listener ) { var index = listeners[ type ].indexOf( listener ); @@ -67,6 +93,12 @@ }; + /** + * Removes all the listeners that were active for the specified event type + * + * @method removeAllEventListeners + * @param type {string} A string representing the event type which will have all its listeners removed + */ this.removeAllEventListeners = function( type ) { var a = listeners[type]; if (a) diff --git a/src/pixi/utils/Polyk.js b/src/pixi/utils/Polyk.js index 8c5d30e..aaf3bdb 100644 --- a/src/pixi/utils/Polyk.js +++ b/src/pixi/utils/Polyk.js @@ -28,17 +28,23 @@ This is an amazing lib! - slightly modified by mat groves (matgroves.com); + slightly modified by Mat Groves (matgroves.com); */ +/** + * Based on the Polyk library http://polyk.ivank.net released under MIT licence. + * This is an amazing lib! + * slightly modified by Mat Groves (matgroves.com); + * @class PolyK + * + */ PIXI.PolyK = {}; /** * Triangulates shapes for webGL graphic fills * * @method Triangulate - * @namespace PolyK - * @constructor + * */ PIXI.PolyK.Triangulate = function(p) { @@ -114,10 +120,17 @@ }; /** - * Checks if a point is within a triangle + * Checks whether a point is within a triangle * - * @class _PointInTriangle - * @namespace PolyK + * @method _PointInTriangle + * @param px {Number} x coordinate of the point to test + * @param py {Number} y coordinate of the point to test + * @param ax {Number} x coordinate of the a point of the triangle + * @param ay {Number} y coordinate of the a point of the triangle + * @param bx {Number} x coordinate of the b point of the triangle + * @param by {Number} y coordinate of the b point of the triangle + * @param cx {Number} x coordinate of the c point of the triangle + * @param cy {Number} y coordinate of the c point of the triangle * @private */ PIXI.PolyK._PointInTriangle = function(px, py, ax, ay, bx, by, cx, cy) @@ -144,10 +157,10 @@ }; /** - * Checks if a shape is convex + * Checks whether a shape is convex * - * @class _convex - * @namespace PolyK + * @method _convex + * * @private */ PIXI.PolyK._convex = function(ax, ay, bx, by, cx, cy, sign) diff --git a/src/pixi/utils/Utils.js b/src/pixi/utils/Utils.js index 7328b18..0b2accd 100644 --- a/src/pixi/utils/Utils.js +++ b/src/pixi/utils/Utils.js @@ -102,7 +102,7 @@ * @class AjaxRequest * @constructor */ -PIXI.AjaxRequest = function AjaxRequest() +PIXI.AjaxRequest = function() { var activexmodes = ['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.3.0', 'Microsoft.XMLHTTP']; //activeX versions to check for in IE