fn create_cube<R: gfx::Resources, F: gfx::Factory<R>>(factory: &mut F)
               -> (gfx::handle::Buffer<R, Vertex>, gfx::Slice<R>)
{
    use gfx::traits::FactoryExt;
    let vertex_data = [
        // top (0, 0, 1)
        Vertex::new([-1, -1,  1], [0, 0, 1]),
        Vertex::new([ 1, -1,  1], [0, 0, 1]),
        Vertex::new([ 1,  1,  1], [0, 0, 1]),
        Vertex::new([-1,  1,  1], [0, 0, 1]),
        // bottom (0, 0, -1)
        Vertex::new([-1,  1, -1], [0, 0, -1]),
        Vertex::new([ 1,  1, -1], [0, 0, -1]),
        Vertex::new([ 1, -1, -1], [0, 0, -1]),
        Vertex::new([-1, -1, -1], [0, 0, -1]),
        // right (1, 0, 0)
        Vertex::new([ 1, -1, -1], [1, 0, 0]),
        Vertex::new([ 1,  1, -1], [1, 0, 0]),
        Vertex::new([ 1,  1,  1], [1, 0, 0]),
        Vertex::new([ 1, -1,  1], [1, 0, 0]),
        // left (-1, 0, 0)
        Vertex::new([-1, -1,  1], [-1, 0, 0]),
        Vertex::new([-1,  1,  1], [-1, 0, 0]),
        Vertex::new([-1,  1, -1], [-1, 0, 0]),
        Vertex::new([-1, -1, -1], [-1, 0, 0]),
        // front (0, 1, 0)
        Vertex::new([ 1,  1, -1], [0, 1, 0]),
        Vertex::new([-1,  1, -1], [0, 1, 0]),
        Vertex::new([-1,  1,  1], [0, 1, 0]),
        Vertex::new([ 1,  1,  1], [0, 1, 0]),
        // back (0, -1, 0)
        Vertex::new([ 1, -1,  1], [0, -1, 0]),
        Vertex::new([-1, -1,  1], [0, -1, 0]),
        Vertex::new([-1, -1, -1], [0, -1, 0]),
        Vertex::new([ 1, -1, -1], [0, -1, 0]),
    ];

    let index_data: &[u16] = &[
         0,  1,  2,  2,  3,  0, // top
         4,  5,  6,  6,  7,  4, // bottom
         8,  9, 10, 10, 11,  8, // right
        12, 13, 14, 14, 15, 12, // left
        16, 17, 18, 18, 19, 16, // front
        20, 21, 22, 22, 23, 20, // back
    ];

    factory.create_vertex_buffer_indexed(&vertex_data, index_data)
}
//----------------------------------------
// Section-2: simple primitives generation
//TODO: replace by genmesh
Section-2: simple primitives generation
TODO: replace by genmesh
Section - 2 : simple primitives generation TODO : replace by genmesh
fn create_cube<R: gfx::Resources, F: gfx::Factory<R>>(factory: &mut F)
               -> (gfx::handle::Buffer<R, Vertex>, gfx::Slice<R>)
{
    use gfx::traits::FactoryExt;
    let vertex_data = [
        // top (0, 0, 1)
        Vertex::new([-1, -1,  1], [0, 0, 1]),
        Vertex::new([ 1, -1,  1], [0, 0, 1]),
        Vertex::new([ 1,  1,  1], [0, 0, 1]),
        Vertex::new([-1,  1,  1], [0, 0, 1]),
        // bottom (0, 0, -1)
        Vertex::new([-1,  1, -1], [0, 0, -1]),
        Vertex::new([ 1,  1, -1], [0, 0, -1]),
        Vertex::new([ 1, -1, -1], [0, 0, -1]),
        Vertex::new([-1, -1, -1], [0, 0, -1]),
        // right (1, 0, 0)
        Vertex::new([ 1, -1, -1], [1, 0, 0]),
        Vertex::new([ 1,  1, -1], [1, 0, 0]),
        Vertex::new([ 1,  1,  1], [1, 0, 0]),
        Vertex::new([ 1, -1,  1], [1, 0, 0]),
        // left (-1, 0, 0)
        Vertex::new([-1, -1,  1], [-1, 0, 0]),
        Vertex::new([-1,  1,  1], [-1, 0, 0]),
        Vertex::new([-1,  1, -1], [-1, 0, 0]),
        Vertex::new([-1, -1, -1], [-1, 0, 0]),
        // front (0, 1, 0)
        Vertex::new([ 1,  1, -1], [0, 1, 0]),
        Vertex::new([-1,  1, -1], [0, 1, 0]),
        Vertex::new([-1,  1,  1], [0, 1, 0]),
        Vertex::new([ 1,  1,  1], [0, 1, 0]),
        // back (0, -1, 0)
        Vertex::new([ 1, -1,  1], [0, -1, 0]),
        Vertex::new([-1, -1,  1], [0, -1, 0]),
        Vertex::new([-1, -1, -1], [0, -1, 0]),
        Vertex::new([ 1, -1, -1], [0, -1, 0]),
    ];
    let index_data: &[u16] = &[
         0,  1,  2,  2,  3,  0, // top
         4,  5,  6,  6,  7,  4, // bottom
         8,  9, 10, 10, 11,  8, // right
        12, 13, 14, 14, 15, 12, // left
        16, 17, 18, 18, 19, 16, // front
        20, 21, 22, 22, 23, 20, // back
    ];
    factory.create_vertex_buffer_indexed(&vertex_data, index_data)
}
fn create_cube < R : gfx :: Resources , F : gfx :: Factory < R > > ( factory : & mut F ) -> ( gfx :: handle :: Buffer < R , Vertex > , gfx :: Slice < R > ) { use gfx :: traits :: FactoryExt ; let vertex_data = [ // top (0, 0, 1) Vertex :: new ( [ - 1 , - 1 , 1 ] , [ 0 , 0 , 1 ] ) , Vertex :: new ( [ 1 , - 1 , 1 ] , [ 0 , 0 , 1 ] ) , Vertex :: new ( [ 1 , 1 , 1 ] , [ 0 , 0 , 1 ] ) , Vertex :: new ( [ - 1 , 1 , 1 ] , [ 0 , 0 , 1 ] ) , // bottom (0, 0, -1) Vertex :: new ( [ - 1 , 1 , - 1 ] , [ 0 , 0 , - 1 ] ) , Vertex :: new ( [ 1 , 1 , - 1 ] , [ 0 , 0 , - 1 ] ) , Vertex :: new ( [ 1 , - 1 , - 1 ] , [ 0 , 0 , - 1 ] ) , Vertex :: new ( [ - 1 , - 1 , - 1 ] , [ 0 , 0 , - 1 ] ) , // right (1, 0, 0) Vertex :: new ( [ 1 , - 1 , - 1 ] , [ 1 , 0 , 0 ] ) , Vertex :: new ( [ 1 , 1 , - 1 ] , [ 1 , 0 , 0 ] ) , Vertex :: new ( [ 1 , 1 , 1 ] , [ 1 , 0 , 0 ] ) , Vertex :: new ( [ 1 , - 1 , 1 ] , [ 1 , 0 , 0 ] ) , // left (-1, 0, 0) Vertex :: new ( [ - 1 , - 1 , 1 ] , [ - 1 , 0 , 0 ] ) , Vertex :: new ( [ - 1 , 1 , 1 ] , [ - 1 , 0 , 0 ] ) , Vertex :: new ( [ - 1 , 1 , - 1 ] , [ - 1 , 0 , 0 ] ) , Vertex :: new ( [ - 1 , - 1 , - 1 ] , [ - 1 , 0 , 0 ] ) , // front (0, 1, 0) Vertex :: new ( [ 1 , 1 , - 1 ] , [ 0 , 1 , 0 ] ) , Vertex :: new ( [ - 1 , 1 , - 1 ] , [ 0 , 1 , 0 ] ) , Vertex :: new ( [ - 1 , 1 , 1 ] , [ 0 , 1 , 0 ] ) , Vertex :: new ( [ 1 , 1 , 1 ] , [ 0 , 1 , 0 ] ) , // back (0, -1, 0) Vertex :: new ( [ 1 , - 1 , 1 ] , [ 0 , - 1 , 0 ] ) , Vertex :: new ( [ - 1 , - 1 , 1 ] , [ 0 , - 1 , 0 ] ) , Vertex :: new ( [ - 1 , - 1 , - 1 ] , [ 0 , - 1 , 0 ] ) , Vertex :: new ( [ 1 , - 1 , - 1 ] , [ 0 , - 1 , 0 ] ) , ] ; let index_data : & [ u16 ] = & [ 0 , 1 , 2 , 2 , 3 , 0 , // top 4 , 5 , 6 , 6 , 7 , 4 , // bottom 8 , 9 , 10 , 10 , 11 , 8 , // right 12 , 13 , 14 , 14 , 15 , 12 , // left 16 , 17 , 18 , 18 , 19 , 16 , // front 20 , 21 , 22 , 22 , 23 , 20 , // back ] ; factory . create_vertex_buffer_indexed ( & vertex_data , index_data ) }
Section-2: simple primitives generation
TODO: replace by genmesh
Section - 2 : simple primitives generation TODO : replace by genmesh
factory
&mut F
factory
&mut F