Skip to content

Commit

Permalink
Bind to null framebuffer only when copy from main canvas (#10486)
Browse files Browse the repository at this point in the history
The render target system's copyToTexture assumes that if the source render surface is a canvas, then it must be the main framebuffer. But this is false if someone is trying to copy from a secondary or offscreen canvas.

For a bug repro, see this JSFiddle
https://jsfiddle.net/ShukantPal/vwrh51qs/27/

I've verified locally that this fix causes the gradient to paint correctly
  • Loading branch information
ShukantPal committed Apr 30, 2024
1 parent 0905750 commit fe1c4c5
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Rectangle } from '../../../../maths/shapes/Rectangle';
import { warn } from '../../../../utils/logging/warn';
import { CanvasSource } from '../../shared/texture/sources/CanvasSource';
import { CLEAR } from '../const';
import { GlRenderTarget } from '../GlRenderTarget';

Expand Down Expand Up @@ -162,8 +161,8 @@ export class GlRenderTargetAdaptor implements RenderTargetAdaptor<GlRenderTarget

const glRenderTarget = new GlRenderTarget();

// we are rendering to a canvas..
if (CanvasSource.test(renderTarget.colorTexture.resource))
// we are rendering to the main canvas..
if (renderTarget.colorTexture.resource === renderer.gl.canvas)
{
glRenderTarget.framebuffer = null;

Expand Down

0 comments on commit fe1c4c5

Please sign in to comment.