2

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.

Boiethios
  • 38,438
  • 19
  • 134
  • 183
  • Do you want to draw the items to texture and keep redrawing that texture instead of the triangles directly, or do you want some kind of "persistent" buffer? If you are doing this purely for performance considerations, you shouldn't worry about it too much until you are completely sure that it is the bottleneck. Plus, such draw calls are pretty cheap, even by the hundreds. – EvilTak Dec 26 '17 at 16:42
  • @EvilTak The question is about redrawing a single texture instead of triangles. Maybe I should also think about keeping the data in the graphical memory although I would need a lower level library than piston... I think you are right, I will benchmark my code. – Boiethios Dec 26 '17 at 16:52

0 Answers0