hecrj / wgpu_glyph

A fast text renderer for wgpu (https://github.com/gfx-rs/wgpu)
https://docs.rs/wgpu_glyph
MIT License
441 stars 77 forks source link

Broken Documentation links? #97

Open EggShark opened 1 year ago

EggShark commented 1 year ago

Im writing a game engine and using wgpu_glyph for the text rendering and here is the snippet of my code

         render_items.transformed_text.iter()
            .map(|text| (wgpu_glyph::Section{
                screen_position: (text.position.x, text.position.y),
                bounds: (self.size.width as f32, self.size.height as f32),
                text: vec![wgpu_glyph::Text::new(&text.text).with_color(text.colour.to_raw())],
                ..Default::default()
                }, text.transformation))
            .for_each(|(section, transform)| {
                let text_transform = unflatten_matrix(transform);
                let ortho = unflatten_matrix(orthographic_projection(self.size.width, self.size.height));
                let transform = flatten_matrix(ortho * text_transform);
                self.glyph_brush.queue(section);
                self.glyph_brush.draw_queued_with_transform(
                    &self.device, &mut staging_belt, &mut encoder, &view, &self.camera_bind_group, transform,
                ).unwrap();
            });
        let text_sections = render_items.text
            .iter()
            .map(|text| wgpu_glyph::Section{
                screen_position: (text.position.x, text.position.y),
                bounds: (self.size.width as f32, self.size.height as f32),
                text: vec![wgpu_glyph::Text::new(&text.text).with_color(text.colour.to_raw())],
                ..Default::default()
            })
            .collect::<Vec<wgpu_glyph::Section>>();
        text_sections.into_iter().for_each(|s| self.glyph_brush.queue(s));
        self.glyph_brush.draw_queued(&self.device, &mut staging_belt, &mut encoder, &view, &self.camera_bind_group, self.size.width, self.size.height).unwrap();

This produces a strange result where the text that is supposed to have no transformations (other than the orthographic transformation) So i went to the documentation for the glyph_brush and under queue it states Benefits from caching, see caching behaviour; however, when I click the link to see this caching behavior it links nowhere.