diff --git a/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js b/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js index 3081078..18727e1 100644 --- a/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js +++ b/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js @@ -34,6 +34,13 @@ * * @member {number} */ + this.vertByteSize = this.vertSize * 4; + + /** + * + * + * @member {number} + */ this.maxSize = 6000;//Math.pow(2, 16) / this.vertSize; /** @@ -44,7 +51,7 @@ this.size = this.maxSize; //the total number of floats in our batch - var numVerts = this.size * 4 * this.vertSize; + var numVerts = this.size * this.vertByteSize; //the total number of indices in our batch var numIndices = this.maxSize * 6; @@ -257,7 +264,7 @@ h1 = sprite.texture.frame.height * -sprite.anchor.y; } - index = this.currentBatchSize * 4 * this.vertSize; + index = this.currentBatchSize * this.vertByteSize; // xy vertices[index++] = w1; @@ -378,7 +385,7 @@ gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertices); } else { - var view = this.vertices.subarray(0, this.currentBatchSize * 4 * this.vertSize); + var view = this.vertices.subarray(0, this.currentBatchSize * this.vertByteSize); gl.bufferSubData(gl.ARRAY_BUFFER, 0, view); } @@ -423,7 +430,7 @@ gl.uniformMatrix3fv(this.shader.uMatrix, false, this.matrix); // set the pointers - var stride = this.vertSize * 4; + var stride = this.vertByteSize; gl.vertexAttribPointer(this.shader.attributes.aVertexPosition, 2, gl.FLOAT, false, stride, 0); gl.vertexAttribPointer(this.shader.attributes.aPositionCoord, 2, gl.FLOAT, false, stride, 2 * 4); diff --git a/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js b/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js index 3081078..18727e1 100644 --- a/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js +++ b/src/core/renderers/webgl/utils/WebGLFastSpriteBatch.js @@ -34,6 +34,13 @@ * * @member {number} */ + this.vertByteSize = this.vertSize * 4; + + /** + * + * + * @member {number} + */ this.maxSize = 6000;//Math.pow(2, 16) / this.vertSize; /** @@ -44,7 +51,7 @@ this.size = this.maxSize; //the total number of floats in our batch - var numVerts = this.size * 4 * this.vertSize; + var numVerts = this.size * this.vertByteSize; //the total number of indices in our batch var numIndices = this.maxSize * 6; @@ -257,7 +264,7 @@ h1 = sprite.texture.frame.height * -sprite.anchor.y; } - index = this.currentBatchSize * 4 * this.vertSize; + index = this.currentBatchSize * this.vertByteSize; // xy vertices[index++] = w1; @@ -378,7 +385,7 @@ gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertices); } else { - var view = this.vertices.subarray(0, this.currentBatchSize * 4 * this.vertSize); + var view = this.vertices.subarray(0, this.currentBatchSize * this.vertByteSize); gl.bufferSubData(gl.ARRAY_BUFFER, 0, view); } @@ -423,7 +430,7 @@ gl.uniformMatrix3fv(this.shader.uMatrix, false, this.matrix); // set the pointers - var stride = this.vertSize * 4; + var stride = this.vertByteSize; gl.vertexAttribPointer(this.shader.attributes.aVertexPosition, 2, gl.FLOAT, false, stride, 0); gl.vertexAttribPointer(this.shader.attributes.aPositionCoord, 2, gl.FLOAT, false, stride, 2 * 4); diff --git a/src/core/renderers/webgl/utils/WebGLSpriteBatch.js b/src/core/renderers/webgl/utils/WebGLSpriteBatch.js index 5dedfe3..96eaa52 100644 --- a/src/core/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/core/renderers/webgl/utils/WebGLSpriteBatch.js @@ -35,6 +35,13 @@ this.vertSize = 5; /** + * + * + * @member {number} + */ + this.vertByteSize = this.vertSize * 4; + + /** * The number of images in the SpriteBatch before it flushes. * * @member {number} @@ -42,7 +49,7 @@ this.size = 2000;//Math.pow(2, 16) / this.vertSize; // the total number of bytes in our batch - var numVerts = this.size * 4 * 4 * this.vertSize; + var numVerts = this.size * 4 * this.vertByteSize; // the total number of indices in our batch var numIndices = this.size * 6; @@ -249,7 +256,7 @@ h1 = texture.frame.height * -aY; } - var index = this.currentBatchSize * 4 * this.vertSize; + var index = this.currentBatchSize * this.vertByteSize; var resolution = texture.baseTexture.resolution; @@ -390,7 +397,7 @@ var h0 = height * (1-aY); var h1 = height * -aY; - var index = this.currentBatchSize * 4 * this.vertSize; + var index = this.currentBatchSize * this.vertByteSize; var resolution = texture.baseTexture.resolution; @@ -466,7 +473,7 @@ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer); // this is the same for each shader? - var stride = this.vertSize * 4; + var stride = this.vertByteSize; gl.vertexAttribPointer(this.shader.attributes.aVertexPosition, 2, gl.FLOAT, false, stride, 0); gl.vertexAttribPointer(this.shader.attributes.aTextureCoord, 2, gl.FLOAT, false, stride, 2 * 4); @@ -479,7 +486,7 @@ gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.vertices); } else { - var view = this.positions.subarray(0, this.currentBatchSize * 4 * this.vertSize); + var view = this.positions.subarray(0, this.currentBatchSize * this.vertByteSize); gl.bufferSubData(gl.ARRAY_BUFFER, 0, view); }