1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
use renderer::CreationProxy; use glin::{self, SimpleVao}; use traits::ToSimpleVao; use util::{Error, Result}; use math::one; use graphics::{Node, NodeT, node}; pub struct Builder{ pub(crate) gl: CreationProxy, } impl Builder{ pub fn from_mesh<T, U, G>(&self, mesh: &G) -> Result<Object<SimpleVao<T>>> where G: ToSimpleVao<T,U>, { let vao = mesh.to_simple_vao(&self.gl, &::default_attribute_bindings(), glin::gl::STATIC_DRAW) .map_err(|err| Error::with_cause("Error creating vao from mesh", err))?; Ok(Object{ geom: vao, node: one(), }) } } pub struct Object<G>{ geom: G, node: Node, } impl<G> Object<G>{ pub fn new(geom: G) -> Object<G> { Object{ geom, node: one(), } } pub fn geometry(&self) -> &G{ &self.geom } } impl<G> NodeT for Object<G>{ fn node(&self) -> &Node { &self.node } fn node_mut(&mut self) -> &mut Node { &mut self.node } fn update_with_parent_flags(&mut self, parent: Option<&Node>, flags: node::Flags) -> bool{ self.node.update_with_parent_flags(parent, flags) } }