Jump to content

Unclear, when RenderTexture is rendered


Buran
 Share

Recommended Posts

I have a few images, which i need to combine and then store the result. As i understood, RenderTexture is just what i need.

let provinceTexture = resources["province"].texture;
let baseProvinceSprite = new PIXI.Sprite(provinceTexture);
baseProvinceSprite.x = 0;
baseProvinceSprite.y = 0;
baseProvinceSprite.width = w;
baseProvinceSprite.height = h;

                
let terrainTexture = resources["grass"].texture;
let terrainSprite = new PIXI.TilingSprite(terrainTexture, w, h);
terrainSprite.mask = baseProvinceSprite;
terrainSprite.x = 0;
terrainSprite.y = 0;
terrainSprite.width = w;
terrainSprite.height = h;

let renderTexture = PIXI.RenderTexture.create({ width: w, height: h });
app.renderer.render(terrainSprite, { renderTexture: renderTexture });

"renderTexture" stores what i need. But i also want to remove sprites and textures i used to make this rendertexture.

If i just destroy them right after .render call, rendertexture is rendered as black texture on screen. It works, only if i destroy them after 1sec timeout, but it doesnt look like a good decision. I guess, i can destroy them only when rendertexture was rendered on screen, which happens later in the code.
So, how do i make this properly?

Link to comment
Share on other sites

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...