Shapes and Graphics now set textures correctly (after batch texture changes)

This commit is contained in:
Richard Davey 2018-10-12 15:09:21 +01:00
parent 9dc53d1e5a
commit a0d3137f76
8 changed files with 40 additions and 3 deletions

View file

@ -104,6 +104,8 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
var getTint = Utils.getTintAppendFloatAlphaAndSwap;
var currentTexture = renderer.blankTexture.glTexture;
for (var cmdIndex = 0; cmdIndex < commands.length; cmdIndex++)
{
cmd = commands[cmdIndex];
@ -130,6 +132,8 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
case Commands.FILL_PATH:
for (pathIndex = 0; pathIndex < path.length; pathIndex++)
{
pipeline.setTexture2D(currentTexture);
pipeline.batchFillPath(
path[pathIndex].points,
currentMatrix,
@ -141,6 +145,8 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
case Commands.STROKE_PATH:
for (pathIndex = 0; pathIndex < path.length; pathIndex++)
{
pipeline.setTexture2D(currentTexture);
pipeline.batchStrokePath(
path[pathIndex].points,
lineWidth,
@ -248,6 +254,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
break;
case Commands.FILL_RECT:
pipeline.setTexture2D(currentTexture);
pipeline.batchFillRect(
commands[++cmdIndex],
commands[++cmdIndex],
@ -259,6 +266,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
break;
case Commands.FILL_TRIANGLE:
pipeline.setTexture2D(currentTexture);
pipeline.batchFillTriangle(
commands[++cmdIndex],
commands[++cmdIndex],
@ -272,6 +280,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
break;
case Commands.STROKE_TRIANGLE:
pipeline.setTexture2D(currentTexture);
pipeline.batchStrokeTriangle(
commands[++cmdIndex],
commands[++cmdIndex],
@ -331,16 +340,18 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
var mode = commands[++cmdIndex];
pipeline.currentFrame = frame;
renderer.setTexture2D(frame.glTexture, 0);
pipeline.setTexture2D(frame.glTexture, 0);
pipeline.tintEffect = mode;
currentTexture = frame.glTexture;
break;
case Commands.CLEAR_TEXTURE:
pipeline.currentFrame = renderer.blankTexture;
renderer.setTexture2D(renderer.blankTexture.glTexture, 0);
pipeline.tintEffect = 2;
currentTexture = renderer.blankTexture.glTexture;
break;
}
}
};

View file

@ -49,6 +49,8 @@ var FillPathWebGL = function (pipeline, calcMatrix, src, alpha, dx, dy)
var tx2 = calcMatrix.getX(x2, y2);
var ty2 = calcMatrix.getY(x2, y2);
pipeline.setTexture2D();
pipeline.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, 0, 0, 1, 1, fillTintColor, fillTintColor, fillTintColor, pipeline.tintEffect);
}
};

View file

@ -47,6 +47,8 @@ var StrokePathWebGL = function (pipeline, src, alpha, dx, dy)
var px2 = path[i] - dx;
var py2 = path[i + 1] - dy;
pipeline.setTexture2D();
pipeline.batchLine(
px1,
py1,

View file

@ -133,6 +133,8 @@ var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera
cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB;
ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB;
pipeline.setTexture2D();
pipeline.batchFillRect(
x * cellWidth,
y * cellHeight,
@ -173,6 +175,8 @@ var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera
cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB;
ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB;
pipeline.setTexture2D();
pipeline.batchFillRect(
x * cellWidth,
y * cellHeight,
@ -197,6 +201,8 @@ var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera
{
var x1 = x * cellWidth;
pipeline.setTexture2D();
pipeline.batchLine(x1, 0, x1, height, 1, 1, 1, 0, false);
}
@ -204,6 +210,8 @@ var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera
{
var y1 = y * cellHeight;
pipeline.setTexture2D();
pipeline.batchLine(0, y1, width, y1, 1, 1, 1, 0, false);
}
}

View file

@ -96,6 +96,8 @@ var IsoBoxWebGLRenderer = function (renderer, src, interpolationPercentage, came
x3 = calcMatrix.getX(0, sizeB - height);
y3 = calcMatrix.getY(0, sizeB - height);
pipeline.setTexture2D();
pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2);
}
@ -117,6 +119,8 @@ var IsoBoxWebGLRenderer = function (renderer, src, interpolationPercentage, came
x3 = calcMatrix.getX(-sizeA, -height);
y3 = calcMatrix.getY(-sizeA, -height);
pipeline.setTexture2D();
pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2);
}
@ -138,6 +142,8 @@ var IsoBoxWebGLRenderer = function (renderer, src, interpolationPercentage, came
x3 = calcMatrix.getX(sizeA, -height);
y3 = calcMatrix.getY(sizeA, -height);
pipeline.setTexture2D();
pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2);
}

View file

@ -95,6 +95,8 @@ var IsoTriangleWebGLRenderer = function (renderer, src, interpolationPercentage,
var x3 = calcMatrix.getX(0, sizeB - height);
var y3 = calcMatrix.getY(0, sizeB - height);
pipeline.setTexture2D();
pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2);
}
@ -159,6 +161,8 @@ var IsoTriangleWebGLRenderer = function (renderer, src, interpolationPercentage,
x2 = calcMatrix.getX(0, sizeB - height);
y2 = calcMatrix.getY(0, sizeB - height);
}
pipeline.setTexture2D();
pipeline.batchTri(x0, y0, x1, y1, x2, y2, 0, 0, 1, 1, tint, tint, tint, 2);
}

View file

@ -66,6 +66,8 @@ var LineWebGLRenderer = function (renderer, src, interpolationPercentage, camera
var startWidth = src._startWidth;
var endWidth = src._endWidth;
pipeline.setTexture2D();
pipeline.batchLine(
src.geom.x1 - dx,
src.geom.y1 - dy,

View file

@ -74,6 +74,8 @@ var TriangleWebGLRenderer = function (renderer, src, interpolationPercentage, ca
var x3 = src.geom.x3 - dx;
var y3 = src.geom.y3 - dy;
pipeline.setTexture2D();
pipeline.batchFillTriangle(
x1,
y1,