diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js index 958661f..88db356 100644 --- a/src/core/display/ObservablePoint.js +++ b/src/core/display/ObservablePoint.js @@ -4,6 +4,7 @@ * * @class * @memberof PIXI + * @param transform {PIXI.Transform} the transform object @mat * @param [x=0] {number} position of the point on the x axis * @param [y=0] {number} position of the point on the y axis */ @@ -25,7 +26,7 @@ * The position of the displayObject on the x axis relative to the local coordinates of the parent. * * @member {number} - * @memberof PIXI.DisplayObject# + * @memberof PIXI.ObservablePoint# */ x: { get: function () @@ -38,7 +39,12 @@ this.transform._versionLocal++; } }, - + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ y: { get: function () { diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js index 958661f..88db356 100644 --- a/src/core/display/ObservablePoint.js +++ b/src/core/display/ObservablePoint.js @@ -4,6 +4,7 @@ * * @class * @memberof PIXI + * @param transform {PIXI.Transform} the transform object @mat * @param [x=0] {number} position of the point on the x axis * @param [y=0] {number} position of the point on the y axis */ @@ -25,7 +26,7 @@ * The position of the displayObject on the x axis relative to the local coordinates of the parent. * * @member {number} - * @memberof PIXI.DisplayObject# + * @memberof PIXI.ObservablePoint# */ x: { get: function () @@ -38,7 +39,12 @@ this.transform._versionLocal++; } }, - + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ y: { get: function () { diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 0d6f061..787106a 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -2,8 +2,7 @@ /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. + * Generic class to deal with traditional 2D matrix transforms * * @class * @memberof PIXI @@ -12,7 +11,13 @@ */ function Transform() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); /** @@ -35,17 +40,27 @@ * @member {PIXI.Point} */ this.pivot = new math.Point(0.0); - + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; this._sr = Math.sin(0); this._cr = Math.cos(0); - + this.updated = true; } Transform.prototype.constructor = Transform; +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ Transform.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -65,10 +80,8 @@ wt.c = lt.c * pt.a + lt.d * pt.c; wt.d = lt.c * pt.b + lt.d * pt.d; wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; } module.exports = Transform; - - diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js index 958661f..88db356 100644 --- a/src/core/display/ObservablePoint.js +++ b/src/core/display/ObservablePoint.js @@ -4,6 +4,7 @@ * * @class * @memberof PIXI + * @param transform {PIXI.Transform} the transform object @mat * @param [x=0] {number} position of the point on the x axis * @param [y=0] {number} position of the point on the y axis */ @@ -25,7 +26,7 @@ * The position of the displayObject on the x axis relative to the local coordinates of the parent. * * @member {number} - * @memberof PIXI.DisplayObject# + * @memberof PIXI.ObservablePoint# */ x: { get: function () @@ -38,7 +39,12 @@ this.transform._versionLocal++; } }, - + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ y: { get: function () { diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 0d6f061..787106a 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -2,8 +2,7 @@ /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. + * Generic class to deal with traditional 2D matrix transforms * * @class * @memberof PIXI @@ -12,7 +11,13 @@ */ function Transform() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); /** @@ -35,17 +40,27 @@ * @member {PIXI.Point} */ this.pivot = new math.Point(0.0); - + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; this._sr = Math.sin(0); this._cr = Math.cos(0); - + this.updated = true; } Transform.prototype.constructor = Transform; +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ Transform.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -65,10 +80,8 @@ wt.c = lt.c * pt.a + lt.d * pt.c; wt.d = lt.c * pt.b + lt.d * pt.d; wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; } module.exports = Transform; - - diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index b86aa2d..30d7823 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -13,15 +13,50 @@ */ function TransformStatic() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); - this.position = new ObservablePoint(this, 0); - this.scale = new ObservablePoint(this,1, 1); - this.pivot = new ObservablePoint(this, 0, 0); - this.skew = new ObservablePoint(this, 0,0); + /** + * The coordinate of the object relative to the local coordinates of the parent. + * + * @member {PIXI.ObservablePoint} + */ + this.position = new ObservablePoint(this,0.0); + /** + * The scale factor of the object. + * + * @member {PIXI.ObservablePoint} + */ + this.scale = new ObservablePoint(this,1,1); + + /** + * The pivot point of the displayObject that it rotates around + * + * @member {PIXI.ObservablePoint} + */ + this.pivot = new ObservablePoint(this,0.0); + + /** + * The skew amount, on the x and y axis. + * + * @member {PIXI.ObservablePoint} + */ + this.skew = new ObservablePoint(this,0.0); + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; + this._sr = Math.sin(0); this._cr = Math.cos(0); @@ -35,6 +70,12 @@ TransformStatic.prototype.constructor = TransformStatic; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ TransformStatic.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -71,5 +112,3 @@ }; module.exports = TransformStatic; - - diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js index 958661f..88db356 100644 --- a/src/core/display/ObservablePoint.js +++ b/src/core/display/ObservablePoint.js @@ -4,6 +4,7 @@ * * @class * @memberof PIXI + * @param transform {PIXI.Transform} the transform object @mat * @param [x=0] {number} position of the point on the x axis * @param [y=0] {number} position of the point on the y axis */ @@ -25,7 +26,7 @@ * The position of the displayObject on the x axis relative to the local coordinates of the parent. * * @member {number} - * @memberof PIXI.DisplayObject# + * @memberof PIXI.ObservablePoint# */ x: { get: function () @@ -38,7 +39,12 @@ this.transform._versionLocal++; } }, - + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ y: { get: function () { diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 0d6f061..787106a 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -2,8 +2,7 @@ /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. + * Generic class to deal with traditional 2D matrix transforms * * @class * @memberof PIXI @@ -12,7 +11,13 @@ */ function Transform() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); /** @@ -35,17 +40,27 @@ * @member {PIXI.Point} */ this.pivot = new math.Point(0.0); - + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; this._sr = Math.sin(0); this._cr = Math.cos(0); - + this.updated = true; } Transform.prototype.constructor = Transform; +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ Transform.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -65,10 +80,8 @@ wt.c = lt.c * pt.a + lt.d * pt.c; wt.d = lt.c * pt.b + lt.d * pt.d; wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; } module.exports = Transform; - - diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index b86aa2d..30d7823 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -13,15 +13,50 @@ */ function TransformStatic() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); - this.position = new ObservablePoint(this, 0); - this.scale = new ObservablePoint(this,1, 1); - this.pivot = new ObservablePoint(this, 0, 0); - this.skew = new ObservablePoint(this, 0,0); + /** + * The coordinate of the object relative to the local coordinates of the parent. + * + * @member {PIXI.ObservablePoint} + */ + this.position = new ObservablePoint(this,0.0); + /** + * The scale factor of the object. + * + * @member {PIXI.ObservablePoint} + */ + this.scale = new ObservablePoint(this,1,1); + + /** + * The pivot point of the displayObject that it rotates around + * + * @member {PIXI.ObservablePoint} + */ + this.pivot = new ObservablePoint(this,0.0); + + /** + * The skew amount, on the x and y axis. + * + * @member {PIXI.ObservablePoint} + */ + this.skew = new ObservablePoint(this,0.0); + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; + this._sr = Math.sin(0); this._cr = Math.cos(0); @@ -35,6 +70,12 @@ TransformStatic.prototype.constructor = TransformStatic; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ TransformStatic.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -71,5 +112,3 @@ }; module.exports = TransformStatic; - - diff --git a/src/core/graphics/canvas/CanvasGraphicsRenderer.js b/src/core/graphics/canvas/CanvasGraphicsRenderer.js index 4cefba4..c635c8e 100644 --- a/src/core/graphics/canvas/CanvasGraphicsRenderer.js +++ b/src/core/graphics/canvas/CanvasGraphicsRenderer.js @@ -13,13 +13,13 @@ */ /** - * Renderer dedicated to drawing and batching sprites. + * Renderer dedicated to drawing and batching graphics objects. * * @class * @private * @memberof PIXI * @extends PIXI.ObjectRenderer - * @param renderer {PIXI.WebGLRenderer} The renderer sprite this batch works for. + * @param renderer {PIXI.SystemRenderer} The current PIXI renderer. */ function CanvasGraphicsRenderer(renderer) { diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js index 958661f..88db356 100644 --- a/src/core/display/ObservablePoint.js +++ b/src/core/display/ObservablePoint.js @@ -4,6 +4,7 @@ * * @class * @memberof PIXI + * @param transform {PIXI.Transform} the transform object @mat * @param [x=0] {number} position of the point on the x axis * @param [y=0] {number} position of the point on the y axis */ @@ -25,7 +26,7 @@ * The position of the displayObject on the x axis relative to the local coordinates of the parent. * * @member {number} - * @memberof PIXI.DisplayObject# + * @memberof PIXI.ObservablePoint# */ x: { get: function () @@ -38,7 +39,12 @@ this.transform._versionLocal++; } }, - + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ y: { get: function () { diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 0d6f061..787106a 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -2,8 +2,7 @@ /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. + * Generic class to deal with traditional 2D matrix transforms * * @class * @memberof PIXI @@ -12,7 +11,13 @@ */ function Transform() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); /** @@ -35,17 +40,27 @@ * @member {PIXI.Point} */ this.pivot = new math.Point(0.0); - + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; this._sr = Math.sin(0); this._cr = Math.cos(0); - + this.updated = true; } Transform.prototype.constructor = Transform; +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ Transform.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -65,10 +80,8 @@ wt.c = lt.c * pt.a + lt.d * pt.c; wt.d = lt.c * pt.b + lt.d * pt.d; wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; } module.exports = Transform; - - diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index b86aa2d..30d7823 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -13,15 +13,50 @@ */ function TransformStatic() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); - this.position = new ObservablePoint(this, 0); - this.scale = new ObservablePoint(this,1, 1); - this.pivot = new ObservablePoint(this, 0, 0); - this.skew = new ObservablePoint(this, 0,0); + /** + * The coordinate of the object relative to the local coordinates of the parent. + * + * @member {PIXI.ObservablePoint} + */ + this.position = new ObservablePoint(this,0.0); + /** + * The scale factor of the object. + * + * @member {PIXI.ObservablePoint} + */ + this.scale = new ObservablePoint(this,1,1); + + /** + * The pivot point of the displayObject that it rotates around + * + * @member {PIXI.ObservablePoint} + */ + this.pivot = new ObservablePoint(this,0.0); + + /** + * The skew amount, on the x and y axis. + * + * @member {PIXI.ObservablePoint} + */ + this.skew = new ObservablePoint(this,0.0); + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; + this._sr = Math.sin(0); this._cr = Math.cos(0); @@ -35,6 +70,12 @@ TransformStatic.prototype.constructor = TransformStatic; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ TransformStatic.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -71,5 +112,3 @@ }; module.exports = TransformStatic; - - diff --git a/src/core/graphics/canvas/CanvasGraphicsRenderer.js b/src/core/graphics/canvas/CanvasGraphicsRenderer.js index 4cefba4..c635c8e 100644 --- a/src/core/graphics/canvas/CanvasGraphicsRenderer.js +++ b/src/core/graphics/canvas/CanvasGraphicsRenderer.js @@ -13,13 +13,13 @@ */ /** - * Renderer dedicated to drawing and batching sprites. + * Renderer dedicated to drawing and batching graphics objects. * * @class * @private * @memberof PIXI * @extends PIXI.ObjectRenderer - * @param renderer {PIXI.WebGLRenderer} The renderer sprite this batch works for. + * @param renderer {PIXI.SystemRenderer} The current PIXI renderer. */ function CanvasGraphicsRenderer(renderer) { diff --git a/src/core/graphics/webgl/WebGLGraphicsData.js b/src/core/graphics/webgl/WebGLGraphicsData.js index 2c8896d..6cee5cc 100644 --- a/src/core/graphics/webgl/WebGLGraphicsData.js +++ b/src/core/graphics/webgl/WebGLGraphicsData.js @@ -9,7 +9,7 @@ * @param gl {WebGLRenderingContext} the current WebGL drawing context * @private */ -function WebGLGraphicsData(gl, shader) +function WebGLGraphicsData(gl, shader) { /** @@ -58,9 +58,12 @@ this.glPoints = null; this.glIndices = null; - + /** + * + * @member {PIXI.Shader} + */ this.shader = shader; - + this.vao = new glCore.VertexArrayObject(gl) .addIndex(this.indexBuffer) .addAttribute(this.buffer, shader.attributes.aVertexPosition, gl.FLOAT, false, 4 * 6, 0) @@ -73,7 +76,7 @@ /** * Resets the vertices and the indices */ -WebGLGraphicsData.prototype.reset = function () +WebGLGraphicsData.prototype.reset = function () { this.points.length = 0; this.indices.length = 0; @@ -82,7 +85,7 @@ /** * Binds the buffers and uploads the data */ -WebGLGraphicsData.prototype.upload = function () +WebGLGraphicsData.prototype.upload = function () { var gl = this.gl; @@ -96,8 +99,10 @@ }; - -WebGLGraphicsData.prototype.destroy = function () +/** + * Empties all the data + */ +WebGLGraphicsData.prototype.destroy = function () { this.color = null; this.points = null; @@ -106,7 +111,7 @@ this.vao.destroy(); this.buffer.destroy(); this.indexBuffer.destroy(); - + this.gl = null; this.buffer = null; diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js index 958661f..88db356 100644 --- a/src/core/display/ObservablePoint.js +++ b/src/core/display/ObservablePoint.js @@ -4,6 +4,7 @@ * * @class * @memberof PIXI + * @param transform {PIXI.Transform} the transform object @mat * @param [x=0] {number} position of the point on the x axis * @param [y=0] {number} position of the point on the y axis */ @@ -25,7 +26,7 @@ * The position of the displayObject on the x axis relative to the local coordinates of the parent. * * @member {number} - * @memberof PIXI.DisplayObject# + * @memberof PIXI.ObservablePoint# */ x: { get: function () @@ -38,7 +39,12 @@ this.transform._versionLocal++; } }, - + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ y: { get: function () { diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 0d6f061..787106a 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -2,8 +2,7 @@ /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. + * Generic class to deal with traditional 2D matrix transforms * * @class * @memberof PIXI @@ -12,7 +11,13 @@ */ function Transform() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); /** @@ -35,17 +40,27 @@ * @member {PIXI.Point} */ this.pivot = new math.Point(0.0); - + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; this._sr = Math.sin(0); this._cr = Math.cos(0); - + this.updated = true; } Transform.prototype.constructor = Transform; +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ Transform.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -65,10 +80,8 @@ wt.c = lt.c * pt.a + lt.d * pt.c; wt.d = lt.c * pt.b + lt.d * pt.d; wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; } module.exports = Transform; - - diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index b86aa2d..30d7823 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -13,15 +13,50 @@ */ function TransformStatic() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); - this.position = new ObservablePoint(this, 0); - this.scale = new ObservablePoint(this,1, 1); - this.pivot = new ObservablePoint(this, 0, 0); - this.skew = new ObservablePoint(this, 0,0); + /** + * The coordinate of the object relative to the local coordinates of the parent. + * + * @member {PIXI.ObservablePoint} + */ + this.position = new ObservablePoint(this,0.0); + /** + * The scale factor of the object. + * + * @member {PIXI.ObservablePoint} + */ + this.scale = new ObservablePoint(this,1,1); + + /** + * The pivot point of the displayObject that it rotates around + * + * @member {PIXI.ObservablePoint} + */ + this.pivot = new ObservablePoint(this,0.0); + + /** + * The skew amount, on the x and y axis. + * + * @member {PIXI.ObservablePoint} + */ + this.skew = new ObservablePoint(this,0.0); + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; + this._sr = Math.sin(0); this._cr = Math.cos(0); @@ -35,6 +70,12 @@ TransformStatic.prototype.constructor = TransformStatic; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ TransformStatic.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -71,5 +112,3 @@ }; module.exports = TransformStatic; - - diff --git a/src/core/graphics/canvas/CanvasGraphicsRenderer.js b/src/core/graphics/canvas/CanvasGraphicsRenderer.js index 4cefba4..c635c8e 100644 --- a/src/core/graphics/canvas/CanvasGraphicsRenderer.js +++ b/src/core/graphics/canvas/CanvasGraphicsRenderer.js @@ -13,13 +13,13 @@ */ /** - * Renderer dedicated to drawing and batching sprites. + * Renderer dedicated to drawing and batching graphics objects. * * @class * @private * @memberof PIXI * @extends PIXI.ObjectRenderer - * @param renderer {PIXI.WebGLRenderer} The renderer sprite this batch works for. + * @param renderer {PIXI.SystemRenderer} The current PIXI renderer. */ function CanvasGraphicsRenderer(renderer) { diff --git a/src/core/graphics/webgl/WebGLGraphicsData.js b/src/core/graphics/webgl/WebGLGraphicsData.js index 2c8896d..6cee5cc 100644 --- a/src/core/graphics/webgl/WebGLGraphicsData.js +++ b/src/core/graphics/webgl/WebGLGraphicsData.js @@ -9,7 +9,7 @@ * @param gl {WebGLRenderingContext} the current WebGL drawing context * @private */ -function WebGLGraphicsData(gl, shader) +function WebGLGraphicsData(gl, shader) { /** @@ -58,9 +58,12 @@ this.glPoints = null; this.glIndices = null; - + /** + * + * @member {PIXI.Shader} + */ this.shader = shader; - + this.vao = new glCore.VertexArrayObject(gl) .addIndex(this.indexBuffer) .addAttribute(this.buffer, shader.attributes.aVertexPosition, gl.FLOAT, false, 4 * 6, 0) @@ -73,7 +76,7 @@ /** * Resets the vertices and the indices */ -WebGLGraphicsData.prototype.reset = function () +WebGLGraphicsData.prototype.reset = function () { this.points.length = 0; this.indices.length = 0; @@ -82,7 +85,7 @@ /** * Binds the buffers and uploads the data */ -WebGLGraphicsData.prototype.upload = function () +WebGLGraphicsData.prototype.upload = function () { var gl = this.gl; @@ -96,8 +99,10 @@ }; - -WebGLGraphicsData.prototype.destroy = function () +/** + * Empties all the data + */ +WebGLGraphicsData.prototype.destroy = function () { this.color = null; this.points = null; @@ -106,7 +111,7 @@ this.vao.destroy(); this.buffer.destroy(); this.indexBuffer.destroy(); - + this.gl = null; this.buffer = null; diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index 038338b..33d25d5 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -8,15 +8,30 @@ * * @class * @memberof PIXI - * @param gl {WebGLRenderingContext} + * @param renderer {PIXI.WebGLRenderer} */ - var TextureManager = function(renderer) { + /** + * A reference to the current renderer + * + * @member {PIXI.WebGLRenderer} + */ this.renderer = renderer; + + /** + * The current WebGL rendering context + * + * @member {WebGLRenderingContext} + */ this.gl = renderer.gl; - // track textures in the renderer so we can no longer listen to them on destruction. + /** + * Track textures in the renderer so we can no longer listen to them on destruction. + * + * @member {array} + * @private + */ this._managedTextures = []; } @@ -68,19 +83,19 @@ texture.on('update', this.updateTexture, this); texture.on('dispose', this.destroyTexture, this); - + this._managedTextures.push(texture); - - + + if(texture.isPowerOfTwo) - { + { if(texture.mipmap) { glTexture.enableMipmap(); } - + if(texture.wrapMode === CONST.WRAP_MODES.CLAMP) { glTexture.enableWrapClamp(); @@ -152,6 +167,9 @@ } } +/** + * Deletes all the textures from WebGL + */ TextureManager.prototype.removeAll = function() { // empty all the old gl textures as they are useless now @@ -165,6 +183,9 @@ } } +/** + * Destroys this manager and removes all its textures + */ TextureManager.prototype.destroy = function() { // destroy managed textures @@ -180,4 +201,3 @@ } module.exports = TextureManager; - diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js index 958661f..88db356 100644 --- a/src/core/display/ObservablePoint.js +++ b/src/core/display/ObservablePoint.js @@ -4,6 +4,7 @@ * * @class * @memberof PIXI + * @param transform {PIXI.Transform} the transform object @mat * @param [x=0] {number} position of the point on the x axis * @param [y=0] {number} position of the point on the y axis */ @@ -25,7 +26,7 @@ * The position of the displayObject on the x axis relative to the local coordinates of the parent. * * @member {number} - * @memberof PIXI.DisplayObject# + * @memberof PIXI.ObservablePoint# */ x: { get: function () @@ -38,7 +39,12 @@ this.transform._versionLocal++; } }, - + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ y: { get: function () { diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 0d6f061..787106a 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -2,8 +2,7 @@ /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. + * Generic class to deal with traditional 2D matrix transforms * * @class * @memberof PIXI @@ -12,7 +11,13 @@ */ function Transform() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); /** @@ -35,17 +40,27 @@ * @member {PIXI.Point} */ this.pivot = new math.Point(0.0); - + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; this._sr = Math.sin(0); this._cr = Math.cos(0); - + this.updated = true; } Transform.prototype.constructor = Transform; +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ Transform.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -65,10 +80,8 @@ wt.c = lt.c * pt.a + lt.d * pt.c; wt.d = lt.c * pt.b + lt.d * pt.d; wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; } module.exports = Transform; - - diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index b86aa2d..30d7823 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -13,15 +13,50 @@ */ function TransformStatic() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); - this.position = new ObservablePoint(this, 0); - this.scale = new ObservablePoint(this,1, 1); - this.pivot = new ObservablePoint(this, 0, 0); - this.skew = new ObservablePoint(this, 0,0); + /** + * The coordinate of the object relative to the local coordinates of the parent. + * + * @member {PIXI.ObservablePoint} + */ + this.position = new ObservablePoint(this,0.0); + /** + * The scale factor of the object. + * + * @member {PIXI.ObservablePoint} + */ + this.scale = new ObservablePoint(this,1,1); + + /** + * The pivot point of the displayObject that it rotates around + * + * @member {PIXI.ObservablePoint} + */ + this.pivot = new ObservablePoint(this,0.0); + + /** + * The skew amount, on the x and y axis. + * + * @member {PIXI.ObservablePoint} + */ + this.skew = new ObservablePoint(this,0.0); + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; + this._sr = Math.sin(0); this._cr = Math.cos(0); @@ -35,6 +70,12 @@ TransformStatic.prototype.constructor = TransformStatic; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ TransformStatic.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -71,5 +112,3 @@ }; module.exports = TransformStatic; - - diff --git a/src/core/graphics/canvas/CanvasGraphicsRenderer.js b/src/core/graphics/canvas/CanvasGraphicsRenderer.js index 4cefba4..c635c8e 100644 --- a/src/core/graphics/canvas/CanvasGraphicsRenderer.js +++ b/src/core/graphics/canvas/CanvasGraphicsRenderer.js @@ -13,13 +13,13 @@ */ /** - * Renderer dedicated to drawing and batching sprites. + * Renderer dedicated to drawing and batching graphics objects. * * @class * @private * @memberof PIXI * @extends PIXI.ObjectRenderer - * @param renderer {PIXI.WebGLRenderer} The renderer sprite this batch works for. + * @param renderer {PIXI.SystemRenderer} The current PIXI renderer. */ function CanvasGraphicsRenderer(renderer) { diff --git a/src/core/graphics/webgl/WebGLGraphicsData.js b/src/core/graphics/webgl/WebGLGraphicsData.js index 2c8896d..6cee5cc 100644 --- a/src/core/graphics/webgl/WebGLGraphicsData.js +++ b/src/core/graphics/webgl/WebGLGraphicsData.js @@ -9,7 +9,7 @@ * @param gl {WebGLRenderingContext} the current WebGL drawing context * @private */ -function WebGLGraphicsData(gl, shader) +function WebGLGraphicsData(gl, shader) { /** @@ -58,9 +58,12 @@ this.glPoints = null; this.glIndices = null; - + /** + * + * @member {PIXI.Shader} + */ this.shader = shader; - + this.vao = new glCore.VertexArrayObject(gl) .addIndex(this.indexBuffer) .addAttribute(this.buffer, shader.attributes.aVertexPosition, gl.FLOAT, false, 4 * 6, 0) @@ -73,7 +76,7 @@ /** * Resets the vertices and the indices */ -WebGLGraphicsData.prototype.reset = function () +WebGLGraphicsData.prototype.reset = function () { this.points.length = 0; this.indices.length = 0; @@ -82,7 +85,7 @@ /** * Binds the buffers and uploads the data */ -WebGLGraphicsData.prototype.upload = function () +WebGLGraphicsData.prototype.upload = function () { var gl = this.gl; @@ -96,8 +99,10 @@ }; - -WebGLGraphicsData.prototype.destroy = function () +/** + * Empties all the data + */ +WebGLGraphicsData.prototype.destroy = function () { this.color = null; this.points = null; @@ -106,7 +111,7 @@ this.vao.destroy(); this.buffer.destroy(); this.indexBuffer.destroy(); - + this.gl = null; this.buffer = null; diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index 038338b..33d25d5 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -8,15 +8,30 @@ * * @class * @memberof PIXI - * @param gl {WebGLRenderingContext} + * @param renderer {PIXI.WebGLRenderer} */ - var TextureManager = function(renderer) { + /** + * A reference to the current renderer + * + * @member {PIXI.WebGLRenderer} + */ this.renderer = renderer; + + /** + * The current WebGL rendering context + * + * @member {WebGLRenderingContext} + */ this.gl = renderer.gl; - // track textures in the renderer so we can no longer listen to them on destruction. + /** + * Track textures in the renderer so we can no longer listen to them on destruction. + * + * @member {array} + * @private + */ this._managedTextures = []; } @@ -68,19 +83,19 @@ texture.on('update', this.updateTexture, this); texture.on('dispose', this.destroyTexture, this); - + this._managedTextures.push(texture); - - + + if(texture.isPowerOfTwo) - { + { if(texture.mipmap) { glTexture.enableMipmap(); } - + if(texture.wrapMode === CONST.WRAP_MODES.CLAMP) { glTexture.enableWrapClamp(); @@ -152,6 +167,9 @@ } } +/** + * Deletes all the textures from WebGL + */ TextureManager.prototype.removeAll = function() { // empty all the old gl textures as they are useless now @@ -165,6 +183,9 @@ } } +/** + * Destroys this manager and removes all its textures + */ TextureManager.prototype.destroy = function() { // destroy managed textures @@ -180,4 +201,3 @@ } module.exports = TextureManager; - diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index d0ef80c..adc6667 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -87,38 +87,59 @@ this.stencilManager = new StencilManager(this); /** - * The currently active ObjectRenderer. + * An empty renderer. * * @member {PIXI.ObjectRenderer} */ this.emptyRenderer = new ObjectRenderer(this); + + /** + * The currently active ObjectRenderer. + * + * @member {PIXI.ObjectRenderer} + */ this.currentRenderer = this.emptyRenderer; this.initPlugins(); + /** + * The current WebGL rendering context, it is created here + * + * @member {WebGLRenderingContext} + */ // initialize the context so it is ready for the managers. this.gl = createContext(this.view, this._contextOptions); this.gl.id = this.CONTEXT_UID = CONTEXT_UID++; + + /** + * The currently active ObjectRenderer. + * + * @member {PIXI.WebGLState} + */ this.state = new WebGLState(this.gl); this.renderingToScreen = true; + + + this._initContext(); + /** * Manages the filters. * * @member {PIXI.FilterManager} */ - - - this._initContext(); - this.filterManager = new FilterManager(this); // map some webGL blend and drawmodes.. this.drawModes = mapWebGLDrawModesToPixi(gl) - //alert(this.state ) + /** + * Holds the current shader + * + * @member {PIXI.Shader} + */ this._activeShader = null; /** @@ -168,6 +189,10 @@ * Renders the object to its webGL view * * @param object {PIXI.DisplayObject} the object to be rendered + * @param renderTexture {PIXI.renderTexture} + * @param clear {Boolean} + * @param transform {PIXI.Transform} + * @param skipUpdateTransform {Boolean} */ WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, transform, skipUpdateTransform) { @@ -260,21 +285,43 @@ } }; +/** + * Resizes the webGL view to the specified width and height. + * + * @param blendMode {number} the desired blend mode + */ WebGLRenderer.prototype.setBlendMode = function (blendMode) { this.state.setBlendMode(blendMode); } +/** + * Erases the active render target and fills the drawing area with a colour + * + * @param clearColor {number} The colour + */ WebGLRenderer.prototype.clear = function (clearColor) { this._activeRenderTarget.clear(clearColor); } +/** + * Sets the transform of the active render target to the given matrix + * + * @param matrix {PIXI.Matrix} The transformation matrix + */ WebGLRenderer.prototype.setTransform = function (matrix) { this._activeRenderTarget.transform = matrix; } + +/** + * Binds a render texture for rendering + * + * @param renderTexture {PIXI.RenderTexture} The render texture to render + * @param transform {PIXI.Transform} The transform to be applied to the render texture + */ //TOOD - required? WebGLRenderer.prototype.bindRenderTexture = function (renderTexture, transform) { @@ -325,7 +372,11 @@ return this; } - +/** + * Changes the current shader to the one given in parameter + * + * @param shader {PIXI.Shader} the new shader + */ WebGLRenderer.prototype.bindShader = function (shader) { //TODO cache @@ -341,7 +392,12 @@ return this; } - +/** + * Binds the texture ... @mat + * + * @param texture {PIXI.Texture} the new texture + * @param location {number} the texture location + */ WebGLRenderer.prototype.bindTexture = function (texture, location) { texture = texture.baseTexture || texture; @@ -375,8 +431,7 @@ } /** - * resets WebGL state so you can render things however you fancy! - * @return {[type]} [description] + * Resets the WebGL state so you can render things however you fancy! */ WebGLRenderer.prototype.reset = function () { diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js index 958661f..88db356 100644 --- a/src/core/display/ObservablePoint.js +++ b/src/core/display/ObservablePoint.js @@ -4,6 +4,7 @@ * * @class * @memberof PIXI + * @param transform {PIXI.Transform} the transform object @mat * @param [x=0] {number} position of the point on the x axis * @param [y=0] {number} position of the point on the y axis */ @@ -25,7 +26,7 @@ * The position of the displayObject on the x axis relative to the local coordinates of the parent. * * @member {number} - * @memberof PIXI.DisplayObject# + * @memberof PIXI.ObservablePoint# */ x: { get: function () @@ -38,7 +39,12 @@ this.transform._versionLocal++; } }, - + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ y: { get: function () { diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 0d6f061..787106a 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -2,8 +2,7 @@ /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. + * Generic class to deal with traditional 2D matrix transforms * * @class * @memberof PIXI @@ -12,7 +11,13 @@ */ function Transform() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); /** @@ -35,17 +40,27 @@ * @member {PIXI.Point} */ this.pivot = new math.Point(0.0); - + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; this._sr = Math.sin(0); this._cr = Math.cos(0); - + this.updated = true; } Transform.prototype.constructor = Transform; +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ Transform.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -65,10 +80,8 @@ wt.c = lt.c * pt.a + lt.d * pt.c; wt.d = lt.c * pt.b + lt.d * pt.d; wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; } module.exports = Transform; - - diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index b86aa2d..30d7823 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -13,15 +13,50 @@ */ function TransformStatic() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); - this.position = new ObservablePoint(this, 0); - this.scale = new ObservablePoint(this,1, 1); - this.pivot = new ObservablePoint(this, 0, 0); - this.skew = new ObservablePoint(this, 0,0); + /** + * The coordinate of the object relative to the local coordinates of the parent. + * + * @member {PIXI.ObservablePoint} + */ + this.position = new ObservablePoint(this,0.0); + /** + * The scale factor of the object. + * + * @member {PIXI.ObservablePoint} + */ + this.scale = new ObservablePoint(this,1,1); + + /** + * The pivot point of the displayObject that it rotates around + * + * @member {PIXI.ObservablePoint} + */ + this.pivot = new ObservablePoint(this,0.0); + + /** + * The skew amount, on the x and y axis. + * + * @member {PIXI.ObservablePoint} + */ + this.skew = new ObservablePoint(this,0.0); + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; + this._sr = Math.sin(0); this._cr = Math.cos(0); @@ -35,6 +70,12 @@ TransformStatic.prototype.constructor = TransformStatic; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ TransformStatic.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -71,5 +112,3 @@ }; module.exports = TransformStatic; - - diff --git a/src/core/graphics/canvas/CanvasGraphicsRenderer.js b/src/core/graphics/canvas/CanvasGraphicsRenderer.js index 4cefba4..c635c8e 100644 --- a/src/core/graphics/canvas/CanvasGraphicsRenderer.js +++ b/src/core/graphics/canvas/CanvasGraphicsRenderer.js @@ -13,13 +13,13 @@ */ /** - * Renderer dedicated to drawing and batching sprites. + * Renderer dedicated to drawing and batching graphics objects. * * @class * @private * @memberof PIXI * @extends PIXI.ObjectRenderer - * @param renderer {PIXI.WebGLRenderer} The renderer sprite this batch works for. + * @param renderer {PIXI.SystemRenderer} The current PIXI renderer. */ function CanvasGraphicsRenderer(renderer) { diff --git a/src/core/graphics/webgl/WebGLGraphicsData.js b/src/core/graphics/webgl/WebGLGraphicsData.js index 2c8896d..6cee5cc 100644 --- a/src/core/graphics/webgl/WebGLGraphicsData.js +++ b/src/core/graphics/webgl/WebGLGraphicsData.js @@ -9,7 +9,7 @@ * @param gl {WebGLRenderingContext} the current WebGL drawing context * @private */ -function WebGLGraphicsData(gl, shader) +function WebGLGraphicsData(gl, shader) { /** @@ -58,9 +58,12 @@ this.glPoints = null; this.glIndices = null; - + /** + * + * @member {PIXI.Shader} + */ this.shader = shader; - + this.vao = new glCore.VertexArrayObject(gl) .addIndex(this.indexBuffer) .addAttribute(this.buffer, shader.attributes.aVertexPosition, gl.FLOAT, false, 4 * 6, 0) @@ -73,7 +76,7 @@ /** * Resets the vertices and the indices */ -WebGLGraphicsData.prototype.reset = function () +WebGLGraphicsData.prototype.reset = function () { this.points.length = 0; this.indices.length = 0; @@ -82,7 +85,7 @@ /** * Binds the buffers and uploads the data */ -WebGLGraphicsData.prototype.upload = function () +WebGLGraphicsData.prototype.upload = function () { var gl = this.gl; @@ -96,8 +99,10 @@ }; - -WebGLGraphicsData.prototype.destroy = function () +/** + * Empties all the data + */ +WebGLGraphicsData.prototype.destroy = function () { this.color = null; this.points = null; @@ -106,7 +111,7 @@ this.vao.destroy(); this.buffer.destroy(); this.indexBuffer.destroy(); - + this.gl = null; this.buffer = null; diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index 038338b..33d25d5 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -8,15 +8,30 @@ * * @class * @memberof PIXI - * @param gl {WebGLRenderingContext} + * @param renderer {PIXI.WebGLRenderer} */ - var TextureManager = function(renderer) { + /** + * A reference to the current renderer + * + * @member {PIXI.WebGLRenderer} + */ this.renderer = renderer; + + /** + * The current WebGL rendering context + * + * @member {WebGLRenderingContext} + */ this.gl = renderer.gl; - // track textures in the renderer so we can no longer listen to them on destruction. + /** + * Track textures in the renderer so we can no longer listen to them on destruction. + * + * @member {array} + * @private + */ this._managedTextures = []; } @@ -68,19 +83,19 @@ texture.on('update', this.updateTexture, this); texture.on('dispose', this.destroyTexture, this); - + this._managedTextures.push(texture); - - + + if(texture.isPowerOfTwo) - { + { if(texture.mipmap) { glTexture.enableMipmap(); } - + if(texture.wrapMode === CONST.WRAP_MODES.CLAMP) { glTexture.enableWrapClamp(); @@ -152,6 +167,9 @@ } } +/** + * Deletes all the textures from WebGL + */ TextureManager.prototype.removeAll = function() { // empty all the old gl textures as they are useless now @@ -165,6 +183,9 @@ } } +/** + * Destroys this manager and removes all its textures + */ TextureManager.prototype.destroy = function() { // destroy managed textures @@ -180,4 +201,3 @@ } module.exports = TextureManager; - diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index d0ef80c..adc6667 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -87,38 +87,59 @@ this.stencilManager = new StencilManager(this); /** - * The currently active ObjectRenderer. + * An empty renderer. * * @member {PIXI.ObjectRenderer} */ this.emptyRenderer = new ObjectRenderer(this); + + /** + * The currently active ObjectRenderer. + * + * @member {PIXI.ObjectRenderer} + */ this.currentRenderer = this.emptyRenderer; this.initPlugins(); + /** + * The current WebGL rendering context, it is created here + * + * @member {WebGLRenderingContext} + */ // initialize the context so it is ready for the managers. this.gl = createContext(this.view, this._contextOptions); this.gl.id = this.CONTEXT_UID = CONTEXT_UID++; + + /** + * The currently active ObjectRenderer. + * + * @member {PIXI.WebGLState} + */ this.state = new WebGLState(this.gl); this.renderingToScreen = true; + + + this._initContext(); + /** * Manages the filters. * * @member {PIXI.FilterManager} */ - - - this._initContext(); - this.filterManager = new FilterManager(this); // map some webGL blend and drawmodes.. this.drawModes = mapWebGLDrawModesToPixi(gl) - //alert(this.state ) + /** + * Holds the current shader + * + * @member {PIXI.Shader} + */ this._activeShader = null; /** @@ -168,6 +189,10 @@ * Renders the object to its webGL view * * @param object {PIXI.DisplayObject} the object to be rendered + * @param renderTexture {PIXI.renderTexture} + * @param clear {Boolean} + * @param transform {PIXI.Transform} + * @param skipUpdateTransform {Boolean} */ WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, transform, skipUpdateTransform) { @@ -260,21 +285,43 @@ } }; +/** + * Resizes the webGL view to the specified width and height. + * + * @param blendMode {number} the desired blend mode + */ WebGLRenderer.prototype.setBlendMode = function (blendMode) { this.state.setBlendMode(blendMode); } +/** + * Erases the active render target and fills the drawing area with a colour + * + * @param clearColor {number} The colour + */ WebGLRenderer.prototype.clear = function (clearColor) { this._activeRenderTarget.clear(clearColor); } +/** + * Sets the transform of the active render target to the given matrix + * + * @param matrix {PIXI.Matrix} The transformation matrix + */ WebGLRenderer.prototype.setTransform = function (matrix) { this._activeRenderTarget.transform = matrix; } + +/** + * Binds a render texture for rendering + * + * @param renderTexture {PIXI.RenderTexture} The render texture to render + * @param transform {PIXI.Transform} The transform to be applied to the render texture + */ //TOOD - required? WebGLRenderer.prototype.bindRenderTexture = function (renderTexture, transform) { @@ -325,7 +372,11 @@ return this; } - +/** + * Changes the current shader to the one given in parameter + * + * @param shader {PIXI.Shader} the new shader + */ WebGLRenderer.prototype.bindShader = function (shader) { //TODO cache @@ -341,7 +392,12 @@ return this; } - +/** + * Binds the texture ... @mat + * + * @param texture {PIXI.Texture} the new texture + * @param location {number} the texture location + */ WebGLRenderer.prototype.bindTexture = function (texture, location) { texture = texture.baseTexture || texture; @@ -375,8 +431,7 @@ } /** - * resets WebGL state so you can render things however you fancy! - * @return {[type]} [description] + * Resets the WebGL state so you can render things however you fancy! */ WebGLRenderer.prototype.reset = function () { diff --git a/src/core/renderers/webgl/WebGLState.js b/src/core/renderers/webgl/WebGLState.js index ba5e036..675a7f1 100755 --- a/src/core/renderers/webgl/WebGLState.js +++ b/src/core/renderers/webgl/WebGLState.js @@ -1,26 +1,58 @@ var mapWebGLBlendModesToPixi = require('./utils/mapWebGLBlendModesToPixi'); - +/** + * A WebGL state machines + * @param gl {WebGLRenderingContext} The current WebGL rendering context + */ var WebGLState = function(gl) { + + /** + * The current active state + * + * @member {Uint8Array} + */ this.activeState = new Uint8Array(16); + + /** + * The default state + * + * @member {Uint8Array} + */ this.defaultState = new Uint8Array(16); - + // default blend mode.. this.defaultState[0] = 1; + /** + * The current state index in the stack + * + * @member {number} + * @private + */ this.stackIndex = 0; + /** + * The stack holding all the different states + * + * @member {array} + * @private + */ this.stack = []; + /** + * The current WebGL rendering context + * + * @member {WebGLRenderingContext} + */ this.gl = gl; this.maxAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); this.blendModes = mapWebGLBlendModesToPixi(gl); - + // check we have vao.. this.nativeVaoExtension = ( @@ -30,6 +62,9 @@ ); } +/** + * Pushes a new active state + */ WebGLState.prototype.push = function() { // next state.. @@ -42,7 +77,7 @@ // copy state.. // set active state so we can force overrides of gl state - for (var i = 0; i < this.activeState.length; i++) + for (var i = 0; i < this.activeState.length; i++) { this.activeState[i] = state[i]; }; @@ -54,12 +89,19 @@ CULL_FACE = 3, BLEND_FUNC = 4; +/** + * Pops a state out + */ WebGLState.prototype.pop = function() { - var state = this.state[--this.stackIndex]; + var state = this.state[--this.stackIndex]; this.setState(state); } +/** + * Sets the current state + * @param state {number} + */ WebGLState.prototype.setState = function(state) { this.setBlend(state[BLEND]); @@ -69,29 +111,32 @@ this.setDepthTest(state[BLEND_FUNC]); } -WebGLState.prototype.setBlendMode = function(blendMode) -{ - -} - +/** + * Sets the blend mode ? @mat + * @param value {number} + */ WebGLState.prototype.setBlend = function(value) { if(this.activeState[BLEND] === value|0)return; this.activeState[BLEND] = value|0; - + var gl = this.gl; if(value) { - gl.enable(gl.BLEND); + gl.enable(gl.BLEND); } else { - gl.disable(gl.BLEND); + gl.disable(gl.BLEND); } } +/** + * Sets the blend mode ? @mat + * @param value {number} + */ WebGLState.prototype.setBlendMode = function(value) { if(value === this.activeState[BLEND_FUNC])return; @@ -101,6 +146,10 @@ this.gl.blendFunc(this.blendModes[value][0], this.blendModes[value][1]); } +/** + * Sets the depth test @mat + * @param value {number} + */ WebGLState.prototype.setDepthTest = function(value) { if(this.activeState[DEPTH_TEST] === value|0)return; @@ -111,14 +160,18 @@ if(value) { - gl.enable(gl.DEPTH_TEST); + gl.enable(gl.DEPTH_TEST); } else { - gl.disable(gl.DEPTH_TEST); + gl.disable(gl.DEPTH_TEST); } } +/** + * Sets the depth test @mat + * @param value {number} + */ WebGLState.prototype.setCullFace = function(value) { if(this.activeState[CULL_FACE] === value|0)return; @@ -129,14 +182,18 @@ if(value) { - gl.enable(gl.CULL_FACE); + gl.enable(gl.CULL_FACE); } else { - gl.disable(gl.CULL_FACE); + gl.disable(gl.CULL_FACE); } } +/** + * Sets the depth test @mat + * @param value {number} + */ WebGLState.prototype.setFrontFace = function(value) { if(this.activeState[FRONT_FACE] === value|0)return; @@ -147,18 +204,21 @@ if(value) { - gl.frontFace(gl.CW); + gl.frontFace(gl.CW); } else { - gl.frontFace(gl.CCW); + gl.frontFace(gl.CCW); } } -WebGLState.prototype.resetAttributes = function(value) +/** + * Disables all the vaos in use + */ +WebGLState.prototype.resetAttributes = function() { var gl = this.gl; - + // im going to assume one is always active for performance reasons. for (i = 1; i < this.maxAttribs; i++) { @@ -167,6 +227,9 @@ } //used +/** + * Resets all the logic and disables the vaos + */ WebGLState.prototype.resetToDefault = function() { // unbind any VAO if they exist.. @@ -179,7 +242,7 @@ this.resetAttributes(); // set active state so we can force overrides of gl state - for (var i = 0; i < this.activeState.length; i++) + for (var i = 0; i < this.activeState.length; i++) { this.activeState[i] = 2; }; diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js index 958661f..88db356 100644 --- a/src/core/display/ObservablePoint.js +++ b/src/core/display/ObservablePoint.js @@ -4,6 +4,7 @@ * * @class * @memberof PIXI + * @param transform {PIXI.Transform} the transform object @mat * @param [x=0] {number} position of the point on the x axis * @param [y=0] {number} position of the point on the y axis */ @@ -25,7 +26,7 @@ * The position of the displayObject on the x axis relative to the local coordinates of the parent. * * @member {number} - * @memberof PIXI.DisplayObject# + * @memberof PIXI.ObservablePoint# */ x: { get: function () @@ -38,7 +39,12 @@ this.transform._versionLocal++; } }, - + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ y: { get: function () { diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 0d6f061..787106a 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -2,8 +2,7 @@ /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. + * Generic class to deal with traditional 2D matrix transforms * * @class * @memberof PIXI @@ -12,7 +11,13 @@ */ function Transform() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); /** @@ -35,17 +40,27 @@ * @member {PIXI.Point} */ this.pivot = new math.Point(0.0); - + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; this._sr = Math.sin(0); this._cr = Math.cos(0); - + this.updated = true; } Transform.prototype.constructor = Transform; +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ Transform.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -65,10 +80,8 @@ wt.c = lt.c * pt.a + lt.d * pt.c; wt.d = lt.c * pt.b + lt.d * pt.d; wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; } module.exports = Transform; - - diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index b86aa2d..30d7823 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -13,15 +13,50 @@ */ function TransformStatic() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); - this.position = new ObservablePoint(this, 0); - this.scale = new ObservablePoint(this,1, 1); - this.pivot = new ObservablePoint(this, 0, 0); - this.skew = new ObservablePoint(this, 0,0); + /** + * The coordinate of the object relative to the local coordinates of the parent. + * + * @member {PIXI.ObservablePoint} + */ + this.position = new ObservablePoint(this,0.0); + /** + * The scale factor of the object. + * + * @member {PIXI.ObservablePoint} + */ + this.scale = new ObservablePoint(this,1,1); + + /** + * The pivot point of the displayObject that it rotates around + * + * @member {PIXI.ObservablePoint} + */ + this.pivot = new ObservablePoint(this,0.0); + + /** + * The skew amount, on the x and y axis. + * + * @member {PIXI.ObservablePoint} + */ + this.skew = new ObservablePoint(this,0.0); + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; + this._sr = Math.sin(0); this._cr = Math.cos(0); @@ -35,6 +70,12 @@ TransformStatic.prototype.constructor = TransformStatic; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ TransformStatic.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -71,5 +112,3 @@ }; module.exports = TransformStatic; - - diff --git a/src/core/graphics/canvas/CanvasGraphicsRenderer.js b/src/core/graphics/canvas/CanvasGraphicsRenderer.js index 4cefba4..c635c8e 100644 --- a/src/core/graphics/canvas/CanvasGraphicsRenderer.js +++ b/src/core/graphics/canvas/CanvasGraphicsRenderer.js @@ -13,13 +13,13 @@ */ /** - * Renderer dedicated to drawing and batching sprites. + * Renderer dedicated to drawing and batching graphics objects. * * @class * @private * @memberof PIXI * @extends PIXI.ObjectRenderer - * @param renderer {PIXI.WebGLRenderer} The renderer sprite this batch works for. + * @param renderer {PIXI.SystemRenderer} The current PIXI renderer. */ function CanvasGraphicsRenderer(renderer) { diff --git a/src/core/graphics/webgl/WebGLGraphicsData.js b/src/core/graphics/webgl/WebGLGraphicsData.js index 2c8896d..6cee5cc 100644 --- a/src/core/graphics/webgl/WebGLGraphicsData.js +++ b/src/core/graphics/webgl/WebGLGraphicsData.js @@ -9,7 +9,7 @@ * @param gl {WebGLRenderingContext} the current WebGL drawing context * @private */ -function WebGLGraphicsData(gl, shader) +function WebGLGraphicsData(gl, shader) { /** @@ -58,9 +58,12 @@ this.glPoints = null; this.glIndices = null; - + /** + * + * @member {PIXI.Shader} + */ this.shader = shader; - + this.vao = new glCore.VertexArrayObject(gl) .addIndex(this.indexBuffer) .addAttribute(this.buffer, shader.attributes.aVertexPosition, gl.FLOAT, false, 4 * 6, 0) @@ -73,7 +76,7 @@ /** * Resets the vertices and the indices */ -WebGLGraphicsData.prototype.reset = function () +WebGLGraphicsData.prototype.reset = function () { this.points.length = 0; this.indices.length = 0; @@ -82,7 +85,7 @@ /** * Binds the buffers and uploads the data */ -WebGLGraphicsData.prototype.upload = function () +WebGLGraphicsData.prototype.upload = function () { var gl = this.gl; @@ -96,8 +99,10 @@ }; - -WebGLGraphicsData.prototype.destroy = function () +/** + * Empties all the data + */ +WebGLGraphicsData.prototype.destroy = function () { this.color = null; this.points = null; @@ -106,7 +111,7 @@ this.vao.destroy(); this.buffer.destroy(); this.indexBuffer.destroy(); - + this.gl = null; this.buffer = null; diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index 038338b..33d25d5 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -8,15 +8,30 @@ * * @class * @memberof PIXI - * @param gl {WebGLRenderingContext} + * @param renderer {PIXI.WebGLRenderer} */ - var TextureManager = function(renderer) { + /** + * A reference to the current renderer + * + * @member {PIXI.WebGLRenderer} + */ this.renderer = renderer; + + /** + * The current WebGL rendering context + * + * @member {WebGLRenderingContext} + */ this.gl = renderer.gl; - // track textures in the renderer so we can no longer listen to them on destruction. + /** + * Track textures in the renderer so we can no longer listen to them on destruction. + * + * @member {array} + * @private + */ this._managedTextures = []; } @@ -68,19 +83,19 @@ texture.on('update', this.updateTexture, this); texture.on('dispose', this.destroyTexture, this); - + this._managedTextures.push(texture); - - + + if(texture.isPowerOfTwo) - { + { if(texture.mipmap) { glTexture.enableMipmap(); } - + if(texture.wrapMode === CONST.WRAP_MODES.CLAMP) { glTexture.enableWrapClamp(); @@ -152,6 +167,9 @@ } } +/** + * Deletes all the textures from WebGL + */ TextureManager.prototype.removeAll = function() { // empty all the old gl textures as they are useless now @@ -165,6 +183,9 @@ } } +/** + * Destroys this manager and removes all its textures + */ TextureManager.prototype.destroy = function() { // destroy managed textures @@ -180,4 +201,3 @@ } module.exports = TextureManager; - diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index d0ef80c..adc6667 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -87,38 +87,59 @@ this.stencilManager = new StencilManager(this); /** - * The currently active ObjectRenderer. + * An empty renderer. * * @member {PIXI.ObjectRenderer} */ this.emptyRenderer = new ObjectRenderer(this); + + /** + * The currently active ObjectRenderer. + * + * @member {PIXI.ObjectRenderer} + */ this.currentRenderer = this.emptyRenderer; this.initPlugins(); + /** + * The current WebGL rendering context, it is created here + * + * @member {WebGLRenderingContext} + */ // initialize the context so it is ready for the managers. this.gl = createContext(this.view, this._contextOptions); this.gl.id = this.CONTEXT_UID = CONTEXT_UID++; + + /** + * The currently active ObjectRenderer. + * + * @member {PIXI.WebGLState} + */ this.state = new WebGLState(this.gl); this.renderingToScreen = true; + + + this._initContext(); + /** * Manages the filters. * * @member {PIXI.FilterManager} */ - - - this._initContext(); - this.filterManager = new FilterManager(this); // map some webGL blend and drawmodes.. this.drawModes = mapWebGLDrawModesToPixi(gl) - //alert(this.state ) + /** + * Holds the current shader + * + * @member {PIXI.Shader} + */ this._activeShader = null; /** @@ -168,6 +189,10 @@ * Renders the object to its webGL view * * @param object {PIXI.DisplayObject} the object to be rendered + * @param renderTexture {PIXI.renderTexture} + * @param clear {Boolean} + * @param transform {PIXI.Transform} + * @param skipUpdateTransform {Boolean} */ WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, transform, skipUpdateTransform) { @@ -260,21 +285,43 @@ } }; +/** + * Resizes the webGL view to the specified width and height. + * + * @param blendMode {number} the desired blend mode + */ WebGLRenderer.prototype.setBlendMode = function (blendMode) { this.state.setBlendMode(blendMode); } +/** + * Erases the active render target and fills the drawing area with a colour + * + * @param clearColor {number} The colour + */ WebGLRenderer.prototype.clear = function (clearColor) { this._activeRenderTarget.clear(clearColor); } +/** + * Sets the transform of the active render target to the given matrix + * + * @param matrix {PIXI.Matrix} The transformation matrix + */ WebGLRenderer.prototype.setTransform = function (matrix) { this._activeRenderTarget.transform = matrix; } + +/** + * Binds a render texture for rendering + * + * @param renderTexture {PIXI.RenderTexture} The render texture to render + * @param transform {PIXI.Transform} The transform to be applied to the render texture + */ //TOOD - required? WebGLRenderer.prototype.bindRenderTexture = function (renderTexture, transform) { @@ -325,7 +372,11 @@ return this; } - +/** + * Changes the current shader to the one given in parameter + * + * @param shader {PIXI.Shader} the new shader + */ WebGLRenderer.prototype.bindShader = function (shader) { //TODO cache @@ -341,7 +392,12 @@ return this; } - +/** + * Binds the texture ... @mat + * + * @param texture {PIXI.Texture} the new texture + * @param location {number} the texture location + */ WebGLRenderer.prototype.bindTexture = function (texture, location) { texture = texture.baseTexture || texture; @@ -375,8 +431,7 @@ } /** - * resets WebGL state so you can render things however you fancy! - * @return {[type]} [description] + * Resets the WebGL state so you can render things however you fancy! */ WebGLRenderer.prototype.reset = function () { diff --git a/src/core/renderers/webgl/WebGLState.js b/src/core/renderers/webgl/WebGLState.js index ba5e036..675a7f1 100755 --- a/src/core/renderers/webgl/WebGLState.js +++ b/src/core/renderers/webgl/WebGLState.js @@ -1,26 +1,58 @@ var mapWebGLBlendModesToPixi = require('./utils/mapWebGLBlendModesToPixi'); - +/** + * A WebGL state machines + * @param gl {WebGLRenderingContext} The current WebGL rendering context + */ var WebGLState = function(gl) { + + /** + * The current active state + * + * @member {Uint8Array} + */ this.activeState = new Uint8Array(16); + + /** + * The default state + * + * @member {Uint8Array} + */ this.defaultState = new Uint8Array(16); - + // default blend mode.. this.defaultState[0] = 1; + /** + * The current state index in the stack + * + * @member {number} + * @private + */ this.stackIndex = 0; + /** + * The stack holding all the different states + * + * @member {array} + * @private + */ this.stack = []; + /** + * The current WebGL rendering context + * + * @member {WebGLRenderingContext} + */ this.gl = gl; this.maxAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); this.blendModes = mapWebGLBlendModesToPixi(gl); - + // check we have vao.. this.nativeVaoExtension = ( @@ -30,6 +62,9 @@ ); } +/** + * Pushes a new active state + */ WebGLState.prototype.push = function() { // next state.. @@ -42,7 +77,7 @@ // copy state.. // set active state so we can force overrides of gl state - for (var i = 0; i < this.activeState.length; i++) + for (var i = 0; i < this.activeState.length; i++) { this.activeState[i] = state[i]; }; @@ -54,12 +89,19 @@ CULL_FACE = 3, BLEND_FUNC = 4; +/** + * Pops a state out + */ WebGLState.prototype.pop = function() { - var state = this.state[--this.stackIndex]; + var state = this.state[--this.stackIndex]; this.setState(state); } +/** + * Sets the current state + * @param state {number} + */ WebGLState.prototype.setState = function(state) { this.setBlend(state[BLEND]); @@ -69,29 +111,32 @@ this.setDepthTest(state[BLEND_FUNC]); } -WebGLState.prototype.setBlendMode = function(blendMode) -{ - -} - +/** + * Sets the blend mode ? @mat + * @param value {number} + */ WebGLState.prototype.setBlend = function(value) { if(this.activeState[BLEND] === value|0)return; this.activeState[BLEND] = value|0; - + var gl = this.gl; if(value) { - gl.enable(gl.BLEND); + gl.enable(gl.BLEND); } else { - gl.disable(gl.BLEND); + gl.disable(gl.BLEND); } } +/** + * Sets the blend mode ? @mat + * @param value {number} + */ WebGLState.prototype.setBlendMode = function(value) { if(value === this.activeState[BLEND_FUNC])return; @@ -101,6 +146,10 @@ this.gl.blendFunc(this.blendModes[value][0], this.blendModes[value][1]); } +/** + * Sets the depth test @mat + * @param value {number} + */ WebGLState.prototype.setDepthTest = function(value) { if(this.activeState[DEPTH_TEST] === value|0)return; @@ -111,14 +160,18 @@ if(value) { - gl.enable(gl.DEPTH_TEST); + gl.enable(gl.DEPTH_TEST); } else { - gl.disable(gl.DEPTH_TEST); + gl.disable(gl.DEPTH_TEST); } } +/** + * Sets the depth test @mat + * @param value {number} + */ WebGLState.prototype.setCullFace = function(value) { if(this.activeState[CULL_FACE] === value|0)return; @@ -129,14 +182,18 @@ if(value) { - gl.enable(gl.CULL_FACE); + gl.enable(gl.CULL_FACE); } else { - gl.disable(gl.CULL_FACE); + gl.disable(gl.CULL_FACE); } } +/** + * Sets the depth test @mat + * @param value {number} + */ WebGLState.prototype.setFrontFace = function(value) { if(this.activeState[FRONT_FACE] === value|0)return; @@ -147,18 +204,21 @@ if(value) { - gl.frontFace(gl.CW); + gl.frontFace(gl.CW); } else { - gl.frontFace(gl.CCW); + gl.frontFace(gl.CCW); } } -WebGLState.prototype.resetAttributes = function(value) +/** + * Disables all the vaos in use + */ +WebGLState.prototype.resetAttributes = function() { var gl = this.gl; - + // im going to assume one is always active for performance reasons. for (i = 1; i < this.maxAttribs; i++) { @@ -167,6 +227,9 @@ } //used +/** + * Resets all the logic and disables the vaos + */ WebGLState.prototype.resetToDefault = function() { // unbind any VAO if they exist.. @@ -179,7 +242,7 @@ this.resetAttributes(); // set active state so we can force overrides of gl state - for (var i = 0; i < this.activeState.length; i++) + for (var i = 0; i < this.activeState.length; i++) { this.activeState[i] = 2; }; diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index fc39f7f..43373ce 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -17,8 +17,6 @@ */ this.gl = gl; -// this.textures = new TextureUvs(); - /** * An array of vertices * @@ -43,7 +41,7 @@ 0,1 ]); - this.interleaved = new Float32Array(8 * 2); + this.interleaved = new Float32Array(8 * 2); for (var i = 0; i < 4; i++) { this.interleaved[i*4] = this.vertices[(i*2)]; @@ -59,25 +57,35 @@ this.indices = createIndicesForQuads(1); /* - * @member {WebGLBuffer} The vertex buffer + * @member {glCore.GLBuffer} The vertex buffer */ - this.vertexBuffer = glCore.GLBuffer.createVertexBuffer(gl, this.interleaved, gl.STATIC_DRAW); + + /* + * @member {glCore.GLBuffer} The index buffer + */ this.indexBuffer = glCore.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW); + /* + * @member {glCore.VertexArrayObject} The index buffer + */ this.vao = new glCore.VertexArrayObject(gl) - - + + } Quad.prototype.constructor = Quad; +/** + * Initialises the vaos and uses the shader + * @param shader {PIXI.Shader} the shader to use + */ Quad.prototype.initVao = function(shader) { this.vao.clear() .addIndex(this.indexBuffer) .addAttribute(this.vertexBuffer, shader.attributes.aVertexPosition, gl.FLOAT, false, 4 * 4, 0) - .addAttribute(this.vertexBuffer, shader.attributes.aTextureCoord, gl.FLOAT, false, 4 * 4, 2 * 4) + .addAttribute(this.vertexBuffer, shader.attributes.aTextureCoord, gl.FLOAT, false, 4 * 4, 2 * 4) } /** @@ -121,6 +129,9 @@ return this; }; +/** + * Draws the quad + */ Quad.prototype.draw = function() { this.vao.bind() @@ -149,14 +160,15 @@ return this; }; +/** + * Removes this quad from WebGL + */ Quad.prototype.destroy = function() { var gl = this.gl; - + gl.deleteBuffer(this.vertexBuffer); gl.deleteBuffer(this.indexBuffer); }; module.exports = Quad; - - diff --git a/src/core/display/ObservablePoint.js b/src/core/display/ObservablePoint.js index 958661f..88db356 100644 --- a/src/core/display/ObservablePoint.js +++ b/src/core/display/ObservablePoint.js @@ -4,6 +4,7 @@ * * @class * @memberof PIXI + * @param transform {PIXI.Transform} the transform object @mat * @param [x=0] {number} position of the point on the x axis * @param [y=0] {number} position of the point on the y axis */ @@ -25,7 +26,7 @@ * The position of the displayObject on the x axis relative to the local coordinates of the parent. * * @member {number} - * @memberof PIXI.DisplayObject# + * @memberof PIXI.ObservablePoint# */ x: { get: function () @@ -38,7 +39,12 @@ this.transform._versionLocal++; } }, - + /** + * The position of the displayObject on the x axis relative to the local coordinates of the parent. + * + * @member {number} + * @memberof PIXI.ObservablePoint# + */ y: { get: function () { diff --git a/src/core/display/Transform.js b/src/core/display/Transform.js index 0d6f061..787106a 100644 --- a/src/core/display/Transform.js +++ b/src/core/display/Transform.js @@ -2,8 +2,7 @@ /** - * The Point object represents a location in a two-dimensional coordinate system, where x represents - * the horizontal axis and y represents the vertical axis. + * Generic class to deal with traditional 2D matrix transforms * * @class * @memberof PIXI @@ -12,7 +11,13 @@ */ function Transform() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); /** @@ -35,17 +40,27 @@ * @member {PIXI.Point} */ this.pivot = new math.Point(0.0); - + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; this._sr = Math.sin(0); this._cr = Math.cos(0); - + this.updated = true; } Transform.prototype.constructor = Transform; +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ Transform.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -65,10 +80,8 @@ wt.c = lt.c * pt.a + lt.d * pt.c; wt.d = lt.c * pt.b + lt.d * pt.d; wt.tx = lt.tx * pt.a + lt.ty * pt.c + pt.tx; - wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; + wt.ty = lt.tx * pt.b + lt.ty * pt.d + pt.ty; } module.exports = Transform; - - diff --git a/src/core/display/TransformStatic.js b/src/core/display/TransformStatic.js index b86aa2d..30d7823 100644 --- a/src/core/display/TransformStatic.js +++ b/src/core/display/TransformStatic.js @@ -13,15 +13,50 @@ */ function TransformStatic() { + /** + * @member {PIXI.Matrix} The global matrix transform + */ this.worldTransform = new math.Matrix(); + /** + * @member {PIXI.Matrix} The local matrix transform + */ this.localTransform = new math.Matrix(); - this.position = new ObservablePoint(this, 0); - this.scale = new ObservablePoint(this,1, 1); - this.pivot = new ObservablePoint(this, 0, 0); - this.skew = new ObservablePoint(this, 0,0); + /** + * The coordinate of the object relative to the local coordinates of the parent. + * + * @member {PIXI.ObservablePoint} + */ + this.position = new ObservablePoint(this,0.0); + /** + * The scale factor of the object. + * + * @member {PIXI.ObservablePoint} + */ + this.scale = new ObservablePoint(this,1,1); + + /** + * The pivot point of the displayObject that it rotates around + * + * @member {PIXI.ObservablePoint} + */ + this.pivot = new ObservablePoint(this,0.0); + + /** + * The skew amount, on the x and y axis. + * + * @member {PIXI.ObservablePoint} + */ + this.skew = new ObservablePoint(this,0.0); + + /** + * The rotation value of the object, in radians + * + * @member {Number} + */ this.rotation = 0; + this._sr = Math.sin(0); this._cr = Math.cos(0); @@ -35,6 +70,12 @@ TransformStatic.prototype.constructor = TransformStatic; + +/** + * Updates the values of the object and applies the parent's transform. + * @param parentTransform {PIXI.Transform} The transform of the parent of this object + * + */ TransformStatic.prototype.updateTransform = function (parentTransform) { var pt = parentTransform.worldTransform; @@ -71,5 +112,3 @@ }; module.exports = TransformStatic; - - diff --git a/src/core/graphics/canvas/CanvasGraphicsRenderer.js b/src/core/graphics/canvas/CanvasGraphicsRenderer.js index 4cefba4..c635c8e 100644 --- a/src/core/graphics/canvas/CanvasGraphicsRenderer.js +++ b/src/core/graphics/canvas/CanvasGraphicsRenderer.js @@ -13,13 +13,13 @@ */ /** - * Renderer dedicated to drawing and batching sprites. + * Renderer dedicated to drawing and batching graphics objects. * * @class * @private * @memberof PIXI * @extends PIXI.ObjectRenderer - * @param renderer {PIXI.WebGLRenderer} The renderer sprite this batch works for. + * @param renderer {PIXI.SystemRenderer} The current PIXI renderer. */ function CanvasGraphicsRenderer(renderer) { diff --git a/src/core/graphics/webgl/WebGLGraphicsData.js b/src/core/graphics/webgl/WebGLGraphicsData.js index 2c8896d..6cee5cc 100644 --- a/src/core/graphics/webgl/WebGLGraphicsData.js +++ b/src/core/graphics/webgl/WebGLGraphicsData.js @@ -9,7 +9,7 @@ * @param gl {WebGLRenderingContext} the current WebGL drawing context * @private */ -function WebGLGraphicsData(gl, shader) +function WebGLGraphicsData(gl, shader) { /** @@ -58,9 +58,12 @@ this.glPoints = null; this.glIndices = null; - + /** + * + * @member {PIXI.Shader} + */ this.shader = shader; - + this.vao = new glCore.VertexArrayObject(gl) .addIndex(this.indexBuffer) .addAttribute(this.buffer, shader.attributes.aVertexPosition, gl.FLOAT, false, 4 * 6, 0) @@ -73,7 +76,7 @@ /** * Resets the vertices and the indices */ -WebGLGraphicsData.prototype.reset = function () +WebGLGraphicsData.prototype.reset = function () { this.points.length = 0; this.indices.length = 0; @@ -82,7 +85,7 @@ /** * Binds the buffers and uploads the data */ -WebGLGraphicsData.prototype.upload = function () +WebGLGraphicsData.prototype.upload = function () { var gl = this.gl; @@ -96,8 +99,10 @@ }; - -WebGLGraphicsData.prototype.destroy = function () +/** + * Empties all the data + */ +WebGLGraphicsData.prototype.destroy = function () { this.color = null; this.points = null; @@ -106,7 +111,7 @@ this.vao.destroy(); this.buffer.destroy(); this.indexBuffer.destroy(); - + this.gl = null; this.buffer = null; diff --git a/src/core/renderers/webgl/TextureManager.js b/src/core/renderers/webgl/TextureManager.js index 038338b..33d25d5 100644 --- a/src/core/renderers/webgl/TextureManager.js +++ b/src/core/renderers/webgl/TextureManager.js @@ -8,15 +8,30 @@ * * @class * @memberof PIXI - * @param gl {WebGLRenderingContext} + * @param renderer {PIXI.WebGLRenderer} */ - var TextureManager = function(renderer) { + /** + * A reference to the current renderer + * + * @member {PIXI.WebGLRenderer} + */ this.renderer = renderer; + + /** + * The current WebGL rendering context + * + * @member {WebGLRenderingContext} + */ this.gl = renderer.gl; - // track textures in the renderer so we can no longer listen to them on destruction. + /** + * Track textures in the renderer so we can no longer listen to them on destruction. + * + * @member {array} + * @private + */ this._managedTextures = []; } @@ -68,19 +83,19 @@ texture.on('update', this.updateTexture, this); texture.on('dispose', this.destroyTexture, this); - + this._managedTextures.push(texture); - - + + if(texture.isPowerOfTwo) - { + { if(texture.mipmap) { glTexture.enableMipmap(); } - + if(texture.wrapMode === CONST.WRAP_MODES.CLAMP) { glTexture.enableWrapClamp(); @@ -152,6 +167,9 @@ } } +/** + * Deletes all the textures from WebGL + */ TextureManager.prototype.removeAll = function() { // empty all the old gl textures as they are useless now @@ -165,6 +183,9 @@ } } +/** + * Destroys this manager and removes all its textures + */ TextureManager.prototype.destroy = function() { // destroy managed textures @@ -180,4 +201,3 @@ } module.exports = TextureManager; - diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index d0ef80c..adc6667 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -87,38 +87,59 @@ this.stencilManager = new StencilManager(this); /** - * The currently active ObjectRenderer. + * An empty renderer. * * @member {PIXI.ObjectRenderer} */ this.emptyRenderer = new ObjectRenderer(this); + + /** + * The currently active ObjectRenderer. + * + * @member {PIXI.ObjectRenderer} + */ this.currentRenderer = this.emptyRenderer; this.initPlugins(); + /** + * The current WebGL rendering context, it is created here + * + * @member {WebGLRenderingContext} + */ // initialize the context so it is ready for the managers. this.gl = createContext(this.view, this._contextOptions); this.gl.id = this.CONTEXT_UID = CONTEXT_UID++; + + /** + * The currently active ObjectRenderer. + * + * @member {PIXI.WebGLState} + */ this.state = new WebGLState(this.gl); this.renderingToScreen = true; + + + this._initContext(); + /** * Manages the filters. * * @member {PIXI.FilterManager} */ - - - this._initContext(); - this.filterManager = new FilterManager(this); // map some webGL blend and drawmodes.. this.drawModes = mapWebGLDrawModesToPixi(gl) - //alert(this.state ) + /** + * Holds the current shader + * + * @member {PIXI.Shader} + */ this._activeShader = null; /** @@ -168,6 +189,10 @@ * Renders the object to its webGL view * * @param object {PIXI.DisplayObject} the object to be rendered + * @param renderTexture {PIXI.renderTexture} + * @param clear {Boolean} + * @param transform {PIXI.Transform} + * @param skipUpdateTransform {Boolean} */ WebGLRenderer.prototype.render = function (displayObject, renderTexture, clear, transform, skipUpdateTransform) { @@ -260,21 +285,43 @@ } }; +/** + * Resizes the webGL view to the specified width and height. + * + * @param blendMode {number} the desired blend mode + */ WebGLRenderer.prototype.setBlendMode = function (blendMode) { this.state.setBlendMode(blendMode); } +/** + * Erases the active render target and fills the drawing area with a colour + * + * @param clearColor {number} The colour + */ WebGLRenderer.prototype.clear = function (clearColor) { this._activeRenderTarget.clear(clearColor); } +/** + * Sets the transform of the active render target to the given matrix + * + * @param matrix {PIXI.Matrix} The transformation matrix + */ WebGLRenderer.prototype.setTransform = function (matrix) { this._activeRenderTarget.transform = matrix; } + +/** + * Binds a render texture for rendering + * + * @param renderTexture {PIXI.RenderTexture} The render texture to render + * @param transform {PIXI.Transform} The transform to be applied to the render texture + */ //TOOD - required? WebGLRenderer.prototype.bindRenderTexture = function (renderTexture, transform) { @@ -325,7 +372,11 @@ return this; } - +/** + * Changes the current shader to the one given in parameter + * + * @param shader {PIXI.Shader} the new shader + */ WebGLRenderer.prototype.bindShader = function (shader) { //TODO cache @@ -341,7 +392,12 @@ return this; } - +/** + * Binds the texture ... @mat + * + * @param texture {PIXI.Texture} the new texture + * @param location {number} the texture location + */ WebGLRenderer.prototype.bindTexture = function (texture, location) { texture = texture.baseTexture || texture; @@ -375,8 +431,7 @@ } /** - * resets WebGL state so you can render things however you fancy! - * @return {[type]} [description] + * Resets the WebGL state so you can render things however you fancy! */ WebGLRenderer.prototype.reset = function () { diff --git a/src/core/renderers/webgl/WebGLState.js b/src/core/renderers/webgl/WebGLState.js index ba5e036..675a7f1 100755 --- a/src/core/renderers/webgl/WebGLState.js +++ b/src/core/renderers/webgl/WebGLState.js @@ -1,26 +1,58 @@ var mapWebGLBlendModesToPixi = require('./utils/mapWebGLBlendModesToPixi'); - +/** + * A WebGL state machines + * @param gl {WebGLRenderingContext} The current WebGL rendering context + */ var WebGLState = function(gl) { + + /** + * The current active state + * + * @member {Uint8Array} + */ this.activeState = new Uint8Array(16); + + /** + * The default state + * + * @member {Uint8Array} + */ this.defaultState = new Uint8Array(16); - + // default blend mode.. this.defaultState[0] = 1; + /** + * The current state index in the stack + * + * @member {number} + * @private + */ this.stackIndex = 0; + /** + * The stack holding all the different states + * + * @member {array} + * @private + */ this.stack = []; + /** + * The current WebGL rendering context + * + * @member {WebGLRenderingContext} + */ this.gl = gl; this.maxAttribs = gl.getParameter(gl.MAX_VERTEX_ATTRIBS); this.blendModes = mapWebGLBlendModesToPixi(gl); - + // check we have vao.. this.nativeVaoExtension = ( @@ -30,6 +62,9 @@ ); } +/** + * Pushes a new active state + */ WebGLState.prototype.push = function() { // next state.. @@ -42,7 +77,7 @@ // copy state.. // set active state so we can force overrides of gl state - for (var i = 0; i < this.activeState.length; i++) + for (var i = 0; i < this.activeState.length; i++) { this.activeState[i] = state[i]; }; @@ -54,12 +89,19 @@ CULL_FACE = 3, BLEND_FUNC = 4; +/** + * Pops a state out + */ WebGLState.prototype.pop = function() { - var state = this.state[--this.stackIndex]; + var state = this.state[--this.stackIndex]; this.setState(state); } +/** + * Sets the current state + * @param state {number} + */ WebGLState.prototype.setState = function(state) { this.setBlend(state[BLEND]); @@ -69,29 +111,32 @@ this.setDepthTest(state[BLEND_FUNC]); } -WebGLState.prototype.setBlendMode = function(blendMode) -{ - -} - +/** + * Sets the blend mode ? @mat + * @param value {number} + */ WebGLState.prototype.setBlend = function(value) { if(this.activeState[BLEND] === value|0)return; this.activeState[BLEND] = value|0; - + var gl = this.gl; if(value) { - gl.enable(gl.BLEND); + gl.enable(gl.BLEND); } else { - gl.disable(gl.BLEND); + gl.disable(gl.BLEND); } } +/** + * Sets the blend mode ? @mat + * @param value {number} + */ WebGLState.prototype.setBlendMode = function(value) { if(value === this.activeState[BLEND_FUNC])return; @@ -101,6 +146,10 @@ this.gl.blendFunc(this.blendModes[value][0], this.blendModes[value][1]); } +/** + * Sets the depth test @mat + * @param value {number} + */ WebGLState.prototype.setDepthTest = function(value) { if(this.activeState[DEPTH_TEST] === value|0)return; @@ -111,14 +160,18 @@ if(value) { - gl.enable(gl.DEPTH_TEST); + gl.enable(gl.DEPTH_TEST); } else { - gl.disable(gl.DEPTH_TEST); + gl.disable(gl.DEPTH_TEST); } } +/** + * Sets the depth test @mat + * @param value {number} + */ WebGLState.prototype.setCullFace = function(value) { if(this.activeState[CULL_FACE] === value|0)return; @@ -129,14 +182,18 @@ if(value) { - gl.enable(gl.CULL_FACE); + gl.enable(gl.CULL_FACE); } else { - gl.disable(gl.CULL_FACE); + gl.disable(gl.CULL_FACE); } } +/** + * Sets the depth test @mat + * @param value {number} + */ WebGLState.prototype.setFrontFace = function(value) { if(this.activeState[FRONT_FACE] === value|0)return; @@ -147,18 +204,21 @@ if(value) { - gl.frontFace(gl.CW); + gl.frontFace(gl.CW); } else { - gl.frontFace(gl.CCW); + gl.frontFace(gl.CCW); } } -WebGLState.prototype.resetAttributes = function(value) +/** + * Disables all the vaos in use + */ +WebGLState.prototype.resetAttributes = function() { var gl = this.gl; - + // im going to assume one is always active for performance reasons. for (i = 1; i < this.maxAttribs; i++) { @@ -167,6 +227,9 @@ } //used +/** + * Resets all the logic and disables the vaos + */ WebGLState.prototype.resetToDefault = function() { // unbind any VAO if they exist.. @@ -179,7 +242,7 @@ this.resetAttributes(); // set active state so we can force overrides of gl state - for (var i = 0; i < this.activeState.length; i++) + for (var i = 0; i < this.activeState.length; i++) { this.activeState[i] = 2; }; diff --git a/src/core/renderers/webgl/utils/Quad.js b/src/core/renderers/webgl/utils/Quad.js index fc39f7f..43373ce 100644 --- a/src/core/renderers/webgl/utils/Quad.js +++ b/src/core/renderers/webgl/utils/Quad.js @@ -17,8 +17,6 @@ */ this.gl = gl; -// this.textures = new TextureUvs(); - /** * An array of vertices * @@ -43,7 +41,7 @@ 0,1 ]); - this.interleaved = new Float32Array(8 * 2); + this.interleaved = new Float32Array(8 * 2); for (var i = 0; i < 4; i++) { this.interleaved[i*4] = this.vertices[(i*2)]; @@ -59,25 +57,35 @@ this.indices = createIndicesForQuads(1); /* - * @member {WebGLBuffer} The vertex buffer + * @member {glCore.GLBuffer} The vertex buffer */ - this.vertexBuffer = glCore.GLBuffer.createVertexBuffer(gl, this.interleaved, gl.STATIC_DRAW); + + /* + * @member {glCore.GLBuffer} The index buffer + */ this.indexBuffer = glCore.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW); + /* + * @member {glCore.VertexArrayObject} The index buffer + */ this.vao = new glCore.VertexArrayObject(gl) - - + + } Quad.prototype.constructor = Quad; +/** + * Initialises the vaos and uses the shader + * @param shader {PIXI.Shader} the shader to use + */ Quad.prototype.initVao = function(shader) { this.vao.clear() .addIndex(this.indexBuffer) .addAttribute(this.vertexBuffer, shader.attributes.aVertexPosition, gl.FLOAT, false, 4 * 4, 0) - .addAttribute(this.vertexBuffer, shader.attributes.aTextureCoord, gl.FLOAT, false, 4 * 4, 2 * 4) + .addAttribute(this.vertexBuffer, shader.attributes.aTextureCoord, gl.FLOAT, false, 4 * 4, 2 * 4) } /** @@ -121,6 +129,9 @@ return this; }; +/** + * Draws the quad + */ Quad.prototype.draw = function() { this.vao.bind() @@ -149,14 +160,15 @@ return this; }; +/** + * Removes this quad from WebGL + */ Quad.prototype.destroy = function() { var gl = this.gl; - + gl.deleteBuffer(this.vertexBuffer); gl.deleteBuffer(this.indexBuffer); }; module.exports = Quad; - - diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index d3daf50..e973cd4 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -1,9 +1,9 @@ var math = require('../../../math'), utils = require('../../../utils'), CONST = require('../../../const'), - + GLTexture = require('pixi-gl-core').GLTexture, - GLFramebuffer = require('pixi-gl-core').GLFramebuffer; + GLFramebuffer = require('pixi-gl-core').GLFramebuffer; /** * @author Mat Groves http://matgroves.com/ @Doormat23 @@ -46,6 +46,11 @@ */ this.texture = null; + /** + * The background colour of this render target, as an array of [r,g,b,a] values + * + * @member {array} + */ this.clearColor = [0, 0, 0, 0]; /** @@ -82,7 +87,12 @@ * @member {PIXI.Rectangle} */ this.frame = null; - + + /** + * The stencil buffer stores masking data for the render target + * + * @member {WebGLRenderBuffer} + */ this.defaultFrame = new PIXI.Rectangle(); this.destinationFrame = null; this.sourceFrame = null; @@ -131,7 +141,7 @@ */ this.root = root; - + if (!this.root) { this.frameBuffer = GLFramebuffer.createRGBA(gl, 100, 100); @@ -149,7 +159,7 @@ A frame buffer needs a target to render to.. create a texture and bind it attach it to the framebuffer.. */ - + // this is used by the base texture this.texture = this.frameBuffer.texture; } @@ -162,7 +172,7 @@ } this.setFrame(); - + this.resize(width, height); }; @@ -285,7 +295,7 @@ width = width | 0; height = height | 0; - if (this.size.width === width && this.size.height === height) + if (this.size.width === width && this.size.height === height) { return; } @@ -298,7 +308,7 @@ this.frameBuffer.resize(width * this.resolution, height * this.resolution); - + var projectionFrame = this.frame || this.size; this.calculateProjection( projectionFrame ); @@ -311,7 +321,7 @@ RenderTarget.prototype.destroy = function () { var gl = this.gl; - + this.frameBuffer.destroy(); this.frameBuffer = null;