Skip to content

Commit e126468

Browse files
authored
Merge pull request #487 from adroitwhiz/pen-stamp-to-framebuffer
penStamp() directly to the PenSkin's framebuffer
2 parents b1274d5 + b1419d0 commit e126468

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/RenderWebGL.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,23 +1542,20 @@ class RenderWebGL extends EventEmitter {
15421542
const skin = /** @type {PenSkin} */ this._allSkins[penSkinID];
15431543

15441544
const gl = this._gl;
1545-
twgl.bindFramebufferInfo(gl, this._queryBufferInfo);
1545+
twgl.bindFramebufferInfo(gl, skin._framebuffer);
15461546

15471547
// Limit size of viewport to the bounds around the stamp Drawable and create the projection matrix for the draw.
1548-
gl.viewport(0, 0, bounds.width, bounds.height);
1548+
gl.viewport(
1549+
(this._nativeSize[0] * 0.5) + bounds.left,
1550+
(this._nativeSize[1] * 0.5) - bounds.top,
1551+
bounds.width,
1552+
bounds.height
1553+
);
15491554
const projection = twgl.m4.ortho(bounds.left, bounds.right, bounds.top, bounds.bottom, -1, 1);
15501555

1551-
gl.clearColor(0, 0, 0, 0);
1552-
gl.clear(gl.COLOR_BUFFER_BIT);
1553-
1554-
try {
1555-
gl.disable(gl.BLEND);
1556-
this._drawThese([stampID], ShaderManager.DRAW_MODE.stamp, projection, {ignoreVisibility: true});
1557-
} finally {
1558-
gl.enable(gl.BLEND);
1559-
}
1560-
1561-
skin._drawToBuffer(this._queryBufferInfo.attachments[0], bounds.left, bounds.top);
1556+
// Draw the stamped sprite onto the PenSkin's framebuffer.
1557+
this._drawThese([stampID], ShaderManager.DRAW_MODE.stamp, projection, {ignoreVisibility: true});
1558+
skin._silhouetteDirty = true;
15621559
}
15631560

15641561
/* ******

0 commit comments

Comments
 (0)