Skip to content

Commit

Permalink
fix multi render (#11260)
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodBoyDigital authored Feb 7, 2025
1 parent 7f5d1af commit 38709e8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class GlRenderTargetAdaptor implements RenderTargetAdaptor<GlRenderTarget
// we are rendering to the main canvas..
const colorTexture = renderTarget.colorTexture;

if (colorTexture.resource === renderer.canvas)
if (CanvasSource.test(colorTexture.resource))
{
this._renderer.context.ensureCanvasSize(renderTarget.colorTexture.resource);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,32 @@ export class RenderTargetSystem<RENDER_TARGET extends GlRenderTarget | GpuRender
}

/**
* Copies a render surface to another texture
* Copies a render surface to another texture.
*
* NOTE:
* for sourceRenderSurfaceTexture, The render target must be something that is written too by the renderer
*
* The following is not valid:
* @example
* const canvas = document.createElement('canvas')
* canvas.width = 200;
* canvas.height = 200;
*
* const ctx = canvas2.getContext('2d')!
* ctx.fillStyle = 'red'
* ctx.fillRect(0, 0, 200, 200);
*
* const texture = RenderTexture.create({
* width: 200,
* height: 200,
* })
* const renderTarget = renderer.renderTarget.getRenderTarget(canvas2);
*
* renderer.renderTarget.copyToTexture(renderTarget,texture, {x:0,y:0},{width:200,height:200},{x:0,y:0});
*
* The best way to copy a canvas is to create a texture from it. Then render with that.
*
* Parsing in a RenderTarget canvas context (with a 2d context)
* @param sourceRenderSurfaceTexture - the render surface to copy from
* @param destinationTexture - the texture to copy to
* @param originSrc - the origin of the copy
Expand Down

0 comments on commit 38709e8

Please sign in to comment.