diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 4c1c27c..8c07212 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -310,7 +310,7 @@ } } - this.renderGeometry(sprite, float32View, uint32View, indexBuffer, index, indexCount);// argb, nextTexture._id, float32View, uint32View, indexBuffer, index, indexCount); + this.packGeometry(sprite, float32View, uint32View, indexBuffer, index, indexCount);// argb, nextTexture._id, float32View, uint32View, indexBuffer, index, indexCount); // push a graphics.. index += (sprite.vertexData.length / 2) * 6; @@ -382,7 +382,7 @@ // set the blend mode.. stateSystem.setBlendMode(group.blend); - gl.drawElements(gl.TRIANGLES, group.size, gl.UNSIGNED_SHORT, group.start * 2); + gl.drawElements(group.type, group.size, gl.UNSIGNED_SHORT, group.start * 2); } // reset elements for the next flush @@ -391,7 +391,7 @@ this.currentIndexSize = 0; } - renderGeometry(element, float32View, uint32View, indexBuffer, index, indexCount) + packGeometry(element, float32View, uint32View, indexBuffer, index, indexCount) { const p = index / 6;// float32View.length / 6 / 2; const uvs = element.uvs; diff --git a/packages/core/src/batch/BatchRenderer.js b/packages/core/src/batch/BatchRenderer.js index 4c1c27c..8c07212 100644 --- a/packages/core/src/batch/BatchRenderer.js +++ b/packages/core/src/batch/BatchRenderer.js @@ -310,7 +310,7 @@ } } - this.renderGeometry(sprite, float32View, uint32View, indexBuffer, index, indexCount);// argb, nextTexture._id, float32View, uint32View, indexBuffer, index, indexCount); + this.packGeometry(sprite, float32View, uint32View, indexBuffer, index, indexCount);// argb, nextTexture._id, float32View, uint32View, indexBuffer, index, indexCount); // push a graphics.. index += (sprite.vertexData.length / 2) * 6; @@ -382,7 +382,7 @@ // set the blend mode.. stateSystem.setBlendMode(group.blend); - gl.drawElements(gl.TRIANGLES, group.size, gl.UNSIGNED_SHORT, group.start * 2); + gl.drawElements(group.type, group.size, gl.UNSIGNED_SHORT, group.start * 2); } // reset elements for the next flush @@ -391,7 +391,7 @@ this.currentIndexSize = 0; } - renderGeometry(element, float32View, uint32View, indexBuffer, index, indexCount) + packGeometry(element, float32View, uint32View, indexBuffer, index, indexCount) { const p = index / 6;// float32View.length / 6 / 2; const uvs = element.uvs; diff --git a/packages/graphics/src/GraphicsGeometry.js b/packages/graphics/src/GraphicsGeometry.js index ad8a830..2aef678 100644 --- a/packages/graphics/src/GraphicsGeometry.js +++ b/packages/graphics/src/GraphicsGeometry.js @@ -522,7 +522,7 @@ this.indicesUint16 = new Uint16Array(this.indices); // TODO make this a const.. - this.batchable = this.points.length < GraphicsGeometry.BATCHABLE_SIZE * 2; + this.batchable = this.isBatchable(); if (this.batchable) { @@ -550,6 +550,26 @@ } /** + * Checks to see if this graphics geometry can be batched. + * Currently it needs to be small enough and not contain any native lines. + * @private + */ + isBatchable() + { + const batches = this.batches; + + for (let i = 0; i < batches.length; i++) + { + if (batches[i].style.native) + { + return false; + } + } + + return (this.points.length < GraphicsGeometry.BATCHABLE_SIZE * 2); + } + + /** * Converts intermediate batches data to drawCalls. * @private */