INNER CODE UNIT · Rust

texture_context

PistonDevelopers/piston_window · src/piston_script.rs:192

        let texture_context = unsafe {&*Current::<TextureContext>::new()};
        let glyphs = unsafe { &mut *Current::<Vec<GlyphCache<'static, TextureContext, Texture>>>::new() };
        let font_names = unsafe { &mut *Current::<FontNames>::new() };
        let file: Arc<String> = rt.pop()?;
        let texture_settings = TextureSettings::new().filter(Filter::Nearest);
        Ok(match GlyphCache::<'static, TextureContext, Texture>::new(
            &**file, texture_context.clone(), texture_settings)
        {
            Ok(x) => {
                let id = glyphs.len();
                glyphs.push(x);
                font_names.0.push(file.clone());
                Ok::<usize, Arc<String>>(id).push_var()
            }
            Err(err) => {
                Err::<usize, Arc<String>>(Arc::new(format!("{}", err))).push_var()
            }
        })

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…