codebase now lint free

This commit is contained in:
Mat Groves 2014-01-01 15:00:55 +00:00
parent 2debc70e3f
commit c6ddc833cb
22 changed files with 352 additions and 632 deletions

View file

@ -52,7 +52,6 @@ module.exports = function(grunt) {
'<%= dirs.src %>/extras/Rope.js',
'<%= dirs.src %>/extras/TilingSprite.js',
'<%= dirs.src %>/extras/Spine.js',
'<%= dirs.src %>/extras/CustomRenderable.js',
'<%= dirs.src %>/textures/BaseTexture.js',
'<%= dirs.src %>/textures/Texture.js',
'<%= dirs.src %>/textures/RenderTexture.js',
@ -183,7 +182,7 @@ module.exports = function(grunt) {
spawn: false,
}
}
},
},
karma: {
unit: {
configFile: 'test/karma.conf.js',

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -405,18 +405,22 @@ PIXI.DisplayObject.prototype.updateTransform = function()
PIXI.DisplayObject.prototype.getBounds = function()
{
return PIXI.EmptyRectangle;
}
};
PIXI.DisplayObject.prototype._renderWebGL = function(renderSession)
{
// OVERWRITE
}
// OVERWRITE;
// this line is just here to pass jshinting :)
renderSession = renderSession;
};
PIXI.DisplayObject.prototype._renderCanvas = function(renderSession)
{
// OVERWRITE
}
// OVERWRITE;
// this line is just here to pass jshinting :)
renderSession = renderSession;
};
PIXI.EmptyRectangle = new PIXI.Rectangle(0,0,0,0);

View file

@ -87,7 +87,7 @@ PIXI.DisplayObjectContainer.prototype.addChild = function(child)
// update the stage refference..
if(this.stage)this.setStageReference(this.stage)
if(this.stage)this.setStageReference(this.stage);
};
@ -111,7 +111,7 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
this.children.splice(index, 0, child);
if(this.stage)this.setStageReference(this.stage)
if(this.stage)this.setStageReference(this.stage);
}
else
{
@ -141,7 +141,7 @@ PIXI.DisplayObjectContainer.prototype.swapChildren = function(child, child2)
}
this.children[index1] = child2;
this.children[index2] = child1;
this.children[index2] = child;
};
@ -173,7 +173,7 @@ PIXI.DisplayObjectContainer.prototype.removeChild = function(child)
{
var index = this.children.indexOf( child );
if ( index !== -1 )
{
{
// update the stage reference..
if(this.stage)this.removeStageReference();
@ -207,7 +207,7 @@ PIXI.DisplayObjectContainer.prototype.updateTransform = function()
};
PIXI.DisplayObjectContainer.prototype.getBounds = function()
{
{
if(this.children.length === 0)return PIXI.EmptyRectangle;
// TODO the bounds have already been calculated this render session so return what we have
@ -252,7 +252,7 @@ PIXI.DisplayObjectContainer.prototype.getBounds = function()
//this._currentBounds = bounds;
return bounds;
}
};
PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage)
{
@ -263,8 +263,8 @@ PIXI.DisplayObjectContainer.prototype.setStageReference = function(stage)
var child = this.children[i];
if(child.interactive)this.stage.dirty = true;
child.setStageReference(stage);
}
}
}
};
PIXI.DisplayObjectContainer.prototype.removeStageReference = function()
{
@ -274,13 +274,15 @@ PIXI.DisplayObjectContainer.prototype.removeStageReference = function()
if(child.interactive)this.stage.dirty = true;
child.removeStageReference();
child.stage = null;
}
}
}
};
PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
{
if(this.visible === false || this.alpha === 0)return;
var i,j;
if(this._mask || this._filters)
{
if(this._mask)
@ -291,16 +293,15 @@ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
}
if(this._filters)
{
{
renderSession.spriteBatch.flush();
renderSession.filterManager.pushFilter(this._filterBlock);
}
// simple render children!
for(var i=0,j=this.children.length; i<j; i++)
for(i=0,j=this.children.length; i<j; i++)
{
var child = this.children[i];
child._renderWebGL(renderSession);
this.children[i]._renderWebGL(renderSession);
}
renderSession.spriteBatch.stop();
@ -313,13 +314,12 @@ PIXI.DisplayObjectContainer.prototype._renderWebGL = function(renderSession)
else
{
// simple render children!
for(var i=0,j=this.children.length; i<j; i++)
for(i=0,j=this.children.length; i<j; i++)
{
var child = this.children[i];
child._renderWebGL(renderSession);
this.children[i]._renderWebGL(renderSession);
}
}
}
};
PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
{
@ -340,4 +340,4 @@ PIXI.DisplayObjectContainer.prototype._renderCanvas = function(renderSession)
{
renderSession.maskManager.popMask(renderSession.context);
}
}
};

