Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3978

Handling destroy of generated textures from canvas

$
0
0

I need to generate some textures on the fly, bassicaly when map is loaded I generate several dozens simple gradient textures.

I found here: https://github.com/pixijs/pixi.js/issues/3806 (last comments) that this is possible to use just one helper canvas to do this but after reading some other sources I am a little confused how to handle destroy of this textures.
At the moment I have some helperCanvas with 2D context to generate my textures and then I do:

// This create texture from helper canvas as I understand
var texture1 = new PIXI.Texture(new PIXI.BaseTexture(helperCanvas));

// This one "save" texture in GPU memory if I understood correctly.
renderer.textureManager.updateTexture(texture1.baseTexture);

// Create new sprite from this texture
var sprite = new Sprite( texture1 );

I do this in loop to create all needed sprites but I am not sure what should I do when map is unloaded, when I don't need these textures.
Is any action needed or GC can handle this? Should I remove them manually from textureManager by some method or call destroy on sprite?


Viewing all articles
Browse latest Browse all 3978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>