Jump to content

Dynamic asset loading in WebGL


arnuschky
 Share

Recommended Posts

You can destroy resources yes, but it's up to the browser when they are eventually garbage collected. There's certainly no way to force something to be unloaded at a specific time, more just a "please delete this when you can". This is the reason no engines that run in a browser actually truly support it.

Link to comment
Share on other sites

You can destroy resources yes, but it's up to the browser when they are eventually garbage collected. There's certainly no way to force something to be unloaded at a specific time, more just a "please delete this when you can". This is the reason no engines that run in a browser actually truly support it.

 

There's a call on CocoonJS to control this now (for images only, I think, just call img.dispose()). The question is: does the architecture of Pixi support dynamic unloading of textures? For instance, can I load a spritemap for each level, and each time I switch level I unload the old and one load the new one? Does that work properly with the WebGL texture maps?

Link to comment
Share on other sites

Just make sure to destroy your textures when you are done with them. `texture.destroy(true)` will remove it from WebGL memory.

 

Cleaning up the javascript objects can be done the same way you remove resources in javascript anywhere else, null out your references and let the GC clean up later.

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