spitfire_draw/
draw_buffer.rs

1use crate::utils::Vertex;
2use spitfire_glow::graphics::{GraphicsState, GraphicsTarget};
3
4#[derive(Default, Clone)]
5pub struct DrawBuffer {
6    pub state: GraphicsState<Vertex>,
7}
8
9impl DrawBuffer {
10    pub fn new(source: &dyn GraphicsTarget<Vertex>) -> Self {
11        Self {
12            state: source.state().fork(),
13        }
14    }
15
16    pub fn submit(&mut self, target: &mut dyn GraphicsTarget<Vertex>) {
17        target.state_mut().stream.append(&mut self.state.stream);
18    }
19
20    pub fn submit_cloned(&self, target: &mut dyn GraphicsTarget<Vertex>) {
21        target.state_mut().stream.append_cloned(&self.state.stream);
22    }
23}
24
25impl GraphicsTarget<Vertex> for DrawBuffer {
26    fn state(&self) -> &GraphicsState<Vertex> {
27        &self.state
28    }
29
30    fn state_mut(&mut self) -> &mut GraphicsState<Vertex> {
31        &mut self.state
32    }
33}