Skip to content

Question: How to recreate a ReferenceType using only the numeric primitive? #339

@hughlang

Description

@hughlang

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

        let texture = try_opt(self.gl_ctx.create_texture(), "Create GL texture")?;
        let raw = texture.as_ref();
        let id = raw.as_raw() as u32;

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.

       let a_ref = Reference::from_raw_unchecked(img_id as i32);

Thanks for any help you can provide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions