Skip to content

Commit 4b27b37

Browse files
committed
Added texture and unit arguments to batchQuad and batchTri, fixing the y2k bug.
1 parent bacff65 commit 4b27b37

6 files changed

Lines changed: 18 additions & 15 deletions

File tree

src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextWebGLRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ var DynamicBitmapTextWebGLRenderer = function (renderer, src, interpolationPerce
286286
ty3 = Math.round(ty3);
287287
}
288288

289-
pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect);
289+
pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, 0);
290290
}
291291

292292
if (crop)

src/gameobjects/bitmaptext/static/BitmapTextWebGLRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ var BitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage,
216216
ty3 = Math.round(ty3);
217217
}
218218

219-
pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect);
219+
pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, 0);
220220
}
221221
};
222222

src/gameobjects/blitter/BlitterWebGLRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ var BlitterWebGLRenderer = function (renderer, src, interpolationPercentage, cam
114114
}
115115

116116
// TL x/y, BL x/y, BR x/y, TR x/y
117-
if (pipeline.batchQuad(tx0, ty0, tx0, ty1, tx1, ty1, tx1, ty0, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect))
117+
if (pipeline.batchQuad(tx0, ty0, tx0, ty1, tx1, ty1, tx1, ty0, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect, frame.glTexture, 0))
118118
{
119119
prevTextureSourceIndex = -1;
120120
}

src/gameobjects/particles/ParticleManagerWebGLRenderer.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,7 @@ var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpola
133133

134134
var tint = getTint(particle.tint, alpha);
135135

136-
if (pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect))
137-
{
138-
pipeline.setTexture2D(texture, 0);
139-
}
136+
pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, tintEffect, texture, 0);
140137
}
141138
}
142139
};

src/renderer/webgl/pipelines/ForwardDiffuseLightPipeline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ var ForwardDiffuseLightPipeline = new Class({
377377

378378
this.setTexture2D(texture, 0);
379379

380-
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect);
380+
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, 0);
381381
},
382382

383383
/**

src/renderer/webgl/pipelines/TextureTintPipeline.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -633,13 +633,11 @@ var TextureTintPipeline = new Class({
633633
ty3 = Math.round(ty3);
634634
}
635635

636-
// Adds texture to batch (if not present)
637636
this.setTexture2D(texture, 0);
638637

639638
var tintEffect = (sprite._isTinted && sprite.tintFill);
640639

641-
// Flushes batch if full, which can take the texture batch with it
642-
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect);
640+
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, 0);
643641
},
644642

645643
/**
@@ -679,10 +677,12 @@ var TextureTintPipeline = new Class({
679677
* @param {number} tintBL - The bottom-left tint color value.
680678
* @param {number} tintBR - The bottom-right tint color value.
681679
* @param {(number|boolean)} tintEffect - The tint effect for the shader to use.
680+
* @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch if a flush occurs.
681+
* @param {integer} [unit=0] - Texture unit to which the texture needs to be bound.
682682
*
683683
* @return {boolean} `true` if this method caused the batch to flush, otherwise `false`.
684684
*/
685-
batchQuad: function (x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect)
685+
batchQuad: function (x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, unit)
686686
{
687687
var hasFlushed = false;
688688

@@ -691,6 +691,8 @@ var TextureTintPipeline = new Class({
691691
this.flush();
692692

693693
hasFlushed = true;
694+
695+
this.setTexture2D(texture, unit);
694696
}
695697

696698
var vertexViewF32 = this.vertexViewF32;
@@ -777,17 +779,21 @@ var TextureTintPipeline = new Class({
777779
* @param {number} tintTR - The top-right tint color value.
778780
* @param {number} tintBL - The bottom-left tint color value.
779781
* @param {(number|boolean)} tintEffect - The tint effect for the shader to use.
782+
* @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch if a flush occurs.
783+
* @param {integer} [unit=0] - Texture unit to which the texture needs to be bound.
780784
*
781785
* @return {boolean} `true` if this method caused the batch to flush, otherwise `false`.
782786
*/
783-
batchTri: function (x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect)
787+
batchTri: function (x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect, texture, unit)
784788
{
785789
var hasFlushed = false;
786790

787791
if (this.vertexCount + 3 > this.vertexCapacity)
788792
{
789793
this.flush();
790794

795+
this.setTexture2D(texture, unit);
796+
791797
hasFlushed = true;
792798
}
793799

@@ -1002,7 +1008,7 @@ var TextureTintPipeline = new Class({
10021008

10031009
this.setTexture2D(texture, 0);
10041010

1005-
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect);
1011+
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, texture, 0);
10061012
},
10071013

10081014
/**
@@ -1060,7 +1066,7 @@ var TextureTintPipeline = new Class({
10601066

10611067
tint = Utils.getTintAppendFloatAlpha(tint, alpha);
10621068

1063-
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, 0);
1069+
this.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, frame.u0, frame.v0, frame.u1, frame.v1, tint, tint, tint, tint, 0, frame.glTexture, 0);
10641070
},
10651071

10661072
/**

0 commit comments

Comments
 (0)