diff --git a/docs/TODO_ux.md b/docs/TODO_ux.md index 0d360b14c7..383a0e119f 100644 --- a/docs/TODO_ux.md +++ b/docs/TODO_ux.md @@ -66,11 +66,11 @@ ## Switch to OpenGL (for speed) - get things running again - - editor is very slow... why? - - colors still seem off - circles, arrows, other disabled things - forking - render text + - colors still seem off + - make polygon store points and indices efficiently - change ezgui API to allow uploading geometry once - undo the y inversion hacks at last! diff --git a/ezgui/src/lib.rs b/ezgui/src/lib.rs index 5f57e348f7..7320b13f37 100644 --- a/ezgui/src/lib.rs +++ b/ezgui/src/lib.rs @@ -212,31 +212,28 @@ impl<'a> GfxCtx<'a> { } pub fn draw_polygon(&mut self, color: Color, poly: &geom::Polygon) { + let mut vertices: Vec = Vec::new(); for tri in &poly.triangles { - let vb = glium::VertexBuffer::new( - self.display, - &[ - Vertex { - position: [tri.pt1.x() as f32, tri.pt1.y() as f32], - color: color.0, - }, - Vertex { - position: [tri.pt2.x() as f32, tri.pt2.y() as f32], - color: color.0, - }, - Vertex { - position: [tri.pt3.x() as f32, tri.pt3.y() as f32], - color: color.0, - }, - ], - ) - .unwrap(); - let indices = glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList); - - self.target - .draw(&vb, &indices, &self.program, &self.uniforms, &self.params) - .unwrap(); + vertices.push(Vertex { + position: [tri.pt1.x() as f32, tri.pt1.y() as f32], + color: color.0, + }); + vertices.push(Vertex { + position: [tri.pt2.x() as f32, tri.pt2.y() as f32], + color: color.0, + }); + vertices.push(Vertex { + position: [tri.pt3.x() as f32, tri.pt3.y() as f32], + color: color.0, + }); } + + let vb = glium::VertexBuffer::new(self.display, &vertices).unwrap(); + let indices = glium::index::NoIndices(glium::index::PrimitiveType::TrianglesList); + + self.target + .draw(&vb, &indices, &self.program, &self.uniforms, &self.params) + .unwrap(); } pub fn draw_circle(&mut self, color: Color, circle: &geom::Circle) {