mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
BlitterBatch will now flush if you try to add too many Bobs (avoids index error).
This commit is contained in:
parent
36d627d165
commit
d480263fa9
5 changed files with 13 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
|||
var CHECKSUM = {
|
||||
build: '9783ae10-f200-11e6-8fd1-91715dad763f'
|
||||
build: '1ab7d5b0-f236-11e6-867a-17ae0be84b32'
|
||||
};
|
||||
module.exports = CHECKSUM;
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
var BlitterWebGLRenderer = function (renderer, src, interpolationPercentage)
|
||||
{
|
||||
var worldAlpha = src.color.worldAlpha;
|
||||
|
@ -12,16 +11,12 @@ var BlitterWebGLRenderer = function (renderer, src, interpolationPercentage)
|
|||
}
|
||||
|
||||
// Render bobs
|
||||
|
||||
for (var i = 0; i <= len; ++i)
|
||||
{
|
||||
var bob = src.children.list[i];
|
||||
var frame = bob.frame;
|
||||
|
||||
// if (!bob.visible)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
renderer.blitterBatch.add(bob.x, bob.y, frame, worldAlpha);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
var ProcessKeyDown = function (event, list, prevent)
|
||||
{
|
||||
if (prevent === undefined) { prevent = false; }
|
||||
if (prevent === undefined) { prevent = false; }
|
||||
|
||||
if (list)
|
||||
{
|
||||
|
|
|
@ -86,6 +86,7 @@ BlitterBatch.prototype = {
|
|||
this.indexBufferObject = indexBufferObject;
|
||||
this.vertexArray = vertexArray;
|
||||
this.viewMatrixLocation = viewMatrixLocation;
|
||||
this.maxParticles = max;
|
||||
|
||||
// Populate the index buffer only once
|
||||
for (var indexA = 0, indexB = 0; indexA < max; indexA += CONST.PARTICLE_INDEX_COUNT, indexB += CONST.PARTICLE_VERTEX_COUNT)
|
||||
|
@ -115,16 +116,20 @@ BlitterBatch.prototype = {
|
|||
{
|
||||
this.manager.setBatch(this, frame.texture.source[frame.sourceIndex].glTexture);
|
||||
|
||||
// The user must check if the buffers are full before flushing
|
||||
// this is to give freedom of when should the renderer flush. var vertexDataBuffer = this.vertexDataBuffer;
|
||||
if (this.elementCount >= this.maxParticles)
|
||||
{
|
||||
this.flush();
|
||||
}
|
||||
|
||||
var vertexDataBuffer = this.vertexDataBuffer;
|
||||
var vertexBuffer = vertexDataBuffer.floatView;
|
||||
var vertexOffset = vertexDataBuffer.allocate(CONST.PARTICLE_VERTEX_COMPONENT_COUNT * CONST.PARTICLE_VERTEX_COUNT);
|
||||
var uvs = frame.uvs;
|
||||
var width = frame.width;
|
||||
var height = frame.height;
|
||||
x += frame.x
|
||||
y += frame.y
|
||||
|
||||
x += frame.x;
|
||||
y += frame.y;
|
||||
|
||||
vertexBuffer[vertexOffset++] = x;
|
||||
vertexBuffer[vertexOffset++] = y;
|
||||
|
|
|
@ -12,7 +12,7 @@ var CONST = {
|
|||
// How many 32-bit components does the vertex have.
|
||||
PARTICLE_VERTEX_COMPONENT_COUNT: 5,
|
||||
|
||||
// Can't be bigger since index are 16-bit
|
||||
// Can't be bigger than 10,000 since index are 16-bit
|
||||
MAX_PARTICLES: 2000,
|
||||
|
||||
VERTEX_SHADER_SOURCE: VertexShader,
|
||||
|
|
Loading…
Reference in a new issue