View file

@ -237,7 +237,7 @@ PIXI.Sprite.prototype.getBounds = function()
this._currentBounds = bounds;
return bounds;
}
};
PIXI.Sprite.prototype._renderWebGL = function(renderSession)
@ -245,6 +245,8 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
// if the sprite is not visible or the alpha is 0 then no need to render this element
if(this.visible === false || this.alpha === 0)return;
var i,j;
// do a quick check to see if this element has a mask or a filter.
if(this._mask || this._filters)
{
@ -258,7 +260,7 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
}
if(this._filters)
{
{
spriteBatch.flush();
renderSession.filterManager.pushFilter(this._filterBlock);
}
@ -267,10 +269,9 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
spriteBatch.render(this);
// now loop through the children and make sure they get rendered
for(var i=0,j=this.children.length; i<j; i++)
for(i=0,j=this.children.length; i<j; i++)
{
var child = this.children[i];
child._renderWebGL(renderSession);
this.children[i]._renderWebGL(renderSession);
}
// time to stop the sprite batch as either a mask element or a filter draw will happen next
@ -286,16 +287,15 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession)
renderSession.spriteBatch.render(this);
// simple render children!
for(var i=0,j=this.children.length; i<j; i++)
for(i=0,j=this.children.length; i<j; i++)
{
var child = this.children[i];
child._renderWebGL(renderSession);
this.children[i]._renderWebGL(renderSession);
}
}
//TODO check culling
}
};
PIXI.Sprite.prototype._renderCanvas = function(renderSession)
{
@ -325,7 +325,7 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession)
// check blend mode
if(this.blendMode !== renderSession.currentBlendMode)
{
renderSession.currentBlendMode = this.blendMode;
renderSession.currentBlendMode = this.blendMode;
context.globalCompositeOperation = PIXI.blendModesCanvas[renderSession.currentBlendMode];
}
@ -375,7 +375,7 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession)
trim.x - this.anchor.x * trim.realWidth,
trim.y - this.anchor.y * trim.realHeight,
frame.width,
frame.height);
frame.height);
}
else
{
@ -388,7 +388,7 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession)
(this.anchor.x) * -frame.width,
(this.anchor.y) * -frame.height,
frame.width,
frame.height);
frame.height);
}
}
@ -405,7 +405,7 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession)
{
renderSession.maskManager.popMask(renderSession.context);
}
}
};
// some helper functions..

View file

@ -1,58 +0,0 @@
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
*/
/**
* This object is one that will allow you to specify custom rendering functions based on render type
*
* @class CustomRenderable
* @extends DisplayObject
* @constructor
*/
PIXI.CustomRenderable = function()
{
PIXI.DisplayObject.call( this );
this.renderable = true;
};
// constructor
PIXI.CustomRenderable.prototype = Object.create( PIXI.DisplayObject.prototype );
PIXI.CustomRenderable.prototype.constructor = PIXI.CustomRenderable;
/**
* If this object is being rendered by a CanvasRenderer it will call this callback
*
* @method renderCanvas
* @param renderer {CanvasRenderer} The renderer instance
*/
PIXI.CustomRenderable.prototype.renderCanvas = function()
{
// override!
};
/**
* If this object is being rendered by a WebGLRenderer it will call this callback to initialize
*
* @method initWebGL
* @param renderer {WebGLRenderer} The renderer instance
*/
PIXI.CustomRenderable.prototype.initWebGL = function()
{
// override!
};
/**
* If this object is being rendered by a WebGLRenderer it will call this callback
*
* @method renderWebGL
* @param rendererGroup {WebGLRenderGroup} The renderer group instance
* @param projectionMatrix {Matrix} The object's projection matrix
*/
PIXI.CustomRenderable.prototype.renderWebGL = function()
{
// not sure if both needed? but ya have for now!
// override!
};

View file

