Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting a texture before dispose #12

Open
wwwtyro opened this issue Mar 25, 2016 · 2 comments
Open

Extracting a texture before dispose #12

wwwtyro opened this issue Mar 25, 2016 · 2 comments

Comments

@wwwtyro
Copy link

wwwtyro commented Mar 25, 2016

I have a use case where I want to render to a texture for later use, but I don't need the fbo object to stick around. Since dispose also wipes the texture, I've been doing this:

var texture = fbo.color[0];
fbo.color = [];
fbo.dispose();

This allows me to keep the texture object and still call dispose on the fbo, but is a little hacky. Is there a better pattern for this? If not, what would an acceptable API for this behavior be? Something like the following?

var texture = fbo.color[0];
fbo.dispose({preserveColor: true});

I'm happy to make a PR if we can find consensus.

@mikolalysenko
Copy link
Member

Another way to do it would be to inject the texture via an argument, though it might take a bit more work to set up and then you have to track the texture as a dependency. The advantage there though is that it is closer to how WebGL actually works and it would let you reuse the same texture across multiple FBOs.

That said, I think the dispose() modification seems reasonable. If you want to write a PR, go for it and I'll merge it in. It is probably less work up front and doesn't really break anything existing.

@wwwtyro
Copy link
Author

wwwtyro commented Mar 25, 2016

Those are great points. I'm wondering now if a better approach might be to make a new fbo module that expects a texture, and then convert this module into a wrapper around it that still matches this module's behavior. Seems like it might make the internal logic easier, and still leaves users with an easy-to-comprehend module here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants