Skip to content

Commit 5db55a8

Browse files
committed
The Graphics Game Objects now support rendering in Light2d. You can even use normal map textures for the texture fills.
1 parent a62c456 commit 5db55a8

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

src/gameobjects/graphics/GraphicsWebGLRenderer.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
104104

105105
var getTint = Utils.getTintAppendFloatAlphaAndSwap;
106106

107-
var currentTexture = renderer.blankTexture.glTexture;
107+
// Set to a white texture, not a blank one, so Lights2D works too!
108+
var currentTexture = renderer.tempTextures[0];
108109

109110
for (var cmdIndex = 0; cmdIndex < commands.length; cmdIndex++)
110111
{
@@ -132,7 +133,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
132133
case Commands.FILL_PATH:
133134
for (pathIndex = 0; pathIndex < path.length; pathIndex++)
134135
{
135-
pipeline.setTexture2D(currentTexture);
136+
pipeline.setTexture2D(currentTexture, src);
136137

137138
pipeline.batchFillPath(
138139
path[pathIndex].points,
@@ -145,7 +146,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
145146
case Commands.STROKE_PATH:
146147
for (pathIndex = 0; pathIndex < path.length; pathIndex++)
147148
{
148-
pipeline.setTexture2D(currentTexture);
149+
pipeline.setTexture2D(currentTexture, src);
149150

150151
pipeline.batchStrokePath(
151152
path[pathIndex].points,
@@ -254,7 +255,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
254255
break;
255256

256257
case Commands.FILL_RECT:
257-
pipeline.setTexture2D(currentTexture);
258+
pipeline.setTexture2D(currentTexture, src);
258259
pipeline.batchFillRect(
259260
commands[++cmdIndex],
260261
commands[++cmdIndex],
@@ -266,7 +267,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
266267
break;
267268

268269
case Commands.FILL_TRIANGLE:
269-
pipeline.setTexture2D(currentTexture);
270+
pipeline.setTexture2D(currentTexture, src);
270271
pipeline.batchFillTriangle(
271272
commands[++cmdIndex],
272273
commands[++cmdIndex],
@@ -280,7 +281,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
280281
break;
281282

282283
case Commands.STROKE_TRIANGLE:
283-
pipeline.setTexture2D(currentTexture);
284+
pipeline.setTexture2D(currentTexture, src);
284285
pipeline.batchStrokeTriangle(
285286
commands[++cmdIndex],
286287
commands[++cmdIndex],
@@ -340,7 +341,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
340341
var mode = commands[++cmdIndex];
341342

342343
pipeline.currentFrame = frame;
343-
pipeline.setTexture2D(frame.glTexture, 0);
344+
pipeline.setTexture2D(frame.glTexture, src);
344345
pipeline.tintEffect = mode;
345346

346347
currentTexture = frame.glTexture;
@@ -350,7 +351,7 @@ var GraphicsWebGLRenderer = function (renderer, src, interpolationPercentage, ca
350351
case Commands.CLEAR_TEXTURE:
351352
pipeline.currentFrame = renderer.blankTexture;
352353
pipeline.tintEffect = 2;
353-
currentTexture = renderer.blankTexture.glTexture;
354+
currentTexture = renderer.tempTextures[0];
354355
break;
355356
}
356357
}

0 commit comments

Comments
 (0)