@ -56,7 +56,7 @@ PIXI.TilingSprite.prototype.constructor = PIXI.TilingSprite;
*/
Object.defineProperty(PIXI.TilingSprite.prototype, 'width', {
get: function() {
return this._width
return this._width;
},
set: function(value) {
@ -72,7 +72,7 @@ Object.defineProperty(PIXI.TilingSprite.prototype, 'width', {
*/
Object.defineProperty(PIXI.TilingSprite.prototype, 'height', {
get: function() {
return this._height
return this._height;
},
set: function(value) {
this._height = value;
@ -93,6 +93,8 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
if(this.visible === false || this.alpha === 0)return;
var i,j;
if(this.mask || this.filters)
{
if(this.mask)
@ -103,7 +105,7 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
}
if(this.filters)
{
{
renderSession.spriteBatch.flush();
renderSession.filterManager.pushFilter(this._filterBlock);
}
@ -112,10 +114,9 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
renderSession.spriteBatch.renderTilingSprite(this);
// simple render children!
for(var i=0,j=this.children.length; i<j; i++)
for(i=0,j=this.children.length; i<j; i++)
{
var child = this.children[i];
child._renderWebGL(renderSession);
this.children[i]._renderWebGL(renderSession);
}
renderSession.spriteBatch.stop();
@ -130,13 +131,12 @@ PIXI.TilingSprite.prototype._renderWebGL = function(renderSession)
renderSession.spriteBatch.renderTilingSprite(this);
// simple render children!
for(var i=0,j=this.children.length; i<j; i++)
for(i=0,j=this.children.length; i<j; i++)
{
var child = this.children[i];
child._renderWebGL(renderSession);
this.children[i]._renderWebGL(renderSession);
}
}
}
};
PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
{
@ -152,7 +152,7 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
// check blend mode
if(this.blendMode !== renderSession.currentBlendMode)
{
renderSession.currentBlendMode = this.blendMode;
renderSession.currentBlendMode = this.blendMode;
context.globalCompositeOperation = PIXI.blendModesCanvas[renderSession.currentBlendMode];
}
@ -172,4 +172,4 @@ PIXI.TilingSprite.prototype._renderCanvas = function(renderSession)
context.translate(-tilePosition.x, -tilePosition.y);
context.closePath();
}
};

View file

@ -109,15 +109,15 @@ PIXI.JsonLoader.prototype.onJSONLoaded = function () {
// check to see ifthe sprite ha been trimmed..
if (frameData[i].trimmed) {
var texture = PIXI.TextureCache[i]
var texture = PIXI.TextureCache[i];
texture.trimmed = true;
var actualSize = frameData[i].sourceSize;
var realSize = frameData[i].spriteSourceSize;
texture.trim.x = realSize.x
texture.trim.y = realSize.y
texture.trim.x = realSize.x;
texture.trim.y = realSize.y;
texture.trim.realWidth = actualSize.w;
texture.trim.realHeight = actualSize.h;
}

View file

@ -51,7 +51,7 @@ PIXI.Graphics = function()
*/
this.graphicsData = [];
this.tint = 0xFFFFFF// * Math.random();
this.tint = 0xFFFFFF;// * Math.random();
this.blendMode = PIXI.blendModes.NORMAL;
@ -243,15 +243,15 @@ PIXI.Graphics.prototype._renderWebGL = function(renderSession)
// check blend mode
if(this.blendMode !== renderSession.spriteBatch.currentBlendMode)
{
this.spriteBatch.currentBlendMode = sprite.blendMode;
var blendModeWebGL = PIXI.blendModesWebGL[renderSession.spriteBatch.currentBlendMode];
this.spriteBatch.currentBlendMode = this.blendMode;
var blendModeWebGL = PIXI.blendModesWebGL[renderSession.spriteBatch.currentBlendMode];
this.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
}
PIXI.WebGLGraphics.renderGraphics(this, renderSession);
renderSession.spriteBatch.start();
}
};
PIXI.Graphics.prototype._renderCanvas = function(renderSession)
{
@ -263,13 +263,13 @@ PIXI.Graphics.prototype._renderCanvas = function(renderSession)
if(this.blendMode !== renderSession.currentBlendMode)
{
renderSession.currentBlendMode = this.blendMode;
renderSession.currentBlendMode = this.blendMode;
context.globalCompositeOperation = PIXI.blendModesCanvas[renderSession.currentBlendMode];
}
context.setTransform(transform[0], transform[3], transform[1], transform[4], transform[2], transform[5]);
PIXI.CanvasGraphics.renderGraphics(this, context);
}
};
PIXI.Graphics.prototype.getBounds = function()
{
@ -337,7 +337,7 @@ PIXI.Graphics.prototype.getBounds = function()
bounds.height = maxY - minY;
return bounds;
}
};
PIXI.Graphics.prototype.updateBounds = function()
{

View file

@ -26,7 +26,7 @@ PIXI.CanvasRenderer = function(width, height, view, transparent)
PIXI.blendModesCanvas = [];
if(PIXI.canUseNewCanvasBlendModes())
{
{
PIXI.blendModesCanvas[PIXI.blendModes.NORMAL] = "source-over";
PIXI.blendModesCanvas[PIXI.blendModes.ADD] = "lighter"; //IS THIS OK???
PIXI.blendModesCanvas[PIXI.blendModes.MULTIPLY] = "multiply";
@ -66,26 +66,26 @@ PIXI.CanvasRenderer = function(width, height, view, transparent)
* @property view
* @type Canvas
*/
this.view = view || document.createElement( 'canvas' );
this.view = view || document.createElement( "canvas" );
/**
* The canvas context that the everything is drawn to
* @property context
* @type Canvas 2d Context
*/
this.context = this.view.getContext( '2d' );
this.context = this.view.getContext( "2d" );
//some filter variables
this.smoothProperty = null;
if('imageSmoothingEnabled' in this.context)
this.smoothProperty = 'imageSmoothingEnabled';
else if('webkitImageSmoothingEnabled' in this.context)
this.smoothProperty = 'webkitImageSmoothingEnabled';
else if('mozImageSmoothingEnabled' in this.context)
this.smoothProperty = 'mozImageSmoothingEnabled';
else if('oImageSmoothingEnabled' in this.context)
this.smoothProperty = 'oImageSmoothingEnabled';
if("imageSmoothingEnabled" in this.context)
this.smoothProperty = "imageSmoothingEnabled";
else if("webkitImageSmoothingEnabled" in this.context)
this.smoothProperty = "webkitImageSmoothingEnabled";
else if("mozImageSmoothingEnabled" in this.context)
this.smoothProperty = "mozImageSmoothingEnabled";
else if("oImageSmoothingEnabled" in this.context)
this.smoothProperty = "oImageSmoothingEnabled";
this.scaleMode = null;
@ -215,7 +215,7 @@ PIXI.CanvasRenderer.prototype.renderStripFlat = function(strip)
context.lineTo(x2, y2);
}
context.fillStyle = '#FF0000';
context.fillStyle = "#FF0000";
context.fill();
context.closePath();
};
@ -281,22 +281,22 @@ PIXI.CanvasBuffer = function(width, height)
this.width = width;
this.height = height;
this.canvas = document.createElement( 'canvas' );
this.context = this.canvas.getContext( '2d' );
this.canvas = document.createElement( "canvas" );
this.context = this.canvas.getContext( "2d" );
// this.context.f
this.canvas.width = width;
this.canvas.height = height;
}
};
PIXI.CanvasBuffer.prototype.clear = function()
{
this.context.clearRect(0,0, this.width, this.height);
}
};
PIXI.CanvasBuffer.prototype.resize = function(width, height)
{
this.width = this.canvas.width = width;
this.height = this.canvas.height = height;
}
};

