Remove unnecessary copy of mesh indices in glium painter

This commit is contained in:
Emil Ernerfeldt 2021-04-05 10:21:17 +02:00
parent b028e708e0
commit 4fc3c6d375

View file

@ -152,11 +152,9 @@ impl Painter {
glium::VertexBuffer::new(display, &vertices).unwrap()
};
let indices: Vec<u32> = mesh.indices.iter().map(|idx| *idx as u32).collect();
// TODO: we should probably reuse the `IndexBuffer` instead of allocating a new one each frame.
let index_buffer =
glium::IndexBuffer::new(display, PrimitiveType::TrianglesList, &indices).unwrap();
glium::IndexBuffer::new(display, PrimitiveType::TrianglesList, &mesh.indices).unwrap();
let (width_in_pixels, height_in_pixels) = display.get_framebuffer_dimensions();
let width_in_points = width_in_pixels as f32 / pixels_per_point;