pub fn with_data(primitive_mode: PrimitiveMode, vertices: &[T]) -> VertexBuffer<T> {
        let usage = BufferUsage::StaticDraw;
        let mut buffer = VertexBuffer::new(primitive_mode, usage);

        let vertex_count = vertices.len();
        let bytes = mem::size_of::<T>() * vertex_count;

        unsafe {
            gl::GenBuffers(1, &mut buffer.vbo);
            gl::BindBuffer(BufferTarget::Array as GLenum, buffer.vbo);
            gl::BufferData(
                BufferTarget::Array as GLenum,
                bytes as GLsizeiptr,
                mem::transmute(&vertices[0]),
                usage as GLenum
            );

            gl::BindVertexArray(buffer.vao);
            T::setup_attrib_pointers(0);
        }

        buffer.vertex_count = vertex_count;
        buffer.allocated    = vertex_count;

        return buffer;
    }
/// Creates a new vertex buffer, storing the given vertices on the GPU.
Creates a new vertex buffer, storing the given vertices on the GPU.
Creates a new vertex buffer storing the given vertices on the GPU .
pub fn with_data(primitive_mode: PrimitiveMode, vertices: &[T]) -> VertexBuffer<T> {
        let usage = BufferUsage::StaticDraw;
        let mut buffer = VertexBuffer::new(primitive_mode, usage);
        let vertex_count = vertices.len();
        let bytes = mem::size_of::<T>() * vertex_count;
        unsafe {
            gl::GenBuffers(1, &mut buffer.vbo);
            gl::BindBuffer(BufferTarget::Array as GLenum, buffer.vbo);
            gl::BufferData(
                BufferTarget::Array as GLenum,
                bytes as GLsizeiptr,
                mem::transmute(&vertices[0]),
                usage as GLenum
            );
            gl::BindVertexArray(buffer.vao);
            T::setup_attrib_pointers(0);
        }
        buffer.vertex_count = vertex_count;
        buffer.allocated    = vertex_count;
        return buffer;
    }
pub fn with_data ( primitive_mode : PrimitiveMode , vertices : & [ T ] ) -> VertexBuffer < T > { let usage = BufferUsage :: StaticDraw ; let mut buffer = VertexBuffer :: new ( primitive_mode , usage ) ; let vertex_count = vertices . len ( ) ; let bytes = mem :: size_of :: < T > ( ) * vertex_count ; unsafe { gl :: GenBuffers ( 1 , & mut buffer . vbo ) ; gl :: BindBuffer ( BufferTarget :: Array as GLenum , buffer . vbo ) ; gl :: BufferData ( BufferTarget :: Array as GLenum , bytes as GLsizeiptr , mem :: transmute ( & vertices [ 0 ] ) , usage as GLenum ) ; gl :: BindVertexArray ( buffer . vao ) ; T :: setup_attrib_pointers ( 0 ) ; } buffer . vertex_count = vertex_count ; buffer . allocated = vertex_count ; return buffer ; }
Creates a new vertex buffer, storing the given vertices on the GPU.
Creates a new vertex buffer storing the given vertices on the GPU .
primitive_mode
PrimitiveMode
vertices
&[T]
primitive_mode
PrimitiveMode
vertices
&[T]