When I want to draw some primitives in Piston, I do something like that:
let gl = &mut GlGraphics::new(OpenGL::V3_2);
gl.draw(viewport, |context, gl| {
Rectangle::new([1., 1., 1., 1.])
.draw([0., 0., 10., 20.], &context.draw_state, context.view, gl);
});
This code draws a rectangle in a buffer and diplay it on the screen. But what if I want to draw some primitives in a texture (i.e. keep the buffer for reusing it)? I am not sure about the library optimization, and if I could make this, I would have hundreds less triangles to draw.