-
Notifications
You must be signed in to change notification settings - Fork 178
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
Question: How to recreate a ReferenceType using only the numeric primitive? #339
Comments
Not sure why you're messing around with raw pointers (could you explain more?). You also shouldn't be using hidden methods, since they're supposed to be internal. But to answer your question, |
Thanks for asking @Pauan. I am supporting both OpenGL and WebGL and the former lets you reference program, texture, location, etc through primitives like u32. With WebGL, I have to deal with opaque references that are hard to deconstruct and reconstruct. If I have a Trait or other system of passing around information, it is useful to have the most simple primitives. Of course, I can cache stuff and look it up, but it seems like the WebGL system is making it unnecessarily difficult for me. WebGLTexture is getting generated as part of the |
Okay, so taking a look at the docs, it seems to have a use stdweb::unstable::TryInto;
let texture: WebGLTexture = a_ref.try_into().unwrap(); |
Thanks for the advice. It didn't work using your example, but it did give me a better understanding of the necessary imports. I didn't import ReferenceType before and I think that was one problem. use stdweb::ReferenceType; // along with all the others
let a_ref = Reference::from_raw_unchecked(img_id as i32);
let result = WebGLTexture::from_reference_unchecked(a_ref); Thanks so much. Closing this now. |
Suppose you want to store the u32 value of a created stdweb object that wraps a Reference. For me, I am working with WebGLTexture objects. You can get the u32 value out like this
Great! Now, I want to use the u32 value to recreate the WebGLTexture so I can bind it. I really don't know how and I've tried many things. Any ideas? I can get as far as this, and I get a
Reference(u32)
object but I can't get to the final step using downcast or any other means.Thanks for any help you can provide.
The text was updated successfully, but these errors were encountered: