diff --git a/src/core/const.js b/src/core/const.js index 8ed6162..be143e6 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -11,7 +11,7 @@ * @constant * @property {string} VERSION */ - VERSION: require('../../package.json').version, + VERSION: '__VERSION__', /** * @property {number} PI_2 - Two Pi @@ -162,7 +162,7 @@ RESOLUTION:1, FILTER_RESOLUTION:1, - + /** * The default render options if none are supplied to {@link PIXI.WebGLRenderer} * or {@link PIXI.CanvasRenderer}. @@ -215,7 +215,8 @@ // TODO: maybe change to SPRITE.BATCH_SIZE: 2000 // TODO: maybe add PARTICLE.BATCH_SIZE: 15000 - SPRITE_BATCH_SIZE: 4000 //nice balance between mobile and desktop machines + SPRITE_BATCH_SIZE: 2000, //nice balance between mobile and desktop machines + SPRITE_MAX_TEXTURES: 32//this is the MAXIMUM - various gpus will have there own limits. }; module.exports = CONST; diff --git a/src/core/const.js b/src/core/const.js index 8ed6162..be143e6 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -11,7 +11,7 @@ * @constant * @property {string} VERSION */ - VERSION: require('../../package.json').version, + VERSION: '__VERSION__', /** * @property {number} PI_2 - Two Pi @@ -162,7 +162,7 @@ RESOLUTION:1, FILTER_RESOLUTION:1, - + /** * The default render options if none are supplied to {@link PIXI.WebGLRenderer} * or {@link PIXI.CanvasRenderer}. @@ -215,7 +215,8 @@ // TODO: maybe change to SPRITE.BATCH_SIZE: 2000 // TODO: maybe add PARTICLE.BATCH_SIZE: 15000 - SPRITE_BATCH_SIZE: 4000 //nice balance between mobile and desktop machines + SPRITE_BATCH_SIZE: 2000, //nice balance between mobile and desktop machines + SPRITE_MAX_TEXTURES: 32//this is the MAXIMUM - various gpus will have there own limits. }; module.exports = CONST; diff --git a/src/core/sprites/webgl/SpriteRenderer.js b/src/core/sprites/webgl/SpriteRenderer.js index 4ace97a..2bd1ed4 100644 --- a/src/core/sprites/webgl/SpriteRenderer.js +++ b/src/core/sprites/webgl/SpriteRenderer.js @@ -111,11 +111,9 @@ var gl = this.renderer.gl; - this.MAX_TEXTURES = gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS); - + this.MAX_TEXTURES = Math.min(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS), CONST.SPRITE_MAX_TEXTURES); this.shader = generateMultiTextureShader(gl, this.MAX_TEXTURES); - // create a couple of buffers this.vertexBuffer = glCore.GLBuffer.createVertexBuffer(gl, null, gl.DYNAMIC_DRAW); this.indexBuffer = glCore.GLBuffer.createIndexBuffer(gl, this.indices, gl.STATIC_DRAW); @@ -176,7 +174,6 @@ var sprites = this.sprites; var groups = this.groups; - var currentIndex = this.currentIndex; var colors = buffer.colors; var positions = buffer.positions; @@ -194,10 +191,11 @@ var textureId; var blendMode = 0; currentGroup.textureCount = 0; - + currentGroup.start = 0; + this.tick++; - for (var i = 0; i < currentIndex; i++) + for (var i = 0; i < this.currentIndex; i++) { // upload the sprite elemetns... // they have all ready been calculated so we just need to push them into the buffer. @@ -217,22 +215,26 @@ currentTexture = nextTexture; if(nextTexture._enabled !== this.tick) - { + { nextTexture._enabled = this.tick; nextTexture._id = textureCount; - + if(textureCount === this.MAX_TEXTURES) { this.tick++; textureCount = 0; - currentGroup.size = currentIndex - currentGroup.start; + currentGroup.size = i - currentGroup.start; currentGroup = groups[groupCount++]; currentGroup.textureCount = 0; currentGroup.blend = blendMode; - currentGroup.start = currentIndex; + currentGroup.start = i; + } + else + { + } currentGroup.textures[currentGroup.textureCount++] = nextTexture; @@ -278,10 +280,10 @@ }; - currentGroup.size = currentIndex - currentGroup.start; + currentGroup.size = i - currentGroup.start; this.vertexBuffer.upload(buffer.vertices, 0, true); - + /// render the groups.. for (i = 0; i < groupCount; i++) {