Jump to content

CanvasRenderer RenderTexture not cleared


Rob Gordon
 Share

Recommended Posts

There appears to be an issue with clearing the context when rendering a container to a RenderTexture while using the CanvasRenderer (PIXI-legacy v5.2.4).

Consider this example:
https://www.pixiplayground.com/#/edit/gM7jGSOAvFhZEeJPKeGI4

Click anywhere to toggle the visibility of one of the bunnies.

Using the CanvasRenderer the context is not cleared, and the bunnies remain visible. Using the WebGL renderer (switch forceCanvas to false) this works as expected.

I believe the issue may be here:
if (clear !== undefined ? clear : this.clearBeforeRender) {
if (this.renderingToScreen) {
if (this.transparent) {
context.clearRect(0, 0, this.width, this.height);
}
else {
context.fillStyle = this._backgroundColorString;
context.fillRect(0, 0, this.width, this.height);
}
} // else {
// TODO: implement background for CanvasRenderTarget or RenderTexture?
// }
}

The 'TODO' needs to get done. It appears there is no context management for the case where we are not renderingToScreen (as I believe is the case when we are rendering a Container to a RenderTexture).

 

** I've posted this to the github issues, but thought it might make sense to post it here as well to ensure that this isn't an error of understanding or implementation on my part...

Link to comment
Share on other sites

Understood - though this is the kind of thing that should probably be reflected in the documentation (RenderTexture is a major feature, imo).

Do you know if this is slated for the upcoming 5.3.0 release? I would think having parity between WebGL & Canvas would be critical.

Anything you can share from your custom implementation? Is it as simple as removing the check for this.renderingToScreen, or will that break things?

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...