View file

@ -7,10 +7,10 @@
PIXI.CanvasMaskManager = function()
{
}
};
PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, context)
{
{
context.save();
maskData.visible = false;
@ -26,9 +26,9 @@ PIXI.CanvasMaskManager.prototype.pushMask = function(maskData, context)
context.clip();
maskData.worldAlpha = cacheAlpha;
}
};
PIXI.CanvasMaskManager.prototype.popMask = function(context)
{
{
context.restore();
}
};

View file

@ -1,3 +1,4 @@
/**
* @author Mat Groves
*
@ -6,16 +7,14 @@
PIXI.CanvasTinter = function()
{
/// this.textureCach
}
/// this.textureCach
};
//PIXI.CanvasTinter.cachTint = true;
PIXI.CanvasTinter.getTintedTexture = function(sprite, color, canvas)
PIXI.CanvasTinter.getTintedTexture = function(sprite, color)
{
var cacheMode = 0;
//
// cach on sprite
// cach on texture
@ -25,7 +24,7 @@ PIXI.CanvasTinter.getTintedTexture = function(sprite, color, canvas)
color = PIXI.CanvasTinter.roundColor(color);
var stringColor = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
var stringColor = "#" + ("00000" + ( color | 0).toString(16)).substr(-6);
texture.tintCache = texture.tintCache || {};
@ -41,38 +40,38 @@ PIXI.CanvasTinter.getTintedTexture = function(sprite, color, canvas)
if(PIXI.CanvasTinter.convertTintToImage)
{
// is this better?
var tintImage = new Image();
tintImage.src = canvas.toDataURL();
texture.tintCache[stringColor] = tintImage;
// is this better?
var tintImage = new Image();
tintImage.src = canvas.toDataURL();
texture.tintCache[stringColor] = tintImage;
}
else
{
texture.tintCache[stringColor] = canvas;
// if we are not converting the texture to an image then we need to lose the refferance to the canvas
PIXI.CanvasTinter.canvas = null;
texture.tintCache[stringColor] = canvas;
// if we are not converting the texture to an image then we need to lose the refferance to the canvas
PIXI.CanvasTinter.canvas = null;
}
return canvas;
}
};
PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas)
{
var context = canvas.getContext( '2d' );
var context = canvas.getContext( "2d" );
var frame = texture.frame;
canvas.width = frame.width;
canvas.height = frame.height;
context.fillStyle = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
context.fillStyle = "#" + ("00000" + ( color | 0).toString(16)).substr(-6);
context.fillRect(0, 0, frame.width, frame.height);
context.globalCompositeOperation = 'multiply';
context.globalCompositeOperation = "multiply";
context.drawImage(texture.baseTexture.source,
frame.x,
@ -84,7 +83,7 @@ PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas)
frame.width,
frame.height);
context.globalCompositeOperation = 'destination-atop';
context.globalCompositeOperation = "destination-atop";
context.drawImage(texture.baseTexture.source,
frame.x,
@ -94,12 +93,12 @@ PIXI.CanvasTinter.tintWithMultiply = function(texture, color, canvas)
0,
0,
frame.width,
frame.height);
}
frame.height);
};
PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
{
var context = canvas.getContext( '2d' );
{
var context = canvas.getContext( "2d" );
var frame = texture.frame;
@ -108,11 +107,11 @@ PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
context.globalCompositeOperation = 'copy';
context.fillStyle = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
context.globalCompositeOperation = "copy";
context.fillStyle = "#" + ("00000" + ( color | 0).toString(16)).substr(-6);
context.fillRect(0, 0, frame.width, frame.height);
context.globalCompositeOperation = 'destination-atop';
context.globalCompositeOperation = "destination-atop";
context.drawImage(texture.baseTexture.source,
frame.x,
frame.y,
@ -124,21 +123,21 @@ PIXI.CanvasTinter.tintWithOverlay = function(texture, color, canvas)
frame.height);
//context.globalCompositeOperation = 'copy';
//context.globalCompositeOperation = "copy";
}
};
PIXI.CanvasTinter.tintWithPerPixel = function(texture, color, canvas)
{
var context = canvas.getContext( '2d' );
{
var context = canvas.getContext( "2d" );
var frame = texture.frame;
canvas.width = frame.width;
canvas.height = frame.height;
context.globalCompositeOperation = 'copy';
context.globalCompositeOperation = "copy";
context.drawImage(texture.baseTexture.source,
frame.x,
frame.y,
@ -152,19 +151,19 @@ PIXI.CanvasTinter.tintWithPerPixel = function(texture, color, canvas)
var rgbValues = PIXI.hex2rgb(color);
var r = rgbValues[0], g = rgbValues[1], b = rgbValues[2];
var pixelData = context.getImageData(0, 0, frame.width, frame.height)
var pixelData = context.getImageData(0, 0, frame.width, frame.height);
var pixels = pixelData.data;
for (var i = 0; i < pixels.length; i += 4)
{
pixels[i+0] *= r;
pixels[i+1] *= g;
pixels[i+2] *= b;
pixels[i+0] *= r;
pixels[i+1] *= g;
pixels[i+2] *= b;
}
context.putImageData(pixelData, 0, 0);
}
};
PIXI.CanvasTinter.roundColor = function(color)
{
@ -176,52 +175,8 @@ PIXI.CanvasTinter.roundColor = function(color)
rgbValues[1] = Math.round(rgbValues[1] * step) / step;
rgbValues[2] = Math.round(rgbValues[2] * step) / step;
return PIXI.rgb2hex(rgbValues)
}
PIXI.CanvasTinter._getTintedTextureFast = function(texture, color, canvas)
{
var stringColor = '#' + ('00000' + ( color | 0).toString(16)).substr(-6);
// clone texture..
var canvas = canvas || document.createElement("canvas");
var context = canvas.getContext( '2d' );
var frame = texture.frame;
context.width = frame.width;
context.height = frame.height;
context.fillStyle = stringColor;
context.fillRect(0, 0, frame.width, frame.height);
context.globalCompositeOperation = 'multiply';
context.drawImage(texture.baseTexture.source,
frame.x,
frame.y,
frame.width,
frame.height,
0,
0,
frame.width,
frame.height);
context.globalCompositeOperation = 'destination-in';
context.drawImage(texture.baseTexture.source,
frame.x,
frame.y,
frame.width,
frame.height,
0,
0,
frame.width,
frame.height);
return canvas;
}
return PIXI.rgb2hex(rgbValues);
};
PIXI.CanvasTinter.cacheStepsPerColorChannel = 8;
PIXI.CanvasTinter.convertTintToImage = false;

View file

@ -84,7 +84,7 @@ PIXI.PixiShader.prototype.init = function()
PIXI.PixiShader.prototype.initUniforms = function()
{
this.textureCount = 1;
var gl = this.gl
var gl = this.gl;
var uniform;
for (var key in this.uniforms)
@ -297,7 +297,7 @@ PIXI.PixiShader.defaultVertexSrc = [
' gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);',
' vTextureCoord = aTextureCoord;',
' vec3 color = mod(vec3(aColor.y/65536.0, aColor.y/256.0, aColor.y), 256.0) / 256.0;',
' vColor = vec4(color * aColor.x, aColor.x);',
' vColor = vec4(color * aColor.x, aColor.x);',
'}'
];

View file

@ -61,7 +61,7 @@ PIXI.WebGLRenderer = function(width, height, view, transparent, antialias)
} catch (e) {
//try 'webgl'
try {
this.gl = this.view.getContext('webgl', options);
this.gl = this.view.getContext('webgl', options);
} catch (e2) {
// fail, not able to get a context
throw new Error(' This browser does not support webGL. Try using the canvas renderer' + this);
@ -217,7 +217,7 @@ PIXI.WebGLRenderer.prototype.renderDisplayObject = function(displayObject, proje
// finish the sprite batch
this.spriteBatch.end();
}
};
/**
* Updates the textures loaded into this webgl renderer
@ -235,7 +235,7 @@ PIXI.WebGLRenderer.updateTextures = function()
PIXI.WebGLRenderer.updateTexture(PIXI.texturesToUpdate[i]);
for (var i=0; i < PIXI.Texture.frameUpdates.length; i++)
for (i=0; i < PIXI.Texture.frameUpdates.length; i++)
PIXI.WebGLRenderer.updateTextureFrame(PIXI.Texture.frameUpdates[i]);
for (i = 0; i < PIXI.texturesToDestroy.length; i++)

View file

@ -380,7 +380,6 @@ PIXI.WebGLFilterManager.prototype.initShaderBuffers = function()
this.colorArray,
gl.STATIC_DRAW);
this.colorAttribute
// bind and upload the index
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
gl.bufferData(
@ -535,7 +534,7 @@ PIXI.FilterTexture.prototype.clear = function()
gl.clearColor(0,0,0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
}
};
PIXI.FilterTexture.prototype.resize = function(width, height)
{

View file

@ -24,8 +24,8 @@ PIXI.WebGLGraphics = function()
PIXI.WebGLGraphics.renderGraphics = function(graphics, renderSession)//projection, offset)
{
var gl = renderSession.gl;
var projection = renderSession.projection,
offset = renderSession.offset;
var projection = renderSession.projection,
offset = renderSession.offset,
shader = renderSession.shaderManager.primitiveShader;
if(!graphics._webGL)graphics._webGL = {points:[], indices:[], lastIndex:0,

View file

@ -7,10 +7,10 @@ PIXI.WebGLMaskManager = function(gl)
this.gl = gl;
this.maskStack = [];
this.maskPosition = 0;
}
};
PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession)
{
{
var gl = this.gl;
if(this.maskStack.length === 0)
@ -31,10 +31,10 @@ PIXI.WebGLMaskManager.prototype.pushMask = function(maskData, renderSession)
gl.colorMask(true, true, true, true);
gl.stencilFunc(gl.NOTEQUAL,0, this.maskStack.length);
gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP);
}
};
PIXI.WebGLMaskManager.prototype.popMask = function(renderSession)
{
{
var gl = this.gl;
var maskData = this.maskStack.pop();
@ -54,4 +54,4 @@ PIXI.WebGLMaskManager.prototype.popMask = function(renderSession)
}
if(this.maskStack.length === 0)gl.disable(gl.STENCIL_TEST);
}
};

View file

@ -24,7 +24,7 @@ PIXI.WebGLShaderManager = function(gl)
// the final one is used for the rendering strips
//this.stripShader = new PIXI.StripShader(gl);
}
};
PIXI.WebGLShaderManager.prototype.activatePrimitiveShader = function()
@ -53,15 +53,4 @@ PIXI.WebGLShaderManager.prototype.deactivatePrimitiveShader = function()
gl.enableVertexAttribArray(this.defaultShader.aVertexPosition);
gl.enableVertexAttribArray(this.defaultShader.colorAttribute);
gl.enableVertexAttribArray(this.defaultShader.aTextureCoord);
};
PIXI.WebGLShaderManager.prototype.pushShader = function(maskData, renderSession)
{
// push a shader onto the stack..
}
PIXI.WebGLShaderManager.prototype.popShader = function(renderSession)
{
// push
}
};

View file

@ -31,19 +31,19 @@ PIXI.WebGLSpriteBatch = function(gl)
//vertex data
this.vertices = new Float32Array(numVerts);
//index data
this.indices = new Uint16Array(numIndices);
this.indices = new Uint16Array(numIndices);
this.lastIndexCount = 0;
for (var i=0, j=0; i < numIndices; i += 6, j += 4)
for (var i=0, j=0; i < numIndices; i += 6, j += 4)
{
this.indices[i + 0] = j + 0;
this.indices[i + 0] = j + 0;
this.indices[i + 1] = j + 1;
this.indices[i + 2] = j + 2;
this.indices[i + 3] = j + 0;
this.indices[i + 4] = j + 2;
this.indices[i + 5] = j + 3;
};
}
//upload the index data
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
@ -54,25 +54,25 @@ PIXI.WebGLSpriteBatch = function(gl)
this.drawing = false;
this.currentBatchSize = 0;
this.currentBaseTexture;
}
this.currentBaseTexture = null;
};
PIXI.WebGLSpriteBatch.prototype.begin = function(renderSession)
{
{
this.renderSession = renderSession;
this.shader = this.renderSession.shaderManager.defaultShader;
this.start();
}
};
PIXI.WebGLSpriteBatch.prototype.end = function()
{
{
this.flush();
}
};
PIXI.WebGLSpriteBatch.prototype.render = function(sprite)
{
{
// check texture..
if(sprite.texture.baseTexture !== this.currentBaseTexture || this.currentBatchSize >= this.size)
{
@ -116,20 +116,20 @@ PIXI.WebGLSpriteBatch.prototype.render = function(sprite)
w0 = w1 + width;
h1 = trim.y - aY * trim.realHeight;
h0 = h1 + height;
h0 = h1 + height;
}
else
{
var w0 = (width ) * (1-aX);
var w1 = (width ) * -aX;
w0 = (width ) * (1-aX);
w1 = (width ) * -aX;
var h0 = height * (1-aY);
var h1 = height * -aY;
h0 = height * (1-aY);
h1 = height * -aY;
}
var index = this.currentBatchSize * 4 * this.vertSize;
worldTransform = sprite.worldTransform;
var worldTransform = sprite.worldTransform;
var a = worldTransform[0];
var b = worldTransform[3];
@ -182,10 +182,10 @@ PIXI.WebGLSpriteBatch.prototype.render = function(sprite)
this.currentBatchSize++;
}
};
PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
{
{
var texture = tilingSprite.texture;
if(texture.baseTexture !== this.currentBaseTexture || this.currentBatchSize >= this.size)
@ -202,7 +202,6 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
// set the textures uvs temporarily
// TODO create a seperate texture so that we can tile part of a texture
var tempUvs = texture._uvs;
if(!tilingSprite._uvs)tilingSprite._uvs = new Float32Array(8);
@ -247,7 +246,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
var index = this.currentBatchSize * 4 * this.vertSize;
worldTransform = tilingSprite.worldTransform;
var worldTransform = tilingSprite.worldTransform;
var a = worldTransform[0];
var b = worldTransform[3];
@ -298,7 +297,7 @@ PIXI.WebGLSpriteBatch.prototype.renderTilingSprite = function(tilingSprite)
// increment the batchs
this.currentBatchSize++;
}
};
PIXI.WebGLSpriteBatch.prototype.flush = function()
{
@ -322,12 +321,12 @@ PIXI.WebGLSpriteBatch.prototype.flush = function()
// increment the draw count
this.renderSession.drawCount++;
}
};
PIXI.WebGLSpriteBatch.prototype.stop = function()
{
this.flush();
}
};
PIXI.WebGLSpriteBatch.prototype.start = function()
{
@ -355,7 +354,7 @@ PIXI.WebGLSpriteBatch.prototype.start = function()
{
this.setBlendMode(PIXI.blendModes.NORMAL);
}
}
};
PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode)
{
@ -365,6 +364,6 @@ PIXI.WebGLSpriteBatch.prototype.setBlendMode = function(blendMode)
var blendModeWebGL = PIXI.blendModesWebGL[this.currentBlendMode];
this.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]);
}
};

View file

@ -125,7 +125,7 @@ PIXI.Texture.prototype.setFrame = function(frame)
PIXI.Texture.prototype._updateWebGLuvs = function()
{
if(!this._uvs)this._uvs = new Float32Array(8)
if(!this._uvs)this._uvs = new Float32Array(8);
var frame = this.frame;
var tw = this.baseTexture.width;
@ -142,7 +142,7 @@ PIXI.Texture.prototype._updateWebGLuvs = function()
this._uvs[6] = frame.x / tw;
this._uvs[7] = (frame.y + frame.height) / th;
}
};
/**
* Helper function that returns a texture based on an image url

View file

@ -116,11 +116,11 @@ PIXI.AjaxRequest = function AjaxRequest()
return false;
}
};
/*
PIXI.packColorRGBA = function(r, g, b, a)//r, g, b, a)
{
// console.log(r, b, c, d)
return (Math.floor((r)*63) << 18) | (Math.floor((g)*63) << 12) | (Math.floor((b)*63) << 6)// | (Math.floor((a)*63))
return (Math.floor((r)*63) << 18) | (Math.floor((g)*63) << 12) | (Math.floor((b)*63) << 6);// | (Math.floor((a)*63))
// i = i | (Math.floor((a)*63));
// return i;
// var r = (i / 262144.0 ) / 64;
@ -131,17 +131,19 @@ PIXI.packColorRGBA = function(r, g, b, a)//r, g, b, a)
// console.log(r, g, b, a);
// return i;
}
};
*/
/*
PIXI.packColorRGB = function(r, g, b)//r, g, b, a)
{
return (Math.floor((r)*255) << 16) | (Math.floor((g)*255) << 8) | (Math.floor((b)*255));
}
};
PIXI.unpackColorRGB = function(r, g, b)//r, g, b, a)
{
return (Math.floor((r)*255) << 16) | (Math.floor((g)*255) << 8) | (Math.floor((b)*255));
}
};
*/
PIXI.canUseNewCanvasBlendModes = function()
{
@ -155,35 +157,6 @@ PIXI.canUseNewCanvasBlendModes = function()
context.fillStyle = '#fff';
context.fillRect(0,0,1,1);
return context.getImageData(0,0,1,1).data[0] === 0;
}
/*
* DEBUGGING ONLY
*/
PIXI.runList = function(item)
{
window.console.log('>>>>>>>>>');
window.console.log('_');
var safe = 0;
var tmp = item.first;
window.console.log(tmp);
while(tmp._iNext)
{
safe++;
tmp = tmp._iNext;
window.console.log(tmp);
// console.log(tmp);
if(safe > 100)
{
window.console.log('BREAK');
break;
}
}
};